Skip to main content
Glama

Wikidata SPARQL Query

wikidata_sparql_query
Read-only

Execute a SPARQL SELECT query against the Wikidata Query Service. Full graph power: multi-hop traversals, aggregations, subqueries, OPTIONAL, FILTER, UNION, BIND. Standard Wikidata prefixes (wd:, wdt:, p:, ps:, pq:, wikibase:, bd:) are auto-injected. The wikibase:label SERVICE is also auto-injected when language is set and the query includes ?Label variables — so you can use ?itemLabel without writing the boilerplate. Hard server timeout is 60s; use LIMIT to keep queries fast. Bindings use the SPARQL 1.1 JSON format: each value is { type, value, "xml:lang"? }. Use wikidata_get_labels to humanize QID results from this tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSPARQL SELECT query. Must be a SELECT query (not CONSTRUCT/DESCRIBE/ASK). Standard prefixes (wd:, wdt:, p:, ps:, pq:, wikibase:, bd:) are injected automatically. Example: SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146. } LIMIT 10
timeoutNoClient-side timeout in seconds (1–55). Capped at 55s — the Wikidata server hard limit is 60s.
languageNoLanguage for the wikibase:label SERVICE (e.g., "en", "de"). Controls the language of ?<var>Label variables. Set to "" to suppress label SERVICE injection.en

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorNoPresent when the call failed. Absent on success.
noticeNoRecovery hint when no results returned — suggests checking query logic or broadening filters. Absent on non-empty results.
resultsNoArray of result bindings. Each row maps variable names to binding objects with { type, value, "xml:lang"?, datatype? } fields.
truncatedNoTrue when the row count equals 10,000 — the Wikidata/Blazegraph server-side cap — indicating the result set was likely truncated. False otherwise. Add a LIMIT clause to avoid hitting the cap. Note: the SPARQL endpoint does not expose an explicit truncation flag; this is an inferred signal.
variablesNoVariable names returned by the SELECT clause.
totalCountNoNumber of result rows returned.

TDQS

A4.4/5.0
Behavior5/5

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

Annotations (readOnlyHint: true, openWorldHint: true) are reinforced rather than contradicted, and the description adds substantial behavior beyond them: SELECT-only enforced, auto-injection of standard prefixes, the dynamic wikibase:label SERVICE injection rule, the 60s hard server timeout, and the SPARQL 1.1 JSON binding format. An agent can predict failure modes and output shapes without a trial call. No contradiction with annotations; annotation_contradiction = false.

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?

Dense but never padded. Every clause delivers a distinct fact: purpose, capability scope, prefix injection, label SERVICE behavior, timeout, response format, and cross-tool routing. The core purpose leads, and behavioral details follow in logical order with zero fluff.

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 full SPARQL endpoint, the description covers the critical gotchas an agent would otherwise discover through failed calls: auto-injected prefixes, label SERVICE magic, timeout ceiling, and response shape. An output schema exists to carry return-value documentation. Minor gaps like rate limiting, error handling for malformed queries, and caching are not addressed, but these are optional given the output schema's presence.

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?

At 100% schema coverage, the baseline is 3, but the description adds meaning beyond the schema: it explains the 60s server cap that rationalizes the timeout parameter's 55s maximum, and it clarifies the label SERVICE auto-injection rule that governs how the language and query parameters interact. The 'use LIMIT to keep queries fast' tip connects the query param to performance behavior.

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?

The opening sentence, 'Execute a SPARQL SELECT query against the Wikidata Query Service,' is a textbook example of specific verb + resource. It further enumerates capability ('multi-hop traversals, aggregations, subqueries, OPTIONAL, FILTER, UNION, BIND') and implicitly differentiates from siblings by naming wikidata_get_labels as the follow-up for humanization, clarifying what this tool is not for.

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 closing pointer to 'Use wikidata_get_labels to humanize QID results' gives one alternative-routing hint, and 'Full graph power' implies this is the heavy-duty sibling versus simpler accessors. However, there is no explicit statement of when to prefer this over wikidata_get_entity, wikidata_get_statements, or search tools — the when/when-not boundary is implied, not stated.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A4.5/5.0
Disambiguation5/5

Each tool targets a distinct access pattern: entity retrieval, label resolution, sitelinks, statements, external ID lookup, text search, and SPARQL. Any apparent overlap (e.g., get_entity with fields vs. get_statements) is explicitly disambiguated in the descriptions.

Naming Consistency5/5

All tools share a consistent wikidata_ prefix followed by verb_noun style: get_entity, get_labels, get_sitelinks, get_statements, resolve_external_id, search_entities. Even sparql_query follows the predictable action-oriented pattern, so the set reads uniformly.

Tool Count5/5

Seven tools is well-scoped for a Wikidata knowledge-access server. Each tool earns its place, covering the primary retrieval methods without adding redundant or purely cosmetic variants.

Completeness5/5

For a read-only Wikidata MCP server, the surface is essentially complete: direct entity lookup, label humanization, sitelink mapping, statement fetching with qualifiers/references, external ID resolution, text search, and full SPARQL querying. There are no obvious dead ends for the domain it serves.