A Model Context Protocol (MCP) server implementation for Dgraph graph database, built using the mcp-go library.
This project implements an MCP server that allows LLM applications to interact with a Dgraph database. It provides tools for:
- Executing DQL queries
- Performing mutations
- Altering the schema
- Retrieving the current schema
- Go 1.18 or higher
- Dgraph database (running locally or remotely)
- Clone this repository
- Install dependencies:
go mod download
The server can be configured using environment variables:
DGRAPH_HOST
: Dgraph host address (default:localhost:9080
)
go run main.go
The server uses standard input/output for communication with LLM applications.
Execute a DQL query against Dgraph.
Parameters:
query
(string, required): The DQL query to executevariables
(object, optional): Variables for the query
Example:
{
"tool": "dgraph_query",
"params": {
"query": "{ me(func: has(name)) { name } }"
}
}
Execute a mutation against Dgraph.
Parameters:
mutation
(string, required): The RDF mutation to executecommit
(boolean, optional): Whether to commit the transaction (default: true)
Example:
{
"tool": "dgraph_mutate",
"params": {
"mutation": "_:person <name> \"John Doe\" .",
"commit": true
}
}
Alter the Dgraph schema.
Parameters:
schema
(string, required): The schema definition to apply
Example:
{
"tool": "dgraph_alter_schema",
"params": {
"schema": "name: string @index(exact) ."
}
}
Returns the current Dgraph schema.
This server can be integrated with any LLM application that supports the Model Context Protocol (MCP). The server communicates via standard input/output, making it easy to integrate with various LLM frameworks.
{
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