Skip to main content
Glama
CKAN MCP Server

CKAN MCP Server

by ondata

Search CKAN DataStore

ckan_datastore_search
Read-onlyIdempotent

Query CKAN DataStore tabular resources with filters, full-text search, sorting, and pagination; use limit=0 first to discover column names and avoid invalid filter errors.

Instructions

Query data from a CKAN DataStore resource.

The DataStore allows SQL-like queries on tabular data. Not all resources have DataStore enabled.

The response always includes a Fields section listing all available column names and types. Use limit=0 to discover column names without fetching data — do this before using filters to avoid guessing column names and getting HTTP 400 errors.

Args:

  • server_url (string): Base URL of CKAN server

  • resource_id (string): ID of the DataStore resource

  • q (string | object): Full-text search (optional). A string searches all fields; an object such as { "column": "word" } searches only that column. Some portals refuse whole-table full-text search on large tables but accept the column form

  • filters (object): Key-value filters (e.g., { "anno": 2023 })

  • limit (number): Max rows to return (default: 100, max: 32000)

  • offset (number): Pagination offset (default: 0)

  • fields (array): Specific fields to return (optional)

  • sort (string): Sort field with direction (e.g., "anno desc")

  • distinct (boolean): Return distinct values (default: false)

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

Returns: DataStore records matching query, always including available column names and types

Examples:

  • { server_url: "...", resource_id: "abc-123", limit: 0 } ← discover columns first

  • { server_url: "...", resource_id: "abc-123", limit: 50 }

  • { server_url: "...", resource_id: "...", filters: { "regione": "Sicilia" } }

  • { server_url: "...", resource_id: "...", sort: "anno desc", limit: 100 }

Typical workflow: ckan_package_search → ckan_package_show (find resource_id with datastore_active=true) → ckan_datastore_search (limit=0 to get columns) → ckan_datastore_search (with filters)

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>",
      "resource_id": "<resource_id>"
    },
    "name": "ckan_datastore_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
qNoFull-text search: a string searches all fields; an object { "column": "word" } searches only that column (accepted by some portals that refuse full-text search on large tables)
sortNoSort expression (e.g., 'anno desc', 'nome asc')
limitNoMax rows to return (default 100, max 32000); use 0 to get only column names without data
fieldsNoSpecific field names to return; omit to return all fields
offsetNoPagination offset
filtersNoKey-value filters for exact matches (e.g., { "regione": "Sicilia", "anno": 2023 })
distinctNoReturn only distinct rows
server_urlYesBase URL of the CKAN server (e.g., https://dati.gov.it/opendata)
resource_idYesUUID of the DataStore resource (from ckan_package_show resource.id where datastore_active is true)
response_formatNoOutput format: 'markdown' for human-readable or 'json' for machine-readablemarkdown

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.4.144
    • addedInput schema / properties / q / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "additionalProperties": {
      +      "type": "string"
      +    },
      +    "type": "object"
      +  }
      +]
    • changedInput schema / properties / q / description
      Previous value: -"Full-text search across all fields"New value: +"Full-text search: a string searches all fields; an object { \"column\": \"word\" } searches only that column (accepted by some portals that refuse full-text search on large tables)"
    • removedInput schema / properties / q / type
      Removed value: -"string"
  2. First observedv0.4.108

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already cover the read-only, idempotent, non-destructive profile, so the description is free to add operationally useful behavior: the prerequisite that datastore_active must be true, that column metadata is always returned, and that some portals reject whole-table full-text search but accept the column-object form. It omits any statement about response size limits or how pagination interacts with large result sets beyond the raw offset parameter.

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

Conciseness5/5

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

Front-loaded purpose sentence, then constraints, then a compact Args/Returns/Examples/workflow layout that an agent can scan quickly. The Args list duplicates schema text slightly, but the four examples and the workflow line earn their space by making the call pattern unmistakable.

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

Completeness5/5

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

There is no output schema, so the description carries the return-value burden and does it by stating that a Fields section with column names and types is always included. Combined with the prerequisite check (datastore_active) and the column-discovery pattern, an agent has everything needed to call this correctly on the first attempt.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds genuine meaning: the rationale for limit=0, the distinction between string and object forms of q and why the object form succeeds where the string fails, and worked examples mapping filters/sort/limit to realistic calls. The Args block largely restates the schema, which limits how much extra value it contributes.

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 and resource ('Query data from a CKAN DataStore resource') and adds the key qualifier that not all resources have DataStore enabled. It clearly distinguishes itself from the package-level siblings it names, but never contrasts itself with ckan_datastore_search_sql, the closest alternative for the same resource.

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?

Provides concrete when-to-use guidance: call with limit=0 first to discover column names, then run the real query with filters, and it explains the failure mode (HTTP 400 from guessing columns) that motivates the sequence. A full recommended workflow across ckan_package_search → ckan_package_show → this tool is spelled out, though it gives no guidance on when the SQL sibling would be preferable.

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