Skip to main content
Glama
zzaebok

Wikidata MCP Server

by zzaebok

维基数据 MCP 服务器

铁匠徽章

使用模型上下文协议 (MCP) 实现 Wikidata API 的服务器端。该项目提供与 Wikidata 交互的工具,例如搜索标识符(实体和属性)、提取元数据(标签和描述)以及执行 sparql 查询


安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Wikidata MCP 服务器:

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

手动安装

如果尚未安装uv ,请安装。

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

然后,安装依赖项。

$ 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

跑步

使用以下命令运行服务器:

$ uv run src/server.py

如果您想使用简单的客户端代码(使用langchain-mcp-adapters )进行测试,请使用以下命令运行客户端:

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

LLM 提取有效的实体和属性标识符,执行 sparql 查询,最后推荐一部由奉俊昊执导的电影。

{
  "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 工具

服务器中实现了以下工具:

工具

描述

search_entity(query: str)

通过查询来搜索 Wikidata 实体 ID。

search_property(query: str)

通过查询来搜索 Wikidata 属性 ID。

get_properties(entity_id: str)

获取与给定 Wikidata 实体 ID 关联的属性。

execute_sparql(sparql_query: str)

在 Wikidata 上执行 SPARQL 查询。

get_metadata(entity_id: str, language: str = "en")

检索给定 Wikidata 实体 ID 的英文标签和描述。


执照

MIT 许可证

A
license - permissive license
A
quality
F
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    B
    maintenance
    A Model Context Protocol server that retrieves information from Wikipedia to provide context to LLMs, allowing users to search articles, get summaries, full content, sections, and links from Wikipedia.
    22
    285
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Provides access to Wikidata for Large Language Models through the Model Context Protocol, offering tools for entity search, detailed retrieval, SPARQL queries, relation exploration, and property-based searches.
    5
    4
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A production-ready server that provides Wikipedia search and content retrieval tools through the Model Context Protocol, enabling AI assistants to search for articles, list sections, and retrieve specific content.

View all related MCP servers

Related MCP Connectors

  • Search and fetch Wikidata entities, execute SPARQL queries, and resolve external identifiers.

  • A Model Context Protocol server for Wix AI tools

  • Wikidata MCP — wraps Wikidata API (wikidata.org/w/api.php)

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zzaebok/mcp-wikidata'

If you have feedback or need assistance with the MCP directory API, please join our Discord server