Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mcp-wikidata

MCP.Pizza Chef: zzaebok

The mcp-wikidata server implements the Wikidata API using the Model Context Protocol, allowing LLMs to search entity and property identifiers, extract metadata like labels and descriptions, and execute SPARQL queries. It facilitates real-time, structured access to Wikidata's vast knowledge base, enabling AI models to interact with and retrieve rich semantic data efficiently.

Use This MCP server To

Search Wikidata entities and properties by identifier Extract labels and descriptions from Wikidata entries Execute SPARQL queries on Wikidata knowledge graph Integrate Wikidata semantic data into AI workflows Provide real-time structured Wikidata context to LLMs Enable knowledge graph exploration via natural language Support data enrichment with Wikidata metadata Automate retrieval of linked open data from Wikidata

README

Wikidata MCP Server

smithery badge

A server implementation for Wikidata API using the Model Context Protocol (MCP). This project provides tools to interact with Wikidata, such as searching identifiers (entity and property), extracting metadata (label and description) and executing sparql query.


Installation

Installing via Smithery

To install Wikidata MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @zzaebok/mcp-wikidata --client claude

Installing Manually

Install uv if it is not installed yet.

$ curl -LsSf https://astral.sh/uv/install.sh | sh

Then, install dependencies.

$ git clone https://github.com/zzaebok/mcp-wikidata.git
$ cd mcp-wikidata
$ uv sync
# if you want to run client example together
$ uv sync --extra example

Run

Run the server with:

$ uv run src/server.py

If you want to test it with a simple client code (with langchain-mcp-adapters), run the client with:

# in another shell
$ uv run src/client.py

The LLM extracts valid entity and property identifiers, executes a sparql query, and finally recommend a movie directed by Bong Joon-ho.

See the execution output
{
  "messages": [
      HumanMessage(
          content="Can you recommend me a movie directed by Bong Joonho?",
      ),
      AIMessage(
          tool_calls=[
              {
                  "name": "search_entity",
                  "args": {"query": "Bong Joon-ho"},
              }
          ],
      ),
      ToolMessage(
          content="Q495980",
          name="search_entity",
      ),
      AIMessage(
          tool_calls=[
              {
                  "name": "get_properties",
                  "args": {"entity_id": "Q495980"},
              }
          ],
      ),
      ToolMessage(
          content='["P345", "P244", "P214", "P227", ...]',
          name="get_properties",
      ),
      AIMessage(
          tool_calls=[
              {
                  "name": "search_property",
                  "args": {"query": "director"},
              }
          ],
      ),
      ToolMessage(
          content="P57",
          name="search_property",
      ),
      AIMessage(
          tool_calls=[
              {
                  "name": "execute_sparql",
                  "args": {
                      "sparql_query": 'SELECT ?film ?filmLabel WHERE {\n  ?film wdt:P57 wd:Q495980.\n  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }\n} LIMIT 1'
                  },
              }
          ],
      ),
      ToolMessage(
          content='[{"film": {"type": "uri", "value": "http://www.wikidata.org/entity/Q483761"}, "filmLabel": {"xml:lang": "en", "type": "literal", "value": "Mother"}}]',
          name="execute_sparql",
      ),
      AIMessage(
          content='I recommend the movie "Mother," which was directed by Bong Joon-ho.',
      ),
  ]
}

Wikidata MCP Tools

The following tools are implemented in the server:

Tool Description
search_entity(query: str) Search for a Wikidata entity ID by its query.
search_property(query: str) Search for a Wikidata property ID by its query.
get_properties(entity_id: str) Get the properties associated with a given Wikidata entity ID.
execute_sparql(sparql_query: str) Execute a SPARQL query on Wikidata.
get_metadata(entity_id: str, language: str = "en") Retrieve the English label and description for a given Wikidata entity ID.

License

MIT License

mcp-wikidata FAQ

How do I install the mcp-wikidata server?
You can install it automatically via Smithery CLI or manually by cloning the repo, installing dependencies with uv, and syncing.
What functionality does mcp-wikidata provide?
It supports searching Wikidata identifiers, extracting metadata, and running SPARQL queries through MCP.
Can mcp-wikidata be used with different LLM providers?
Yes, it is provider-agnostic and works with OpenAI, Claude, Gemini, and others.
Is there an example client to test mcp-wikidata?
Yes, the repository includes example clients you can run alongside the server.
What is SPARQL and why is it supported?
SPARQL is a query language for RDF data; mcp-wikidata supports it to query Wikidata's knowledge graph precisely.
Does mcp-wikidata support real-time data updates?
It provides real-time access to Wikidata's API, reflecting up-to-date knowledge graph data.
What are the prerequisites for running mcp-wikidata?
You need to have uv installed and a compatible environment to run the server and dependencies.
How does mcp-wikidata enhance AI model capabilities?
It feeds structured, semantic Wikidata context into LLMs, enabling richer, knowledge-driven responses.