这是一个提供只读访问权限到 Ontotext GraphDB 的模型上下文协议服务器。此服务器使大型语言模型能够探索 RDF 图并针对 GraphDB 实例执行 SPARQL 查询。
sparqlQuery
query (字符串):要执行的 SPARQL 查询graph (字符串,可选):特定图 IRIformat (字符串,可选):响应格式 (json, xml, csv)listGraphs
该服务器提供了存储库数据的多个视图:
类列表 (graphdb://<host>/repository/<repo>/classes)
谓词 (graphdb://<host>/repository/<repo>/predicates)
统计信息 (graphdb://<host>/repository/<repo>/stats)
样本数据 (graphdb://<host>/repository/<repo>/sample)
图内容 (graphdb://<host>/repository/<repo>/graph/<graphUri>)
您可以通过创建一个 .env 文件来使用环境变量配置服务器:
GRAPHDB_ENDPOINT=http://localhost:7200
GRAPHDB_REPOSITORY=myRepository
GRAPHDB_USERNAME=username
GRAPHDB_PASSWORD=password
或者,您可以将端点和存储库作为命令行参数提供:
node dist/index.js http://localhost:7200 myRepository
命令行参数优先于环境变量。
要在 Claude Desktop 应用程序中使用此服务器,请在您的 claude_desktop_config.json 的 "mcpServers" 部分添加以下配置:
{
"mcpServers": {
"graphdb": {
"command": "node",
"args": [
"/path/to/mcp-server-graphdb/dist/index.js"
],
"env": {
"GRAPHDB_ENDPOINT": "http://localhost:7200",
"GRAPHDB_REPOSITORY": "myRepository",
"GRAPHDB_USERNAME": "username",
"GRAPHDB_PASSWORD": "password"
}
}
}
}
请替换为您具体的 GraphDB 配置。
# 克隆仓库
git clone https://github.com/keonchennl/mcp-server-graphdb.git
cd mcp-server-graphdb
# 安装依赖
yarn install
# 构建项目
yarn build
这里有一些示例 SPARQL 查询,您可以使用此服务器运行:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w
3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?class ?label
WHERE {
{ ?class a rdfs:Class } UNION { ?class a owl:Class }
OPTIONAL { ?class rdfs:label ?label }
}
ORDER BY ?class
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?property ?label ?range
WHERE {
?property rdfs:domain <http://example.org/YourClass> .
OPTIONAL { ?property rdfs:label ?label }
OPTIONAL { ?property rdfs:range ?range }
}
ORDER BY ?property
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?class (COUNT(?instance) AS ?count)
WHERE {
?instance a ?class
}
GROUP BY ?class
ORDER BY DESC(?count)
此 MCP 服务器根据 GPL-3.0 许可证发布。这意味着您可以自由地使用、修改和分发软件,但需遵守 GNU GPL-3.0 许可证的条款和条件。