Skip to main content
Glama
CKAN MCP Server

CKAN MCP Server

by ondata

Search CKAN DataStore with SQL

ckan_datastore_search_sql
Read-onlyIdempotent

Run SQL queries directly on CKAN DataStore resources to retrieve filtered or aggregated open data results without downloading entire datasets.

Instructions

Run SQL queries on a CKAN DataStore resource.

This endpoint is only available on CKAN portals with DataStore enabled and SQL access exposed.

Args:

  • server_url (string): Base URL of CKAN server

  • sql (string): SQL query (e.g., SELECT * FROM "resource_id" LIMIT 10)

  • response_format ('markdown' | 'json'): Output format

Returns: SQL query results from DataStore

Examples:

  • { server_url: "...", sql: "SELECT * FROM "abc-123" LIMIT 10" }

  • { server_url: "...", sql: "SELECT COUNT(*) AS total FROM "abc-123"" }

Typical workflow: ckan_package_show (get resource_id) → ckan_datastore_search_sql (run SQL on it)

Security note: SQL queries are forwarded directly to the CKAN DataStore API. The CKAN server enforces its own access controls and read-only permissions. No local database is exposed. Queries are limited to public DataStore resources on the target portal.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "server_url": "<server_url>",
      "sql": "<sql>"
    },
    "name": "ckan_datastore_search_sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL SELECT query; resource_id is the table name, must be double-quoted (e.g., SELECT * FROM "abc-123" LIMIT 10). Column names with capitals, spaces or accents must be double-quoted too (SELECT "Comune" ...)
server_urlYesBase URL of the CKAN server (e.g., https://dati.gov.it/opendata)
response_formatNoOutput format: 'markdown' for human-readable or 'json' for machine-readablemarkdown

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.4.146
    • changedInput schema / properties / sql / description
      Previous value: -"SQL SELECT query; resource_id is the table name, must be double-quoted (e.g., SELECT * FROM \"abc-123\" LIMIT 10)"New value: +"SQL SELECT query; resource_id is the table name, must be double-quoted (e.g., SELECT * FROM \"abc-123\" LIMIT 10). Column names with capitals, spaces or accents must be double-quoted too (SELECT \"Comune\" ...)"
  2. First observedv0.4.108

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive, but the security note adds genuine context beyond them: queries are forwarded to the CKAN DataStore API, the remote server enforces its own access controls, no local DB is exposed, and only public resources on the target portal are reachable. What is missing is any disclosure of result-size caps or rate limits, which are real constraints for CKAN's SQL endpoint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and security preamble are front-loaded well, but the Args block verbatim duplicates the schema fields, and the two Examples largely repeat the example already inside the sql property description. Removing those leaves a tighter, still complete definition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter tool with no output schema, the description covers prerequisites, the resource_id-as-table-name convention, a workflow, and security scope. It would be fully complete with a note on row limits/truncation and what a failure looks like when the portal lacks SQL access.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents server_url, sql, and response_format, including the double-quoting rule and the enum. The description's Args block and examples restate the same information without adding new meaning (e.g., no guidance on which SQL clauses the endpoint rejects). Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: "Run SQL queries on a CKAN DataStore resource." This is clearly distinct from the sibling ckan_datastore_search (which takes filters, not SQL) and from ckan_package_show, and the stated workflow chains them together. It does not explicitly contrast itself with ckan_datastore_search, so an agent must infer the difference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives a real precondition ("only available on CKAN portals with DataStore enabled and SQL access exposed") and a typical workflow naming the prerequisite tool (ckan_package_show to get resource_id). It stops short of saying when to prefer this over ckan_datastore_search or what to do when SQL access is not exposed, so no explicit exclusion is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.