用于 Dgraph 图数据库的模型上下文协议 (MCP) 服务器实现,基于 mcp-go 库构建。
本项目实现了一个 MCP 服务器,允许大型语言模型 (LLM) 应用程序与 Dgraph 数据库进行交互。它提供了以下工具:
go mod download
服务器可以通过环境变量进行配置:
DGRAPH_HOST: Dgraph 主机地址(默认:localhost:9080)go run main.go
服务器使用标准输入/输出与 LLM 应用程序通信。
执行针对 Dgraph 的 DQL 查询。
参数:
query (字符串,必需):要执行的 DQL 查询variables (对象,可选):查询的变量示例:
{
"tool": "dgraph_query",
"params": {
"query": "{ me(func: has(name)) { name } }"
}
}
执行针对 Dgraph 的数据变更操作。
参数:
mutation (字符串,必需):要执行的 RDF 变更commit (布尔值,可选):是否提交事务(默认:true)示例:
{
"tool": "dgraph_mutate",
"params": {
"mutation": "_:person <name> \"John Doe\" .",
"commit": true
}
}
修改 Dgraph 的模式。
参数:
schema (字符串,必需):要应用的模式定义示例:
{
"tool": "dgraph_alter_schema",
"params": {
"schema": "name: string @index(exact) ."
}
}
返回当前的 Dgraph 模式。
此服务器可以与支持模型上下文协议 (MCP) 的任何 LLM 应用程序集成。服务器通过标准输入/输出进行通信,使其易于与各种 LLM 框架集成。
{
people(func: has(name)) {
name
age
friends {
name
}
}
}
_:alice <name> "Alice" .
_:alice <age> "30" .
_:bob <name> "Bob" .
_:bob <age> "32" .
_:alice <friend> _:bob .
name: string @index(exact) .
age: int .
friend: [uid] .
MIT