{
  "markdown": "<div align=\"center\">\n  <h1>@cyanheads/wikidata-mcp-server</h1>\n  <p><b>Search and fetch Wikidata entities, execute SPARQL queries, and resolve external identifiers via MCP. STDIO or Streamable HTTP.</b>\n  <div>7 Tools • 1 Resource</div>\n  </p>\n</div>\n\n<div align=\"center\">\n\n[![Version](https://img.shields.io/badge/Version-0.1.18-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/wikidata-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^2.0.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/wikidata-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/wikidata-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^7.0.2-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0%2B-blueviolet.svg?style=flat-square)](https://bun.sh/)\n\n</div>\n\n<div align=\"center\">\n\n[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/wikidata-mcp-server/releases/latest/download/wikidata-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=wikidata-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvd2lraWRhdGEtbWNwLXNlcnZlciJdfQ==) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22wikidata-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fwikidata-mcp-server%22%5D%7D)\n\n[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)\n\n</div>\n\n<div align=\"center\">\n\n**Public Hosted Server:** [https://wikidata.caseyjhand.com/mcp](https://wikidata.caseyjhand.com/mcp)\n\n</div>\n\n---\n\n## Tools\n\n7 tools for working with Wikidata's knowledge graph:\n\n| Tool | Description |\n|:---|:---|\n| `wikidata_search_entities` | Search for items or properties by text query, returning QIDs/PIDs with labels, descriptions, and match metadata |\n| `wikidata_get_entity` | Fetch a full entity by QID or PID with optional field and language filtering |\n| `wikidata_get_labels` | Batch-resolve up to 50 QIDs or PIDs to human-readable labels and descriptions |\n| `wikidata_get_statements` | Fetch property claims for an entity with qualifier detail and QID label resolution |\n| `wikidata_get_sitelinks` | Fetch Wikipedia and Wikimedia project article URLs for a Wikidata item |\n| `wikidata_sparql_query` | Execute a SPARQL SELECT query against the Wikidata Query Service |\n| `wikidata_resolve_external_id` | Look up a Wikidata entity by an external identifier (DOI, PubMed ID, ORCID, OpenAlex ID, etc.) |\n\n### `wikidata_search_entities`\n\nSearch Wikidata for items or properties by text query.\n\n- Searches labels, aliases, and descriptions\n- `type=\"item\"` for real-world concepts (people, places, works); `type=\"property\"` for predicate P-IDs\n- Language-aware results (BCP 47 language codes)\n- Offset-based pagination, up to 50 results per call\n- Returns match metadata indicating whether the hit was on a label or alias\n\n---\n\n### `wikidata_get_entity`\n\nFetch a Wikidata entity by QID or PID with field selection.\n\n- Q-IDs (e.g. `Q76`) fetch items; P-IDs (e.g. `P31`) fetch properties — endpoint routing is automatic\n- `fields` parameter selects `labels`, `descriptions`, `aliases`, `statements`, or `sitelinks`\n- `fields` narrows the upstream fetch, not just the response — Q76 is 344,114 bytes whole, 6,703 for `labels` alone\n- `languages` parameter filters multilingual maps to specific language codes, client-side (the entity endpoint takes no language parameter)\n- 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 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 it\n\n---\n\n### `wikidata_get_labels`\n\nBatch-resolve QIDs/PIDs to human-readable labels and descriptions.\n\n- Up to 50 IDs per call, batched via the MediaWiki `wbgetentities` API\n- Supports multiple language codes per request\n- Reports `found` count and `notFound` IDs for partial-result handling\n- Designed for the common agent pattern: run a SPARQL query, then humanize the QID results\n\n---\n\n### `wikidata_get_statements`\n\nFetch property claims for a Wikidata entity with full qualifier and reference detail.\n\n- `properties` parameter fetches only specific P-IDs — omit to return all statements\n- Value QIDs are resolved to human-readable labels by default via a batched label call\n- Set `resolve_labels=false` for raw QIDs only (faster, smaller payload)\n- 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 `properties` for the ones you need (unfiltered, Q30 carries 467 properties across 1,717 statements)\n- Preferred-rank statements represent the most current values\n- Designed for fact verification: \"what does Wikidata say about this entity's {property}?\"\n\n---\n\n### `wikidata_get_sitelinks`\n\nFetch Wikipedia and Wikimedia project article URLs for a Wikidata item.\n\n- Maps site codes (e.g., `enwiki`) to article titles and URLs\n- `sites` parameter filters to specific site codes\n- `wikis_only=true` returns only Wikipedia links (excludes Wiktionary, Wikiquote, Wikisource, etc.)\n- Major items can have 300+ sitelinks across languages\n- Only Q-IDs (items) have sitelinks — P-IDs are not supported\n\n---\n\n### `wikidata_sparql_query`\n\nExecute a SPARQL SELECT query against the Wikidata Query Service (Blazegraph).\n\n- Full graph power: multi-hop traversals, aggregations, subqueries, OPTIONAL, FILTER, UNION, BIND\n- Standard Wikidata prefixes (`wd:`, `wdt:`, `p:`, `ps:`, `pq:`, `wikibase:`, `bd:`) are auto-injected\n- `wikibase:label` SERVICE auto-injected when `language` is set and the query uses `?<var>Label` variables\n- Results in SPARQL 1.1 JSON format: each binding is `{ type, value, \"xml:lang\"? }`\n- Hard server timeout is 60s; client-side `timeout` parameter (1–55s) applies earlier\n- Rate-limited at 60 requests/min and 5 concurrent requests per IP\n\n---\n\n### `wikidata_resolve_external_id`\n\nLook up a Wikidata entity by an external identifier.\n\n- Common use cases: CrossRef DOI → QID (P356), PubMed PMID → QID (P698), ORCID → author QID (P496), OpenAlex ID → entity QID (P10283), IMDb ID (P345)\n- 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 normalized\n- The property's data type must be `external-id` — item-valued or media properties (e.g. `P31`, `P18`) are rejected rather than returning an empty match\n- Returns `match=null` when not found (the Query Service lags the live wiki, so a null is not proof of absence)\n- Returns `multipleMatches` when a Wikidata data integrity issue causes more than one entity to claim the same external ID\n- Designed for cross-server joins with pubmed-mcp-server, crossref-mcp-server, and openalex-mcp-server\n\n## Resource\n\n| Type | Name | Description |\n|:---|:---|:---|\n| Resource | `wikidata://entity/{id}` | Compact markdown summary of a Wikidata entity — labels, English description, instance-of, Wikipedia link, image, and statement count |\n\nAll resource data is also reachable via tools.\n\n## Features\n\nBuilt on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):\n\n- Declarative tool definitions — single file per tool, framework handles registration and validation\n- Unified error handling across all tools\n- Pluggable auth (`none`, `jwt`, `oauth`)\n- Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`\n- Structured logging with optional OpenTelemetry tracing\n- Runs locally (stdio/HTTP) from the same codebase\n\nWikidata-specific:\n\n- Wikidata REST API v1 for entity and statement fetches — no SPARQL overhead for lookup operations\n- MediaWiki `wbgetentities` API for efficient batch label resolution\n- Wikidata Query Service (Blazegraph) for SPARQL with auto-injected prefix headers and label SERVICE\n- Configurable `User-Agent` per Wikimedia policy\n- Separate timeout configuration for REST and SPARQL endpoints\n\nAgent-friendly output:\n\n- `wikidata_get_labels` designed to follow SPARQL result sets — run the query, then humanize in one call\n- `wikidata_resolve_external_id` handles DOI/PMID/ORCID normalization transparently, with `multipleMatches` for data integrity edge cases\n- `wikidata_get_statements` resolves QID values to labels in the same call, with `resolve_labels=false` escape hatch for raw payloads\n- All tools echo input parameters in the response for traceability\n\n## Getting started\n\n### Self-Hosted / Local\n\nAdd the following to your MCP client configuration file.\n\n```json\n{\n  \"mcpServers\": {\n    \"wikidata-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"bunx\",\n      \"args\": [\"@cyanheads/wikidata-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\"\n      }\n    }\n  }\n}\n```\n\nOr with npx (no Bun required):\n\n```json\n{\n  \"mcpServers\": {\n    \"wikidata-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@cyanheads/wikidata-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\"\n      }\n    }\n  }\n}\n```\n\nOr with Docker:\n\n```json\n{\n  \"mcpServers\": {\n    \"wikidata-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"docker\",\n      \"args\": [\"run\", \"-i\", \"--rm\", \"-e\", \"MCP_TRANSPORT_TYPE=stdio\", \"ghcr.io/cyanheads/wikidata-mcp-server:latest\"]\n    }\n  }\n}\n```\n\nFor Streamable HTTP, set the transport and start the server:\n\n```sh\nMCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http\n# Server listens at http://localhost:3010/mcp\n```\n\n### Prerequisites\n\n- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js ≥ 24.0.0).\n\n### Installation\n\n1. **Clone the repository:**\n\n```sh\ngit clone https://github.com/cyanheads/wikidata-mcp-server.git\n```\n\n2. **Navigate into the directory:**\n\n```sh\ncd wikidata-mcp-server\n```\n\n3. **Install dependencies:**\n\n```sh\nbun install\n```\n\n## Configuration\n\nAll configuration is validated at startup via Zod schemas. Key environment variables:\n\n| Variable | Description | Default |\n|:---|:---|:---|\n| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http` | `stdio` |\n| `MCP_HTTP_PORT` | HTTP server port | `3010` |\n| `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path where the MCP server is mounted | `/mcp` |\n| `MCP_PUBLIC_URL` | Public origin override for TLS-terminating reverse-proxy deployments | none |\n| `MCP_AUTH_MODE` | Authentication: `none`, `jwt`, or `oauth` | `none` |\n| `MCP_SESSION_MODE` | HTTP session mode: `stateful`, `stateless`, or `auto`. The framework's `auto` default resolves to `stateful`; this server explicitly selects `stateless`. | `stateless` |\n| `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `notice`, `warning`, `error`) | `info` |\n| `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) |\n| `LOGS_DIR` | Directory for log files (Node.js only) | `<project-root>/logs` |\n| `STORAGE_PROVIDER_TYPE` | Storage backend: `in-memory`, `filesystem`, `supabase`, `cloudflare-kv/r2/d1` | `in-memory` |\n| `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)` |\n| `WIKIDATA_SPARQL_TIMEOUT_MS` | Max wait for a SPARQL response in ms | `55000` |\n| `WIKIDATA_REST_TIMEOUT_MS` | Max wait for REST API responses in ms | `10000` |\n| `OTEL_ENABLED` | Enable OpenTelemetry | `false` |\n\n## Running the server\n\n### Local development\n\n- **Build and run the production version**:\n\n  ```sh\n  # One-time build\n  bun run rebuild\n\n  # Run the built server\n  bun run start:http\n  # or\n  bun run start:stdio\n  ```\n\n- **Run checks and tests**:\n  ```sh\n  bun run devcheck  # Lints, formats, type-checks, and more\n  bun run test      # Runs the test suite\n  ```\n\n## Project structure\n\n| Directory | Purpose |\n|:---|:---|\n| `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). Seven tools for entity lookup, statements, sitelinks, SPARQL, and external ID resolution. |\n| `src/mcp-server/resources` | Resource definitions. Entity summary resource. |\n| `src/services/wikidata` | Wikidata service layer — REST API client, SPARQL client, statement normalization, types. |\n| `src/config` | Server-specific environment variable parsing and validation with Zod. |\n| `tests/` | Unit and integration tests, mirroring the `src/` structure. |\n\n## Development guide\n\nSee [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:\n\n- Handlers throw, framework catches — no `try/catch` in tool logic\n- Use `ctx.log` for logging, `ctx.state` for storage\n- Register new tools and resources in the `createApp()` arrays\n\n## Contributing\n\nIssues and pull requests are welcome. Run checks and tests before submitting:\n\n```sh\nbun run devcheck\nbun run test\n```\n\n## License\n\nApache-2.0 — see [LICENSE](./LICENSE) for details.\n",
  "bytes": 14006,
  "sha": "a75c76d611f87e2665d0ecb4d9387ab1a1187a70770f1f16796950dc2615c77d",
  "repo_slug": "cyanheads/wikidata-mcp-server",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_cyanheads_wikidata_mcp_server_3d51b9fc/readme"
}