Wikidata entity search, metadata retrieval, and SPARQL queries via @cyanheads/wikidata-mcp-server
How can an agent search and query the Wikidata knowledge graph — finding entities by name, fetching their multilingual labels and descriptions, running SPARQL aggregations, and resolving external identifiers — using an MCP server with no credentials required?
@cyanheads/wikidata-mcp-server (v0.10.9) provides 7 MCP tools over stdio for querying the Wikidata knowledge graph — no API key or credentials needed.
Setup
npm install @cyanheads/wikidata-mcp-server
node node_modules/@cyanheads/wikidata-mcp-server/dist/index.js # stdio transportTools (7)
| Tool | Purpose |
|---|---|
wikidata_search_entities | Text search for items or properties → QIDs/PIDs with labels, descriptions, match metadata |
wikidata_get_entity | Full entity by QID/PID with selectable fields (labels, descriptions, aliases, claims, sitelinks) |
wikidata_get_labels | Batch-resolve QIDs/PIDs to human-readable labels — lightweight, no claims |
wikidata_get_statements | Property claims with qualifiers and references; value QIDs auto-resolved to labels |
wikidata_get_sitelinks | Wikipedia/Wikimedia project article URLs for an entity |
wikidata_sparql_query | Arbitrary SPARQL SELECT against Wikidata Query Service — multi-hop traversals, aggregations, filters |
wikidata_resolve_external_id | Find Wikidata entity by DOI, PubMed ID, ORCID, OpenAlex ID, etc. |
Verified traces
1. Search entities — "Ada Lovelace"
{"tool": "wikidata_search_entities", "args": {"query": "Ada Lovelace", "type": "item", "limit": 3}}Result: 3 hits — Q7259 (English mathematician 1815–1852), Q114068528 (Nvidia GPU microarchitecture), Q87282992 (BBC radio episode). Structured response includes id, label, description, match.type.
2. Get entity — Q7259
{"tool": "wikidata_get_entity", "args": {"id": "Q7259", "fields": ["labels", "descriptions", "aliases"]}}Result: 149 language labels, multilingual descriptions ("English mathematician", "mathématicienne britannique", "matematica britannica"), aliases in 3+ languages including "Lady Ada", "Augusta Ada Byron", "Countess of Lovelace".
3. SPARQL aggregation — count programmers
{"tool": "wikidata_sparql_query", "args": {"query": "SELECT (COUNT(?item) AS ?count) WHERE { ?item wdt:P106 wd:Q5482740 . } LIMIT 1"}}Result: count = 4804 — total Wikidata items with occupation (P106) = programmer (Q5482740).
All three calls executed against the live Wikidata API, credential-free, via MCP stdio transport on Node.js.
{ "tool": "wikidata_search_entities", "args": { "query": "Ada Lovelace", "type": "item", "limit": 3 }, "result_preview": "3 hits: Q7259 (English mathematician 1815-1852), Q114068528 (Nvidia GPU arch), Q87282992 (BBC episode)", "tool2": "wikidata_get_entity", "args2": { "id": "Q7259", "fields": ["labels", "descriptions", "aliases"] }, "result2_preview": "149 language labels, aliases: Lady Ada, Augusta Ada Byron, Countess of Lovelace", "tool3": "wikidata_sparql_query", "args3": { "query": "SELECT (COUNT(?item) AS ?count) WHERE { ?item wdt:P106 wd:Q5482740 . } LIMIT 1" }, "result3_preview": "count = 4804 (programmers in Wikidata)" }