
Memgraph
STDIOOfficial连接Memgraph数据库与大语言模型的轻量级服务器
连接Memgraph数据库与大语言模型的轻量级服务器
Memgraph MCP Server is a lightweight server implementation of the Model Context Protocol (MCP) designed to connect Memgraph with LLMs.
uv
You can do it in the UI, by opening your Claude desktop app navigate to Settings
, under the Developer
section, click on Edit Config
and add the
following content:
{
"mcpServers": {
"mpc-memgraph": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-memgraph",
"--python",
"3.13",
"mcp-memgraph"
]
}
}
}
Or you can open the config file in your favorite text editor. The location of the config file depends on your operating system:
MacOS/Linux
~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows
%APPDATA%/Claude/claude_desktop_config.json
[!NOTE]
You may need to put the full path to the uv executable in the command field. You can get this by runningwhich uv
on MacOS/Linux orwhere uv
on Windows. Make sure you pass in the absolute path to your server.
docker run -p 7687:7687 memgraph/memgraph-mage --schema-info-enabled=True
The --schema-info-enabled
configuration setting is set to True
to allow LLM to run SHOW SCHEMA INFO
query.The Memgraph MCP Server exposes the following tools over MCP. Each tool runs a Memgraph‐toolbox operation and returns a list of records (dictionaries).
Run any arbitrary Cypher query against the connected Memgraph database.
Parameters:
query
: A valid Cypher query string.Fetch the current Memgraph configuration settings.
Equivalent to running SHOW CONFIGURATION
.
Retrieve information about existing indexes.
Equivalent to running SHOW INDEX INFO
.
Retrieve information about existing constraints.
Equivalent to running SHOW CONSTRAINT INFO
.
Fetch the graph schema (labels, relationships, property keys).
Equivalent to running SHOW SCHEMA INFO
.
Retrieve storage usage metrics for nodes, relationships, and properties.
Equivalent to running SHOW STORAGE INFO
.
List all database triggers.
Equivalent to running SHOW TRIGGERS
.
Compute betweenness centrality on the entire graph.
Uses BetweennessCentralityTool
under the hood.
Compute PageRank scores for all nodes.
Uses PageRankTool
under the hood.
To build the Docker image using your local memgraph-toolbox
code, run from the root of the monorepo:
cd /path/to/ai-toolkit docker build -f integrations/mcp-memgraph/Dockerfile -t mcp-memgraph:latest .
This will include your local memgraph-toolbox
and install it inside the image.
To connect to local Memgraph containers, by default the MCP server will be available at http://localhost:8000/mcp/
:
docker run --rm mcp-memgraph:latest
Configure your MCP host to run the docker command and utilize stdio:
docker run --rm -i -e MCP_TRANSPORT=stdio mcp-memgraph:latest
📄 Note: By default, the server will connect to a Memgraph instance running on localhost docker network
bolt://host.docker.internal:7687
. If you have a Memgraph instance running on a different host or port, you can specify it using environment variables.
To avoid using host networking, or to connect to an external Memgraph instance:
docker run --rm \ -p 8000:8000 \ -e MEMGRAPH_URL=bolt://memgraph:7687 \ -e MEMGRAPH_USER=myuser \ -e MEMGRAPH_PASSWORD=password \ mcp-memgraph:latest
If you are using VS Code MCP extension or similar, your configuration for an HTTP server would look like:
{ "servers": { "mcp-memgraph-http": { "url": "http://localhost:8000/mcp/" } } }
Note: The URL must end with
/mcp/
.
You can also run the server using stdio for integration with MCP stdio clients:
MCP: Add server...
.Command (stdio)
docker
as the command to run.mcp-memgraph
.settings.json
) or "Workspace" (adds to .vscode/mcp.json
).When the settings open, enhance the args as follows:
{ "servers": { "mcp-memgraph": { "type": "stdio", "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MCP_TRANSPORT=stdio", "mcp-memgraph:latest" ] } } }
To connect to a remote Memgraph instance with authentication, add environment variables to the args
list:
{ "servers": { "mcp-memgraph": { "type": "stdio", "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MCP_TRANSPORT=stdio", "-e", "MEMGRAPH_URL=bolt://memgraph:7687", "-e", "MEMGRAPH_USER=myuser", "-e", "MEMGRAPH_PASSWORD=mypassword", "mcp-memgraph:latest" ] } } }
Open GitHub Copilot in Agent mode and you'll be able to interact with the Memgraph MCP server.