wikidata-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@wikidata-mcp-serverSearch for entities named 'Taj Mahal'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Public Hosted Server: https://wikidata.caseyjhand.com/mcp
Overview
Wikidata's knowledge graph. Search and fetch entities, traverse the graph with SPARQL, and resolve external identifiers like DOI, PMID, ORCID, OpenAlex, and IMDb to their Wikidata items. No API key required.
Tools
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.) |
Resources
Resource | Description |
| 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.
Related MCP server: MediaWiki MCP adapter
Capability reference
wikidata_search_entities tool
Searches labels, aliases, and descriptions;
type="item"for people, places, and works,type="property"for P-IDsTakes a Wikidata language code (
en,de,pt-br; case-insensitive); offset pagination, up to 50 results per callEach hit includes match metadata saying whether it matched a label or alias
wikidata_get_entity tool
Q-IDs (e.g.
Q76) fetch items and P-IDs (e.g.P31) fetch properties;fieldsselectslabels,descriptions,aliases,statements, orsitelinks, and narrows the upstream fetch (Q76 is 344,114 bytes whole, 6,703 forlabelsalone)languagesfilters multilingual maps to the given language codesAn entity too large to inline returns an outline of field categories with byte sizes; its
retrieval_noticenames afieldsset that fits and points oversized statements or sitelinks to the tool that can narrow them
wikidata_get_labels tool
Up to 50 IDs per call via the MediaWiki
wbgetentitiesAPI, with one or more language codes per requestReports a
foundcount andnotFoundIDs for partial resultsMeant to follow a SPARQL query: run it, then humanize the QIDs
wikidata_get_statements tool
propertieslimits the fetch to specific P-IDs (omit for all); item QIDs and quantity units in values, qualifiers, and references are resolved to labels unlessresolve_labels=falseReferences stay grouped by source; unknown or absent values come back as
somevalue/novalueA statement set too large to inline returns an outline of P-IDs with byte sizes, largest first (unfiltered, Q30 carries 467 properties across 1,717 statements); re-call with
propertieswhose sizes sum to 24,000 or less, as theretrieval_noticesuggests
wikidata_get_sitelinks tool
Maps site codes (e.g.
enwiki) to article titles and URLs;sitesfilters to specific codeswikis_only=truekeeps only Wikipedia links (drops Wiktionary, Wikiquote, Wikisource, etc.)Q-IDs only; P-IDs are not supported
wikidata_sparql_query tool
Runs SELECT queries against the Wikidata Query Service (Blazegraph); ASK, CONSTRUCT, DESCRIBE, updates, and plain search text are rejected before the request is sent
Standard prefixes (
wd:,wdt:,p:,ps:,pq:,wikibase:,bd:) and thewikibase:labelSERVICE (when the query uses a?<var>Label,?<var>Description, or?<var>AltLabelvariable) are added automatically;languagetakes one code or a fallback list likefr,enResults are SPARQL 1.1 JSON bindings, capped at 64,000 bytes per response and cut between whole rows; a larger result returns its leading rows with
returnedCount,totalCount, and a notice to page withORDER BYplusLIMIT/OFFSETor to aggregateClient
timeoutis 1–55s (server hard limit 60s); rate limit is 60 requests/min and 5 concurrent requests per IP
wikidata_resolve_external_id tool
Resolves DOI (P356), PMID (P698), ORCID (P496), OpenAlex ID (P10283), IMDb ID (P345), and other external IDs to a QID; whitespace and resolver URL prefixes are stripped, and DOIs, PMIDs, and ORCIDs are normalized
The property must have data type
external-id; item-valued or media properties (e.g.P31,P18) are rejectedReturns
match=nullwhen not found (the Query Service lags the live wiki, so null is not proof of absence) andmultipleMatcheswhen more than one entity claims the same ID; the label uses the requestedlanguage, falling back tomul
wikidata://entity/{id} resource
Compact markdown summary — labels (all languages), English description, instance-of (
P31), enwiki Wikipedia link, image (P18), and statement countReturned as
text/markdown; for full entity data, usewikidata_get_entityidis a Q-ID or P-ID, the same identifiers the tools take
Features
Built 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:
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 policy (WIKIDATA_USER_AGENT)Separate timeout configuration for REST and SPARQL endpoints (
WIKIDATA_REST_TIMEOUT_MS,WIKIDATA_SPARQL_TIMEOUT_MS)
Agent-friendly output:
All tools echo relevant input parameters in the response for traceability
wikidata_get_labelsdesigned to follow SPARQL result sets — run the query, then humanize in one callwikidata_resolve_external_idreturnsmultipleMatchesinstead of a false null when a Wikidata data-integrity issue puts duplicate claims on one external IDOversized entities and statement sets return a
kind: "outline"payload — field/property sizes plus aretrieval_noticenaming the exact re-call — instead of a truncated or oversized response
Getting started
Public Hosted Instance
A 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"
}
}
}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.4.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 installConfigure environment:
cp .env.example .env
# edit .env and set any overridesConfiguration
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 forced-GC interval in ms (Bun only) |
|
| 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 |
|
See .env.example for the full list of optional overrides.
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
Docker
docker build -t wikidata-mcp-server .
docker run --rm -p 3010:3010 wikidata-mcp-serverThe 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.
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()arraysWrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Machine-readable entity discovery with provenance, trust and verified source evidence.
Read-only Wikidata tools and identity evidence. Local optional Google KG; bounded public remote.
Model Context Protocol server for Studex tools, notifications, and profile integrations
Live Wikipedia edit feed, page summaries, trending pages, and Wikidata search.
Related MCP Servers
- AlicenseAqualityDmaintenanceA server implementation for interacting with Wikidata API using the Model Context Protocol, providing tools for searching identifiers, extracting metadata, and executing SPARQL queries.549MIT
- AlicenseNot gradedqualityDmaintenanceA custom Model Context Protocol adapter for MediaWiki and WikiBase APIs6GPL 3.0
- AlicenseBqualityDmaintenanceProvides access to Wikidata for Large Language Models through the Model Context Protocol, offering tools for entity search, detailed retrieval, SPARQL queries, relation exploration, and property-based searches.54MIT
- FlicenseBqualityDmaintenanceEnables querying the DuckDuckGo Instant Answer API through the Model Context Protocol, allowing users to perform searches and retrieve instant answers.19-