Data source: CKAN Open Data Portals
Overview
Open Data (Government Portals) wraps CKAN Open Data Portals, handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.
Prerequisites
- Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
- Choose your integration method: MCP protocol or REST API.
Connect via MCP
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"gnist-opendata": {
"url": "https://context.gnist.ai/mcp/opendata/",
"headers": {
"Gnist-API-Key": "YOUR_API_KEY"
}
}
}
}
Tools (5)
search_datasets
Search government open data datasets across US (data.gov), UK (data.gov.uk), or Canada (open.canada.ca). Covers 460K+ datasets published by government agencies — CSV, JSON, GeoJSON, and API endpoints for climate, transportation, health, economics, geospatial, and more. All free, no API key required. Each result includes download links, formats, and organization info. Args: query: Keyword or topic to search for. portal: Which country portal to search. limit: Number of results (1-50, default 20). offset: Pagination offset. Returns: List of matching datasets with title, description, organization, resources (download links), tags, and license. Use get_dataset for full details on a specific result.
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | required | Search query for datasets (e.g. "climate change", "transportation safety", "public health spending"). |
portal | string | optional | Portal to search: 'us' (data.gov, 290K+ datasets), 'uk' (data.gov.uk, 55K+), 'ca' (open.canada.ca, 115K+). Default 'us'. (default: us) |
limit | integer | optional | Number of results (1-50, default 20). (default: 20) |
offset | integer | optional | Result offset for pagination (default 0). (default: 0) |
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_datasets", "arguments": {"query": "climate change"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/opendata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'query': 'climate change'},
'name': 'search_datasets'}},
)
print(resp.json())
get_dataset
Get full details for a single government dataset by its name or ID. Returns complete metadata including all download resources (CSV, JSON, API endpoints), description, organization, tags, license, and last-modified date. Args: dataset_id: Dataset name or UUID from search results. portal: Which country portal. Returns: Full dataset record with resources, or found=false if not found.
| Parameter | Type | Required | Description |
|---|---|---|---|
dataset_id | string | required | Dataset name or ID (e.g. 'annual-enterprise-survey-2021'). Found in search_datasets results. |
portal | string | optional | Portal: 'us', 'uk', or 'ca'. Default 'us'. (default: us) |
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_dataset", "arguments": {"dataset_id": "'annual-enterprise-survey-2021'"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/opendata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'dataset_id': "'annual-enterprise-survey-2021'"},
'name': 'get_dataset'}},
)
print(resp.json())
list_organizations
List government organizations that publish open data on a portal. Browse the publishing organizations (agencies, departments, offices) on a specific portal. Each entry shows the organization name, description, and number of datasets published. Args: portal: Which country portal. limit: Number of results (1-50, default 20). Returns: List of organizations with name, description, and dataset count.
| Parameter | Type | Required | Description |
|---|---|---|---|
portal | string | optional | Portal: 'us', 'uk', or 'ca'. Default 'us'. (default: us) |
limit | integer | optional | Number of results (1-50, default 20). (default: 20) |
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "list_organizations", "arguments": {"portal": "us"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/opendata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'portal': 'us'}, 'name': 'list_organizations'}},
)
print(resp.json())
get_organization
Get details for a specific government data-publishing organization. Returns organization metadata including description, logo, and total dataset count. Args: org_id: Organization name or UUID. portal: Which country portal. Returns: Organization details with dataset count, or found=false if not found.
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id | string | required | Organization name or ID (e.g. 'nasa-gov', 'department-of-energy'). Found in list_organizations results. |
portal | string | optional | Portal: 'us', 'uk', or 'ca'. Default 'us'. (default: us) |
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_organization", "arguments": {"org_id": "'nasa-gov'"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/opendata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'org_id': "'nasa-gov'"}, 'name': 'get_organization'}},
)
print(resp.json())
report_feedback
Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.
| Parameter | Type | Required | Description |
|---|---|---|---|
feedback | string | required | |
feedback_type | string | optional | (default: general) |
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/opendata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())
Common Patterns
Use
search_datasets to find items, then get_dataset to get full details. This two-step pattern is common for exploring data before drilling down.Several tools support
limit, offset, or page parameters. Start with small limits during development, then increase for production queries.FAQ
What data does Open Data (Government Portals) provide?
Search 460K+ government datasets across US (data.gov), UK (data.gov.uk), and Canada (open.canada.ca) open data portals — find datasets by topic, organization, or keyword. It exposes 5 tools: search_datasets, get_dataset, list_organizations, get_organization, report_feedback.
What do I need to get started?
A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.
What format does the Open Data (Government Portals) API return?
JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.