wikidata-mcp-server
Public Hosted Server: https://wikidata.caseyjhand.com/mcp
Tools
7 tools for working with Wikidata's knowledge graph:
Tool | Description |
| Search for items or properties by text query, returning QIDs/PIDs with labels, descriptions, and match metadata |
| Fetch a full entity by QID or PID with optional field and language filtering |
| Batch-resolve up to 50 QIDs or PIDs to human-readable labels and descriptions |
| Fetch property claims for an entity with qualifier detail and QID label resolution |
| Fetch Wikipedia and Wikimedia project article URLs for a Wikidata item |
| Execute a SPARQL SELECT query against the Wikidata Query Service |
| Look up a Wikidata entity by an external identifier (DOI, PubMed ID, ORCID, OpenAlex ID, etc.) |
wikidata_search_entities
Search Wikidata for items or properties by text query.
Searches labels, aliases, and descriptions
type="item"for real-world concepts (people, places, works);type="property"for predicate P-IDsLanguage-aware results (BCP 47 language codes)
Offset-based pagination, up to 50 results per call
Returns match metadata indicating whether the hit was on a label or alias
wikidata_get_entity
Fetch a Wikidata entity by QID or PID with field selection.
Q-IDs (e.g.
Q76) fetch items; P-IDs (e.g.P31) fetch properties — endpoint routing is automaticfieldsparameter selectslabels,descriptions,aliases,statements, orsitelinksfieldsnarrows the upstream fetch, not just the response — Q76 is 344,114 bytes whole, 6,703 forlabelsalonelanguagesparameter filters multilingual maps to specific language codes, client-side (the entity endpoint takes no language parameter)An entity too large to inline returns a field-category outline with byte sizes instead of the data — follow its
retrieval_notice: it names a literalfieldsset already measured to fit (category sizes are additive, so requesting every name listed would overflow again), defers the remainder to a further call, and redirects a category too large to deliver whole (statements or sitelinks on a major item) to the tool that can narrow it
wikidata_get_labels
Batch-resolve QIDs/PIDs to human-readable labels and descriptions.
Up to 50 IDs per call, batched via the MediaWiki
wbgetentitiesAPISupports multiple language codes per request
Reports
foundcount andnotFoundIDs for partial-result handlingDesigned for the common agent pattern: run a SPARQL query, then humanize the QID results
wikidata_get_statements
Fetch property claims for a Wikidata entity with full qualifier and reference detail.
propertiesparameter fetches only specific P-IDs — omit to return all statementsValue QIDs are resolved to human-readable labels by default via a batched label call
Set
resolve_labels=falsefor raw QIDs only (faster, smaller payload)A statement set too large to inline returns an outline of the available P-IDs with byte sizes, largest first, instead of the statements — re-call with
propertiesfor the ones you need (unfiltered, Q30 carries 467 properties across 1,717 statements)Preferred-rank statements represent the most current values
Designed for fact verification: "what does Wikidata say about this entity's {property}?"
wikidata_get_sitelinks
Fetch Wikipedia and Wikimedia project article URLs for a Wikidata item.
Maps site codes (e.g.,
enwiki) to article titles and URLssitesparameter filters to specific site codeswikis_only=truereturns only Wikipedia links (excludes Wiktionary, Wikiquote, Wikisource, etc.)Major items can have 300+ sitelinks across languages
Only Q-IDs (items) have sitelinks — P-IDs are not supported
wikidata_sparql_query
Execute a SPARQL SELECT query against the Wikidata Query Service (Blazegraph).
Full graph power: multi-hop traversals, aggregations, subqueries, OPTIONAL, FILTER, UNION, BIND
Standard Wikidata prefixes (
wd:,wdt:,p:,ps:,pq:,wikibase:,bd:) are auto-injectedwikibase:labelSERVICE auto-injected whenlanguageis set and the query uses?<var>LabelvariablesResults in SPARQL 1.1 JSON format: each binding is
{ type, value, "xml:lang"? }Hard server timeout is 60s; client-side
timeoutparameter (1–55s) applies earlierRate-limited at 60 requests/min and 5 concurrent requests per IP
wikidata_resolve_external_id
Look up a Wikidata entity by an external identifier.
Common use cases: CrossRef DOI → QID (P356), PubMed PMID → QID (P698), ORCID → author QID (P496), OpenAlex ID → entity QID (P10283), IMDb ID (P345)
Automatic value normalization: surrounding whitespace trimmed, resolver URL prefixes stripped (
https://doi.org/,https://pubmed.ncbi.nlm.nih.gov/,https://orcid.org/), DOIs uppercased, PMID prefixes stripped, ORCID hyphens normalizedThe property's data type must be
external-id— item-valued or media properties (e.g.P31,P18) are rejected rather than returning an empty matchReturns
match=nullwhen not found (the Query Service lags the live wiki, so a null is not proof of absence)Returns
multipleMatcheswhen a Wikidata data integrity issue causes more than one entity to claim the same external IDDesigned for cross-server joins with pubmed-mcp-server, crossref-mcp-server, and openalex-mcp-server
Resource
Type | Name | Description |
Resource |
| Compact markdown summary of a Wikidata entity — labels, English description, instance-of, Wikipedia link, image, and statement count |
All resource data is also reachable via tools.
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool definitions — single file per tool, framework handles registration and validation
Unified error handling across all tools
Pluggable auth (
none,jwt,oauth)Swappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1Structured logging with optional OpenTelemetry tracing
Runs locally (stdio/HTTP) from the same codebase
Wikidata-specific:
Wikidata REST API v1 for entity and statement fetches — no SPARQL overhead for lookup operations
MediaWiki
wbgetentitiesAPI for efficient batch label resolutionWikidata Query Service (Blazegraph) for SPARQL with auto-injected prefix headers and label SERVICE
Configurable
User-Agentper Wikimedia policySeparate timeout configuration for REST and SPARQL endpoints
Agent-friendly output:
wikidata_get_labelsdesigned to follow SPARQL result sets — run the query, then humanize in one callwikidata_resolve_external_idhandles DOI/PMID/ORCID normalization transparently, withmultipleMatchesfor data integrity edge caseswikidata_get_statementsresolves QID values to labels in the same call, withresolve_labels=falseescape hatch for raw payloadsAll tools echo input parameters in the response for traceability
Getting started
Self-Hosted / Local
Add the following to your MCP client configuration file.
{
"mcpServers": {
"wikidata-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/wikidata-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"wikidata-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/wikidata-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"wikidata-mcp-server": {
"type": "stdio",
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/wikidata-mcp-server:latest"]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcpPrerequisites
Bun v1.3.0 or higher (or Node.js ≥ 24.0.0).
Installation
Clone the repository:
git clone https://github.com/cyanheads/wikidata-mcp-server.gitNavigate into the directory:
cd wikidata-mcp-serverInstall dependencies:
bun installConfiguration
All configuration is validated at startup via Zod schemas. Key environment variables:
Variable | Description | Default |
| Transport: |
|
| HTTP server port |
|
| HTTP endpoint path where the MCP server is mounted |
|
| Public origin override for TLS-terminating reverse-proxy deployments | none |
| Authentication: |
|
| HTTP session mode: |
|
| Log level ( |
|
| Opt-in Bun-only forced-GC interval (ms). Try |
|
| Directory for log files (Node.js only) |
|
| Storage backend: |
|
| User-Agent string for Wikimedia requests (policy requires a descriptive value) |
|
| Max wait for a SPARQL response in ms |
|
| Max wait for REST API responses in ms |
|
| Enable OpenTelemetry |
|
Running the server
Local development
Build and run the production version:
# One-time build bun run rebuild # Run the built server bun run start:http # or bun run start:stdioRun checks and tests:
bun run devcheck # Lints, formats, type-checks, and more bun run test # Runs the test suite
Project structure
Directory | Purpose |
| Tool definitions ( |
| Resource definitions. Entity summary resource. |
| Wikidata service layer — REST API client, SPARQL client, statement normalization, types. |
| Server-specific environment variable parsing and validation with Zod. |
| Unit and integration tests, mirroring the |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor logging,ctx.statefor storageRegister new tools and resources in the
createApp()arrays
Contributing
Issues and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.