
Connects Claude to Wikidata's 100+ million structured entities through seven tools and SPARQL access. You get entity search, full entity fetches with field filtering, batch label resolution for up to 50 QIDs at once, statement extraction with automatic label resolution, sitelink lookup across Wikipedia projects, and direct SPARQL queries against Blazegraph with auto-injected prefixes. The external ID resolver is built for cross-referencing: pass a DOI, PubMed ID, ORCID, or OpenAlex ID and get back the Wikidata QID. Runs locally via stdio or from a public HTTP endpoint. Reach for this when you need structured knowledge graph queries, fact verification against canonical data, or identifier mapping between research databases.
Search and fetch Wikidata entities, execute SPARQL queries, and resolve external identifiers via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://wikidata.caseyjhand.com/mcp
Wikidata's knowledge graph — entity search and lookup over the REST API v1, graph traversal via SPARQL against the Query Service, batch label resolution through MediaWiki, and external identifier resolution (DOI, PMID, ORCID, OpenAlex, IMDb). Search, fetch, and traverse entities from any MCP client. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
| Tool | Description |
|---|---|
wikidata_search_entities | Search for items or properties by text query, returning QIDs/PIDs with labels, descriptions, and match metadata |
wikidata_get_entity | Fetch a full entity by QID or PID with optional field and language filtering |
wikidata_get_labels | Batch-resolve up to 50 QIDs or PIDs to human-readable labels and descriptions |
wikidata_get_statements | Fetch property claims for an entity with qualifier detail and QID label resolution |
wikidata_get_sitelinks | Fetch Wikipedia and Wikimedia project article URLs for a Wikidata item |
wikidata_sparql_query | Execute a SPARQL SELECT query against the Wikidata Query Service |
wikidata_resolve_external_id | Look up a Wikidata entity by an external identifier (DOI, PubMed ID, ORCID, OpenAlex ID, etc.) |
| Resource | Description |
|---|---|
wikidata://entity/{id} | 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.
wikidata_search_entities tooltype="item" for real-world concepts (people, places, works); type="property" for predicate P-IDsen, de, pt-br; case-insensitive)wikidata_get_entity toolQ76) fetch items; P-IDs (e.g. P31) fetch properties — endpoint routing is automaticfields parameter selects labels, descriptions, aliases, statements, or sitelinksfields narrows the upstream fetch, not just the response — Q76 is 344,114 bytes whole, 6,703 for labels alonelanguages parameter filters multilingual maps to specific language codes, client-side (the entity endpoint takes no language parameter)retrieval_notice: it names a literal fields set 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 itwikidata_get_labels toolwbgetentities APIfound count and notFound IDs for partial-result handlingwikidata_get_statements toolproperties parameter fetches only specific P-IDs — omit to return all statementssomevalue / novalueresolve_labels=false for raw QIDs only (faster, smaller payload)properties naming P-IDs whose sizes sum to 24,000 or less (the retrieval_notice names one such set); labels are added after that check (unfiltered, Q30 carries 467 properties across 1,717 statements)wikidata_get_sitelinks toolenwiki) to article titles and URLssites parameter filters to specific site codeswikis_only=true returns only Wikipedia links (excludes Wiktionary, Wikiquote, Wikisource, etc.)wikidata_sparql_query toolwd:, wdt:, p:, ps:, pq:, wikibase:, bd:) are auto-injectedwikibase:label SERVICE auto-injected when the query uses a ?<var>Label, ?<var>Description, or ?<var>AltLabel variable and declares no label SERVICE of its ownlanguage takes one code or a comma-separated fallback list (fr,en); labels fall back to the multilingual (mul) label last{ type, value, "xml:lang"?, datatype? }; the rendered table quotes literals with their @lang or ^^datatype and shows URIs as prefixed names or <…>returnedCount, totalCount, and a notice to page with ORDER BY plus LIMIT/OFFSET or aggregate in the querytimeout parameter (1–55s) applies earlierwikidata_resolve_external_id toolhttps://doi.org/, https://pubmed.ncbi.nlm.nih.gov/, https://orcid.org/), DOIs uppercased, PMID prefixes stripped, ORCID hyphens normalizedexternal-id — item-valued or media properties (e.g. P31, P18) are rejected rather than returning an empty matchmatch=null when not found (the Query Service lags the live wiki, so a null is not proof of absence)language, falling back to the entity's multilingual (mul) labelmultipleMatches when a Wikidata data integrity issue causes more than one entity to claim the same external IDwikidata://entity/{id} resourceP31), enwiki Wikipedia link, image (P18), and statement counttext/markdown; for full entity data, use wikidata_get_entityid is a Q-ID or P-ID, the same identifiers the tools takeBuilt on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
Wikidata-specific:
wbgetentities API for efficient batch label resolutionUser-Agent per Wikimedia policy (WIKIDATA_USER_AGENT)WIKIDATA_REST_TIMEOUT_MS, WIKIDATA_SPARQL_TIMEOUT_MS)Agent-friendly output:
wikidata_get_labels designed to follow SPARQL result sets — run the query, then humanize in one callwikidata_resolve_external_id returns multipleMatches instead of a false null when a Wikidata data-integrity issue puts duplicate claims on one external IDkind: "outline" payload — field/property sizes plus a retrieval_notice naming the exact re-call — instead of a truncated or oversized responseA public instance is available at https://wikidata.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"wikidata-mcp-server": {
"type": "streamable-http",
"url": "https://wikidata.caseyjhand.com/mcp"
}
}
}
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/mcp
git clone https://github.com/cyanheads/wikidata-mcp-server.git
cd wikidata-mcp-server
bun install
cp .env.example .env
# edit .env and set any overrides
All configuration is validated at startup via Zod schemas. Key environment variables:
| Variable | Description | Default |
|---|---|---|
MCP_TRANSPORT_TYPE | Transport: stdio or http | stdio |
MCP_HTTP_PORT | HTTP server port | 3010 |
MCP_HTTP_ENDPOINT_PATH | HTTP endpoint path where the MCP server is mounted | /mcp |
MCP_PUBLIC_URL | Public origin override for TLS-terminating reverse-proxy deployments | none |
MCP_AUTH_MODE | Authentication: none, jwt, or oauth | none |
MCP_SESSION_MODE | HTTP session mode: stateful, stateless, or auto. The framework's auto default resolves to stateful; this server explicitly selects stateless. | stateless |
MCP_LOG_LEVEL | Log level (debug, info, notice, warning, error) | info |
MCP_GC_PRESSURE_INTERVAL_MS | Opt-in Bun-only forced-GC interval (ms). Try 60000 if heap growth is observed under HTTP load. | 0 (disabled) |
LOGS_DIR | Directory for log files (Node.js only) | <project-root>/logs |
STORAGE_PROVIDER_TYPE | Storage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1 | in-memory |
WIKIDATA_USER_AGENT | User-Agent string for Wikimedia requests (policy requires a descriptive value) | wikidata-mcp-server/0.1 (https://github.com/cyanheads/wikidata-mcp-server) |
WIKIDATA_SPARQL_TIMEOUT_MS | Max wait for a SPARQL response in ms | 55000 |
WIKIDATA_REST_TIMEOUT_MS | Max wait for REST API responses in ms | 10000 |
OTEL_ENABLED | Enable OpenTelemetry | false |
See .env.example for the full list of optional overrides.
Build and run the production version:
# One-time build
bun run rebuild
# Run the built server
bun run start:http
# or
bun run start:stdio
Run checks and tests:
bun run devcheck # Lints, formats, type-checks, and more
bun run test # Runs the test suite
docker build -t wikidata-mcp-server .
docker run --rm -p 3010:3010 wikidata-mcp-server
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/wikidata-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
| Directory | Purpose |
|---|---|
src/index.ts | createApp() entry point — registers tools and resources, inits services. |
src/mcp-server/tools | Tool definitions (*.tool.ts). Seven tools for entity lookup, statements, sitelinks, SPARQL, and external ID resolution. |
src/mcp-server/resources | Resource definitions. Entity summary resource. |
src/services/wikidata | Wikidata service layer — REST API client, SPARQL client, statement normalization, types. |
src/config | Server-specific environment variable parsing and validation with Zod. |
tests/ | Unit and integration tests, mirroring the src/ structure. |
See CLAUDE.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for logging, ctx.state for storagecreateApp() arraysIssues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
Apache-2.0 — see LICENSE for details.
WIKIDATA_USER_AGENTdefault: wikidata-mcp-server/0.1 (https://github.com/cyanheads/wikidata-mcp-server)User-Agent string for Wikimedia requests. Wikimedia policy requires a descriptive value.
WIKIDATA_SPARQL_TIMEOUT_MSdefault: 55000Max time to wait for a SPARQL response in milliseconds.
WIKIDATA_REST_TIMEOUT_MSdefault: 10000Max time to wait for REST API responses in milliseconds.
MCP_LOG_LEVELdefault: infoSets the minimum log level for output (e.g., 'debug', 'info', 'warn').
MCP_HTTP_HOSTdefault: 127.0.0.1The hostname for the HTTP server.
MCP_HTTP_PORTdefault: 3010The port to run the HTTP server on.
MCP_HTTP_ENDPOINT_PATHdefault: /mcpThe endpoint path for the MCP server.
MCP_AUTH_MODEdefault: noneAuthentication mode to use: 'none', 'jwt', or 'oauth'.