Skip to main content
Glama

SPARQL query on Wikidata

query_wikidata
Read-only

Run read-only SPARQL SELECT or ASK queries against Wikidata to retrieve entity data, labels, and Swiss municipality codes with predefined prefixes and automatic limits.

Instructions

Run a read-only SPARQL SELECT (or ASK) against the Wikidata Query Service. Prefixes wd:, wdt:, p:, ps:, pq:, rdfs:, schema:, wikibase:, bd: are predefined; use SERVICE wikibase:label { bd:serviceParam wikibase:language "de,fr,en". } for labels. Swiss hooks: wd:Q39 = Switzerland, wdt:P771 = BFS municipality code, wdt:P17 = country, wdt:P131 = located in. Example: SELECT ?m ?mLabel ?bfs WHERE { ?m wdt:P771 ?bfs . SERVICE wikibase:label { bd:serviceParam wikibase:language "de". } }. LIMIT 100 is injected when absent; larger LIMITs are clamped to 1000. 60 s timeout.

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": {
      "query": "<query>"
    },
    "name": "query_wikidata"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesSPARQL SELECT/ASK query (read-only)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.3

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint and openWorldHint, so safety is covered, and the description adds genuinely non-obvious runtime behavior: automatic LIMIT 100 injection, clamping of larger LIMITs to 1000, and a 60 s timeout. It does not describe the result shape (bindings vs boolean for ASK) or error behavior, which keeps it short of a 5.

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

Conciseness4/5

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

Front-loaded with the core action, then progressively more specific guidance (prefixes, labels, Swiss hooks, example, limits, timeout). Dense but each clause carries actionable information; the example is worth its length, though the Swiss hook list borders on reference material.

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 single-string query tool with no output schema, an agent has enough to construct and safely invoke a call: prefixes, label pattern, limits, and timeout are all stated. The remaining gap is return-value shape (rows and bindings versus a boolean for ASK), which matters for composing follow-up calls.

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% and the single parameter is documented as a read-only SPARQL string, so the baseline would be 3. The description earns above baseline by adding real meaning for the query content: the predefined prefix set, the label SERVICE template, Swiss property hooks, and a complete worked example.

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

Purpose5/5

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

States a specific verb and resource: run a read-only SPARQL SELECT/ASK against the Wikidata Query Service. That is clearly distinct from get_wikidata_entity and search_wikidata, which target individual entities or keyword lookup rather than arbitrary query execution.

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

Usage Guidelines3/5

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

The description covers what you can write (SELECT/ASK, predefined prefixes, label SERVICE) and gives a Swiss-data example, so intended usage is strongly implied. However, it never says when to reach for this tool instead of get_wikidata_entity or search_wikidata, and never warns that free-form queries are unnecessary for simple entity lookups.

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

Deploy Server

Other Tools