@cyanheads/wikidata-mcp-server

v0.1.8 pre-1.0

Search and fetch Wikidata entities, execute SPARQL queries, and resolve external identifiers via MCP. STDIO or Streamable HTTP.

@cyanheads/wikidata-mcp-server
claude mcp add --transport http wikidata-mcp-server https://wikidata.caseyjhand.com/mcp
codex mcp add wikidata-mcp-server --url https://wikidata.caseyjhand.com/mcp
{
  "mcpServers": {
    "wikidata-mcp-server": {
      "url": "https://wikidata.caseyjhand.com/mcp"
    }
  }
}
gemini mcp add --transport http wikidata-mcp-server https://wikidata.caseyjhand.com/mcp
{
  "mcpServers": {
    "wikidata-mcp-server": {
      "command": "bunx",
      "args": [
        "@cyanheads/wikidata-mcp-server@latest"
      ]
    }
  }
}
{
  "mcpServers": {
    "wikidata-mcp-server": {
      "type": "http",
      "url": "https://wikidata.caseyjhand.com/mcp"
    }
  }
}
curl -X POST https://wikidata.caseyjhand.com/mcp \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl","version":"1.0.0"}}}'

Tools

7

wikidata_search_entities

open-world

Search Wikidata for items or properties by text query. Returns QIDs or PIDs with labels, descriptions, and match metadata indicating whether the hit was on a label or alias. Use type="item" for real-world concepts (people, places, works) and type="property" to find predicate P-IDs. The API returns no total count — pagination is offset-based with no result ceiling indicator.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "wikidata_search_entities",
    "arguments": {
      "query": "<query>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "description": "Search terms to match against entity labels, aliases, and descriptions."
    },
    "type": {
      "default": "item",
      "description": "Entity type to search. Use \"item\" for Q-IDs (people, places, concepts) or \"property\" for P-IDs (predicates).",
      "type": "string",
      "enum": [
        "item",
        "property"
      ]
    },
    "language": {
      "default": "en",
      "description": "BCP 47 language code for returned labels and descriptions (e.g., \"en\", \"de\", \"zh\").",
      "type": "string"
    },
    "limit": {
      "default": 10,
      "description": "Maximum number of results to return. Range: 1–50.",
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    },
    "offset": {
      "default": 0,
      "description": "Pagination offset. Start at 0; increment by limit to page through results.",
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "query",
    "type",
    "language",
    "limit",
    "offset"
  ],
  "additionalProperties": false
}
view source ↗

wikidata_get_entity

open-world

Fetch a Wikidata entity (item or property) by QID or PID. Use the fields parameter to trim what is returned to the caller — major items can be large. Omit fields to get all data. Q-IDs (e.g. Q76) fetch items; P-IDs (e.g. P31) fetch properties from the correct endpoint automatically. Use wikidata_get_statements for deep claim traversal with label resolution.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "wikidata_get_entity",
    "arguments": {
      "id": "<id>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "Q-ID (e.g., \"Q76\") or P-ID (e.g., \"P31\"). Case-insensitive — normalized to uppercase."
    },
    "fields": {
      "description": "Fields to include in the response. Options: \"labels\", \"descriptions\", \"aliases\", \"statements\", \"sitelinks\". Omit for all fields.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "labels",
          "descriptions",
          "aliases",
          "statements",
          "sitelinks"
        ]
      }
    },
    "languages": {
      "description": "Language codes to include in labels, descriptions, and aliases (e.g., [\"en\", \"de\"]). Omit to return all available languages.",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "id"
  ],
  "additionalProperties": false
}
view source ↗

wikidata_get_labels

