Mcp Sparql

io.github.daedalus由 GitHub 账号 daedalus 发布v0.1.0更新于 Oct 25, 2026

MCP server exposing SPARQL query functionalities for LLMs

概览

AI 生成的概览

一个本地 MCP 服务器,让助手对 Wikidata 等 RDF 端点执行 SPARQL 查询,并以表格或 JSON 返回结果。

可以做什么
对 SPARQL 端点执行 SELECT 查询,返回 Markdown 表格或 JSON,可设置超时和行数上限。执行 ASK 查询得到真/假结果,执行 CONSTRUCT 或 DESCRIBE 查询获取 Turtle 或 JSON-LD 格式的 RDF 三元组。在不执行的情况下校验 SPARQL 语法。列出端点的命名图并获取常用前缀,另提供标准命名空间前缀的内置资源。
适用场景
适合让助手探索 Wikidata 等关联数据或 RDF 数据源、检查某个实体或事实是否存在,或在正式执行前起草并校验 SPARQL 语法。
运行要求
本地 Python 环境,从 PyPI 安装 mcp-sparql 包,以 stdio 进程启动。需要能访问所查询的 SPARQL 端点;未声明账号或密钥,但端点可能需要在每次调用时传入 HTTP 头。
安装前请注意
查询会发送到你指定的第三方 SPARQL 端点,查询文本和提供的请求头都会传给该主机。认证头可按调用传入,避免在查询或日志中暴露密钥。大型或高开销查询可能变慢或被端点限流;存在行数和超时限制。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Sparql,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-sparql — MCP server exposing SPARQL query functionalities for LLMs.

[PyPI] [Python] [Ruff]

mcp-name: io.github.daedalus/mcp-sparql

Install

bash
pip install mcp-sparql

Usage

As an MCP Server

Add to your MCP configuration (e.g., ~/.config/claude/mcp.json):

json
{  "mcpServers": {    "mcp-sparql": {      "command": "mcp-sparql"    }  }}

Available Tools

ToolDescription
sparql_queryExecute SPARQL SELECT queries (table or JSON output)
sparql_askExecute SPARQL ASK queries (boolean result)
sparql_constructExecute SPARQL CONSTRUCT queries (Turtle or JSON-LD)
sparql_describeExecute SPARQL DESCRIBE queries (Turtle or JSON-LD)
sparql_validateValidate SPARQL query syntax without executing
sparql_list_graphsList named graphs on a SPARQL endpoint
sparql_get_prefixesGet common prefixes for a SPARQL endpoint

Examples

Query Wikidata:

sparql_query:  endpoint: "https://query.wikidata.org/sparql"  query: "SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . ?item rdfs:label ?itemLabel . FILTER(LANG(?itemLabel) = 'en') } LIMIT 5"

Check if an entity exists:

sparql_ask:  endpoint: "https://query.wikidata.org/sparql"  query: "ASK { wd:Q42 wdt:P31 wd:Q5 }"

Validate a query:

sparql_validate:  query: "SELECT ?s WHERE { ?s ?p ?o }"

List named graphs:

sparql_list_graphs:  endpoint: "https://query.wikidata.org/sparql"

Get common prefixes:

sparql_get_prefixes:  endpoint: "https://query.wikidata.org/sparql"

Resources

ResourceURIDescription
Common Prefixessparql://common-prefixesStandard SPARQL namespace prefixes

API

sparql_query

Execute a SPARQL SELECT query.

Parameters:

  • endpoint (str): SPARQL endpoint URL
  • query (str): SPARQL SELECT query
  • timeout (int, default=30): Query timeout in seconds
  • output_format (str, default="table"): "table" for Markdown, "json" for JSON
  • headers (dict, optional): HTTP headers for authentication
  • max_rows (int, default=1000): Maximum result rows

sparql_ask

Execute a SPARQL ASK query. Returns "true" or "false".

sparql_construct

Execute a SPARQL CONSTRUCT query. Returns RDF triples.

Additional parameters:

  • output_format (str, default="turtle"): "turtle" or "json"

sparql_describe

Execute a SPARQL DESCRIBE query. Returns RDF description.

sparql_validate

Validate SPARQL query syntax without executing.

sparql_list_graphs

List available named graphs on a SPARQL endpoint.

sparql_get_prefixes

Get commonly used prefixes for a SPARQL endpoint.

Development

bash
git clone https://github.com/daedalus/mcp-sparql.gitcd mcp-sparqlpip install -e ".[test]"
# run testspytest
# formatruff format src/ tests/
# lint + type checkprospector --with-tool ruff --with-tool mypy --with-tool pylint src/

来源:README.md,提交 093080a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分