Wikidata:MCP
The Wikidata MCP provides a set of standardized tools that allow large language models (LLMs) to explore and query Wikidata programmatically. It is designed for agentic AI or AI workflows that need to search, inspect, and query Wikidata, without relying on hardcoded assumptions about its structure or content.
The Wikidata Query Service requires an understanding of SPARQL’s syntax and Wikidata’s data model. While many LLMs can generate syntactically valid SPARQL queries, they lack an understanding of Wikidata’s schema and the relationships between items within a specific domain. The Wikidata MCP connects LLMs to the Wikidata API and Wikidata Query Service to assist users in their research.
Model Context Protocol (MCP)
[edit]Model Context Protocol (MCP), often described as "USB-C for AI", is an open standard, open-source framework introduced by Anthropic to standardize the way large language models (LLMs) interact with external tools, systems, and data sources.
How to set up
[edit]- For hosted chat interfaces (no MCP config exposed), use a client/platform that supports custom MCP server configuration, then connect to:
- For MCP-configurable clients (custom server setup), add this server configuration:
{ "mcpServers": { "wikidata": { "type": "streamable_http", "url": "https://wd-mcp.wmcloud.org/mcp/" } } }
Tools
[edit]Tools are exposed as API endpoints and can be tested interactively at wd-mcp.wmcloud.org/docs.
| Tool | Function | What it does | Typical use |
|---|---|---|---|
| Search Items | search_items(
query,
lang="en",
)
|
Hybrid search combining keyword-based and vector-based search over Wikidata items (QIDs). | Use first to discover candidate items from natural-language queries. |
| Search Properties | search_properties(
query,
lang="en",
include_external_ids=False,
)
|
Hybrid search combining keyword-based and vector-based search over Wikidata properties (PIDs). External-identifier properties are excluded by default. | Use first to identify relevant properties from natural-language queries. |
| Get Statements | get_statements(
entity_id,
include_external_ids=False,
lang="en",
)
|
Lists all direct graph connections (statements) of a Wikidata entity in triplet format and their values. This tool excludes qualifiers, deprecated values, and references. | Use to verify direct relationships and get a fast structural overview. |
| Get Statement Values | get_statement_values(
entity_id,
property_id,
lang="en",
)
|
Returns full statement details for an entity-property pair, including qualifiers, deprecated values, and references. | Use when detailed claim context matters (qualifiers, references, deprecated values). |
| Get Instance and Subclass Hierarchy | get_instance_and_subclass_hierarchy(
entity_id,
max_depth=5,
lang="en",
)
|
Traverses an entity’s classification context through P31 (instance of) and P279 (subclass of) to show its type hierarchy up to a chosen depth. | Use to validate class/ontology context before building filters. |
| Execute SPARQL | execute_sparql(
sparql,
K=10,
)
|
Runs a SPARQL query on Wikidata and returns up to K rows or error messages.
|
Use after confirming entities/properties and relationships with the other tools. |
Differences in the Wikibase MCP
[edit]The Wikibase MCP provides similar tools for any registered Wikibase instance, but differs from the Wikidata MCP in the following ways:
| Feature | Difference |
|---|---|
| Wikibase context | Each endpoint connects to a specific registered Wikibase. The additional get_wikibase_info() tool identifies the current instance.
|
| Search | Item and property search uses the Wikibase Action API with a CirrusSearch fuzzy fallback, rather than Wikidata’s hybrid keyword and vector search. |
| Entity identifiers | QIDs and PIDs are specific to each Wikibase and must be discovered instead of assumed to match Wikidata. |
| Hierarchy | get_property_hierarchy(entity_id, property_id, max_depth=5, lang="en") can traverse any selected property, rather than being limited to P31 and P279.
|
| SPARQL | Queries run against the registered Wikibase’s own Query Service instead of the Wikidata Query Service. |
Agentic workflow
[edit]Python implementation using LangChain
[edit]Code as of July 2026 by Phillipe Saadé
OpenCode Wikidata SPARQL workflow plugin
[edit]This plugin provides an agentic workflow for OpenCode (Q140646955) that answers questions like "who are the presidents of france" based on SPARQL = no hallucination. This enables the 7.5M developers currently using the software to easily use Wikidata. See https://github.com/dpriskorn/opencode-wikidata-sparql-workflow
Wikibase MCP
[edit]For Wikibases other than Wikidata, use the Wikibase MCP at wb-mcp.wmcloud.org.
You can register your Wikibase there to get a dedicated MCP endpoint for your instance, then connect your MCP client to that endpoint.
Links
[edit]- Interactive Tool Testing Ground
- Wikidata MCP GitHub repository
- Wikibase MCP (other than Wikidata)
- Wikibase MCP GitHub repository
Presentations & blog posts
[edit]- "Wikidata MCP: Exploring Wikidata with AI" - presentation by Philippe Saadé of Wikimedia Deutschland at WikidataCon 2025, Nov 2, 2025 (slides, Etherpad Notes)
- "Fact-Checking with Wikidata" - workshop by Philippe Saadé of Wikimedia Deutschland and DataTalks.Club, Jan 20, 2026
- "Wikidata MCP: Grounded SPARQL Query Generation" - presentation by Philippe Saadé of Wikimedia Deutschland at Wikimania 2026, Jul 22, 2026
Updates
[edit]- August 2026
- [Both MCPs] Added language fallback when the requested Wikidata/Wikibase language is unavailable.
- [Wikibase MCP] Added a fuzzy search fallback that uses CirrusSearch to provide entities when the standard search returns too few results.
- July 2026
- [Wikidata MCP] Added a parameter to exclude external-ID properties from property search.
- June 2026
- [Both MCPs] Improve error handling with clear return messages that guide LLMs on what to try next.
- [Both MCPs] Refine tool instructions to guide discovery and validation before SPARQL.
- May 2026
- Released the Wikibase MCP at wb-mcp.wmcloud.org
- February 2026
- Added a tool testing environment at wd-mcp.wmcloud.org/docs
- Improvements to WikidataTextifier
- Migrated label caching from SQLite to MySQL
- Migrated the service from Toolforge to WMCloud
- Textifier now supports all 300+ languages available on Wikidata
- Fixed bugs
- Accept both /mcp and /mcp/ as endpoints
- Improve tool names and descriptions for clarity and avoid SPARQL execution before exploration
- January 2026
- Merged keyword and vector searches into a single tool
- The search now supports hybrid search combining keyword and vector search results
- Falls back to keyword search when vector search is unavailable
- Merged keyword and vector searches into a single tool
- December 2025
- Fixed bugs in statement retrieval and SPARQL execution
- November 2025
- Added the get_instance_and_subclass_hierarchy tool
- October 2025
- Release of the Wikidata MCP at [1]