W
Wikidata MCP
community
search
Wikidata MCP server that interact with Wikidata, by searching identifiers, extracting metadata, and executing sparql query.
Wikidata MCP Server
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
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.
<details>
<summary><i>See the execution output</i></summary>
</details>{ "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 for a Wikidata entity ID by its query. |
| Search for a Wikidata property ID by its query. |
| Get the properties associated with a given Wikidata entity ID. |
| Execute a SPARQL query on Wikidata. |
| Retrieve the English label and description for a given Wikidata entity ID. |
License
MIT License
Related Servers
Aiven
official
Navigate your [Aiven projects](https://go.aiven.io/mcp-server) and interact with the PostgreSQL®, Apache Kafka®, ClickHouse® and OpenSearch® services
View DetailsApify
official
[Actors MCP Server](https://apify.com/apify/actors-mcp-server): Use 3,000+ pre-built cloud tools to extract data from websites, e-commerce, social media, search engines, maps, and more
View Details