Resolve one or more QIDs or PIDs to their human-readable labels and descriptions. Lightweight — returns no claim data. Supports up to 50 IDs per call (batched automatically). Designed for the common agent pattern: receive QIDs from a SPARQL query, then humanize them.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "wikidata_get_labels",
    "arguments": {
      "ids": "<ids>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ids": {
      "minItems": 1,
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "Q-IDs (e.g., \"Q76\") or P-IDs (e.g., \"P31\") to resolve. 1–50 IDs per call."
    },
    "languages": {
      "default": [
        "en"
      ],
      "description": "BCP 47 language codes for returned labels and descriptions (e.g., [\"en\", \"de\", \"fr\"]).",
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "required": [
    "ids",
    "languages"
  ],
  "additionalProperties": false
}
view source ↗

wikidata_get_statements

open-world

Fetch property claims for a Wikidata entity with qualifier and reference detail. Value QIDs are resolved to human-readable labels by default. Use the properties parameter to fetch only specific P-IDs — omitting it returns all statements, which can be large. Designed for fact verification: "what does Wikidata say about this entity's {property}?". Preferred-rank statements are the most current values.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "wikidata_get_statements",
    "arguments": {
      "id": "<id>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "Q-ID (e.g., \"Q76\") or P-ID of the entity to fetch statements for."
    },
    "properties": {
      "description": "P-IDs to fetch (e.g., [\"P31\", \"P569\", \"P27\"]). Omit to return all properties (may be large for major items).",
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "language": {
      "default": "en",
      "description": "Language code for label resolution of QID values (e.g., \"en\", \"de\").",
      "type": "string"
    },
    "resolve_labels": {
      "default": true,
      "description": "Resolve wikibase-item value QIDs to human-readable labels via a batched label call. Set to false to skip label resolution and return raw QIDs only (faster, smaller payload).",
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "language",
    "resolve_labels"
  ],
  "additionalProperties": false
}
view source ↗

wikidata_sparql_query

open-world

Execute a SPARQL SELECT query against the Wikidata Query Service. Full graph power: multi-hop traversals, aggregations, subqueries, OPTIONAL, FILTER, UNION, BIND. Standard Wikidata prefixes (wd:, wdt:, p:, ps:, pq:, wikibase:, bd:) are auto-injected. The wikibase:label SERVICE is also auto-injected when language is set and the query includes ?<var>Label variables — so you can use ?itemLabel without writing the boilerplate. Hard server timeout is 60s; use LIMIT to keep queries fast. Bindings use the SPARQL 1.1 JSON format: each value is { type, value, "xml:lang"? }. Use wikidata_get_labels to humanize QID results from this tool.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "wikidata_sparql_query",
    "arguments": {
      "query": "<query>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "description": "SPARQL SELECT query. Must be a SELECT query (not CONSTRUCT/DESCRIBE/ASK). Standard prefixes (wd:, wdt:, p:, ps:, pq:, wikibase:, bd:) are injected automatically. Example: SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146. } LIMIT 10"
    },
    "language": {
      "default": "en",
      "description": "Language for the wikibase:label SERVICE (e.g., \"en\", \"de\"). Controls the language of ?<var>Label variables. Set to \"\" to suppress label SERVICE injection.",
      "type": "string"
    },
    "timeout": {
      "default": 30,
      "description": "Client-side timeout in seconds (1–55). Capped at 55s — the Wikidata server hard limit is 60s.",
      "type": "integer",
      "minimum": 1,
      "maximum": 55
    }
  },
  "required": [
    "query",
    "language",
    "timeout"
  ],
  "additionalProperties": false
}
view source ↗

wikidata_resolve_external_id

open-world

Look up a Wikidata entity by an external identifier such as a DOI, PubMed ID, ORCID iD, or OpenAlex ID. Returns match=<entity> on success, match=null when not found, and match=null with multipleMatches populated when a Wikidata data integrity issue causes more than one entity to claim the same external ID. Common cross-server join use cases: CrossRef DOI → Wikidata paper QID (P356), PubMed PMID → Wikidata paper QID (P698), ORCID → author QID (P496), OpenAlex ID → entity QID (P10283). Known value normalization is applied automatically: DOIs are uppercased, PMID prefixes stripped, ORCID hyphens normalized.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "wikidata_resolve_external_id",
    "arguments": {
      "property": "<property>",
      "value": "<value>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "property": {
      "type": "string",
      "minLength": 1,
      "description": "P-ID of the external identifier property (e.g., \"P356\" for DOI, \"P698\" for PubMed ID, \"P496\" for ORCID, \"P10283\" for OpenAlex ID, \"P345\" for IMDb ID)."
    },
    "value": {
      "type": "string",
      "minLength": 1,
      "description": "The external identifier value to look up (e.g., \"10.1038/nature01234\" for a DOI, \"32283226\" for a PubMed ID, \"0000-0002-1825-0097\" for an ORCID)."
    },
    "language": {
      "default": "en",
      "description": "Language code for label and description in the response (e.g., \"en\", \"de\").",
      "type": "string"
    }
  },
  "required": [
    "property",
    "value",
    "language"
  ],
  "additionalProperties": false
}
view source ↗

Resources

1

Wikidata entity by QID or PID — labels (all languages), English description, and a summary of key properties (instance-of P31, image P18, enwiki sitelink). Formatted as compact markdown. For full entity data, use the wikidata_get_entity tool.

uri wikidata://entity/{id} mime text/markdown