How zzaebok/mcp-wikidata works
Project Type and Purpose
• This is a Python-based microservice (a backend server) which implements the Model Context Protocol (MCP) to expose Wikidata search and query operations.
• It includes a minimal client example for demonstration.
File Structure
• Top‐level files and dirs:
• Dockerfile, pyproject.toml, smithery.yaml, uv.lock – packaging, dependency, and deployment config
• src/server.py – the MCP server entrypoint and tool-implementation module
• src/client.py – a sample client using the MCP server (via langchain-mcp-adapters)
• No separate “frontend” suggests a pure backend service, with an optional CLI/demo client.
README for Extra Insight
• Describes four core tools (search_entity, search_property, get_properties, execute_sparql, plus get_metadata)
• Shows an example call flow: HumanMessage → AIMessage (tool_call) → ToolMessage → … → AIMessage
• Mentions external SPARQL endpoint (Wikidata), and installation via Smithery or uv.
Main Components & Boundaries
• Client Layer (src/client.py): issues MCP requests over HTTP (or whichever transport uv exposes)
• Transport Layer (UV Runner): uv.Run serves as the process manager / HTTP server
• MCP Server Core (src/server.py):
• Request handler (parses incoming MCP messages)
• Tool executor (dispatches to the appropriate function)
• Tool Implementations:
• search_entity, search_property, get_properties, execute_sparql, get_metadata
• External Services:
• Wikidata HTTP API (Search endpoints)
• Wikidata SPARQL endpoint
• Ops & Packaging:
• Docker container (Dockerfile)
• Dependency config (pyproject.toml, smithery.yaml)
• Lockfile (uv.lock)
Relationships & Data Flows
• Client → MCP Server: sends LLM‐mediated tool_call messages
• MCP Server → Tool implementations (in-proc calls)
• Tool implementations → External Wikidata APIs (HTTP requests) → return JSON
• MCP Server → Client: returns ToolMessage or final AIMessage
• Optionally, external LLM service (via langchain adapters) orchestrates tool calls
Architectural Patterns
• Layered: Transport → Protocol handler → Business logic → External I/O
• Microservice: single responsibility – just Wikidata queries via MCP
• Plugin-style: each tool is a discrete function, making it extensible