Skip to main content
Glama
GraphDB MCP Server

GraphDB MCP Server

by keonchennl

GraphDB MCP 服务器

提供对 Ontotext GraphDB 的只读访问的模型上下文协议 (MCP) 服务器。该服务器使 LLM 能够探索 RDF 图并针对 GraphDB 实例执行 SPARQL 查询。

成分

工具

  • sparql查询

    • 针对连接的 GraphDB 存储库执行 SPARQL 查询

    • 输入:

      • query (字符串):要执行的 SPARQL 查询

      • graph (字符串,可选):要针对的特定图形 IRI

      • format (字符串,可选):响应格式(json、xml、csv)

    • 所有查询均以只读模式执行

  • 列表图

    • 列出存储库中所有可用的图表

    • 无需输入参数

资源

服务器提供了存储库数据的多个视图:

  • 类列表( graphdb://<host>/repository/<repo>/classes )

    • 列出存储库中找到的所有 RDF 类及其计数

  • 谓词( graphdb://<host>/repository/<repo>/predicates )

    • 列出所有谓词(属性)及其使用次数

  • 统计信息( graphdb://<host>/repository/<repo>/stats )

    • 提供主语、谓语、宾语和三元组的计数

  • 示例数据( graphdb://<host>/repository/<repo>/sample )

    • 显示来自存储库的三元组示例

  • 图表内容( graphdb://<host>/repository/<repo>/graph/<graphUri> )

    • 提供特定图表的样本数据以及元数据

Related MCP server: RDF Explorer

配置

您可以通过创建.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 应用程序一起使用,请将以下配置添加到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 配置替换这些值。

安装

# Clone the repository
git clone https://github.com/yourname/mcp-server-graphdb.git
cd mcp-server-graphdb

# Install dependencies
yarn install

# Build the project
yarn build

SPARQL 查询示例

以下是您可以使用该服务器运行的一些 SPARQL 查询示例:

  1. 列出本体中的所有类:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.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
  1. 列出特定类的所有属性:

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
  1. 按类别计数实例:

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 许可证的条款和条件。

Available Tools

2 tools
listGraphsB

List all graphs in the repository

Inputs: no named parameters.

sparqlQueryA

Execute a read-only SPARQL query against the GraphDB repository

Inputs: query (required), format, graph.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: one lists available graphs, while the other executes queries against them. There is no overlap in functionality, making it impossible to confuse their intended use.

    Naming Consistency4/5

    Both tools use camelCase naming, which is consistent, but they follow different patterns: 'listGraphs' uses a verb-noun structure, while 'sparqlQuery' uses a noun-verb structure. This minor deviation prevents a perfect score.

    Tool Count2/5

    With only two tools, the server feels thin for a GraphDB domain, lacking essential operations like creating, updating, or deleting graphs or data. This minimal set is insufficient for typical database workflows.

    Completeness2/5

    The server covers listing and querying but misses critical CRUD operations for a GraphDB system, such as creating graphs, inserting data, or modifying content. This creates significant gaps that will hinder agent tasks.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that connects AI agents to Apache Jena, enabling them to execute SPARQL queries and updates against RDF data stored in Jena Fuseki.
      8
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      The Model Context Protocol (MCP) server provides a conversational interface for the exploration and analysis of RDF Turtle Knowledge Graph in Local File mode or SPARQL Endpoint.
      56
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that connects GraphDB's SPARQL endpoints and Ollama models to Claude, enabling Claude to query and manipulate ontology data while leveraging various AI models.
      28
      3
      MIT
    • A
      license
      C
      quality
      Not graded
      maintenance
      A lightweight server implementation of the Model Context Protocol that connects Memgraph database with LLMs, allowing users to interact with graph databases through natural language.
      1
      25
      MIT