The Wikibase MCP (Model Context Protocol) provides standardized tools that allow large language models (LLMs) to explore and query a registered Wikibase programmatically. It is designed for agentic AI and AI workflows that need to search, inspect, and query a Wikibase without relying on hardcoded assumptions about its structure, identifiers, or content.
The Wikibase MCP service is available at https://wb-mcp.wmcloud.org/. Register a Wikibase there to receive an instance-specific MCP endpoint. The registration API can be explored at https://wb-mcp.wmcloud.org/docs.
For Wikidata, use the dedicated Wikidata MCP instead. Its MCP endpoint is https://wd-mcp.wmcloud.org/mcp.
Open wb-mcp.wmcloud.org and provide:
- a name and optional description;
- its MediaWiki Action API endpoint, such as
https://example.org/w/api.php; - its Wikibase Query Service endpoint, such as
https://query.example.org/sparql.
The service returns a stable mcp_endpoint slug. For a returned value of
example-wikibase, use:
- MCP:
https://wb-mcp.wmcloud.org/example-wikibase/mcp/ - Interactive tool API:
https://wb-mcp.wmcloud.org/example-wikibase/docs
You can also register through the API:
curl -X POST https://wb-mcp.wmcloud.org/wikibases \
-H 'Content-Type: application/json' \
-d '{
"name": "Example Wikibase",
"description": "An example structured knowledge base.",
"action_api_endpoint": "https://example.org/w/api.php",
"query_service_endpoint": "https://query.example.org/sparql"
}'-
get_wikibase_info() -> strReturns the registered Wikibase name and description.Use When: Starting work with an instance, to confirm its context.
-
search_items(query: str, lang: str = "en") -> strSearches Wikibase items (QIDs) using its Action API. Returns matching QIDs with labels and descriptions.Use When: Starting exploration from a concept or natural-language description.
-
search_properties(query: str, lang: str = "en") -> strSearches Wikibase properties (PIDs) using its Action API. Returns matching PIDs with labels and descriptions.Use When: Finding the property that represents a relationship for a statement or SPARQL query.
-
get_statements(entity_id: str, include_external_ids: bool = False, lang: str = "en") -> strReturns direct statements for an entity in triplet-like text form. It excludes qualifiers, references, and deprecated values.Use When: Getting a fast structural overview of an entity.
-
get_statement_values(entity_id: str, property_id: str, lang: str = "en") -> strReturns all statement values for an entity-property pair, including qualifiers, references, and all ranks.Use When: Full statement detail is needed for auditing, fact-checking, or provenance-sensitive tasks.
-
get_property_hierarchy(entity_id: str, property_id: str, max_depth: int = 5, lang: str = "en") -> strRetrieves a JSON-formatted hierarchy by traversing a specified Wikibase property.Use When: Validating a relationship path before using it in SPARQL.
-
execute_sparql(sparql: str, K: int = 10) -> strExecutes a SPARQL query against the registered Wikibase Query Service and returns up toKrows as CSV text.Use When: Structured retrieval and verification are needed.
Set the database environment variables in .env, then run:
uv run python main.pyThen open:
http://localhost:8000/to register and manage Wikibases;http://localhost:8000/docsfor the registration API;http://localhost:8000/<mcp_endpoint>/docsto test an instance's tools;http://localhost:8000/<mcp_endpoint>/mcp/to connect an MCP client.
With Docker:
docker compose up --buildEach registration supplies the Wikibase Action API and Query Service that its tools use. Statement and hierarchy responses are rendered through the configurable Textifier service, which defaults to wd-textify.wmcloud.org.