Skip to main content
Glama
keonchennl

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists graphs but doesn't describe how it behaves—e.g., whether it's read-only, safe, requires authentication, has rate limits, or what the output format might be. This leaves significant gaps in understanding the tool's operational traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It is front-loaded with the core action and resource, making it highly efficient and easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema), the description is minimal but incomplete. It lacks behavioral context, usage guidelines, and output details, which are important even for simple tools. Without annotations or an output schema, the description should do more to inform the agent about what to expect.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, meaning no parameters are documented in the schema. The description doesn't need to add parameter details, as there are none to explain. It efficiently states the tool's purpose without unnecessary parameter information, meeting the baseline for tools with no parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List') and the resource ('all graphs in the repository'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from the sibling tool 'sparqlQuery', which might also involve graph operations, so it doesn't reach the highest score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus the sibling 'sparqlQuery' or any alternatives. It lacks context about use cases, prerequisites, or exclusions, offering only a basic statement of purpose without operational guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

sparqlQueryA

Execute a read-only SPARQL query against the GraphDB repository

ParametersJSON Schema
NameRequiredDescriptionDefault
formatNoOptional: Response format (json, xml, csv)json
graphNoOptional: Specific graph IRI to query
queryYesThe SPARQL query to execute

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the 'read-only' behavioral trait, which is crucial for safety, but lacks details on other aspects like authentication needs, rate limits, error handling, or response structure. This is a minimal but adequate disclosure given the simple query nature.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with zero waste—it directly states the tool's purpose and key constraint ('read-only'). Every word earns its place, making it highly efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (executing queries with parameters) and no annotations or output schema, the description is minimally complete. It covers the core purpose and safety ('read-only') but lacks guidance on result handling or advanced usage, leaving gaps for the agent to infer.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all three parameters. The description doesn't add any meaning beyond what the schema provides (e.g., no extra details on query syntax or format implications). Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute'), resource ('SPARQL query'), and target ('GraphDB repository'), and distinguishes from the sibling tool 'listGraphs' by specifying query execution rather than listing. It's precise and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'read-only', which provides clear context for when to use this tool (for queries that don't modify data). However, it doesn't mention when not to use it or explicitly compare it to the sibling tool 'listGraphs' beyond the implied difference in purpose.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 2 tool updatesv1.0.0
    • First observedlistGraphs
    • First observedsparqlQuery

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

ActivityInactive
ResponsivenessNo issues

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
    F
    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.
    55
    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