The Memgraph MCP Server implements the Model Context Protocol (MCP) to connect Memgraph graph database with Large Language Models. This lightweight server enables LLMs to query Memgraph and leverage its graph capabilities, allowing for more powerful AI applications with database integration.
Before setting up the Memgraph MCP Server, you need:
Install the uv
package manager and create a virtual environment:
# Install uv (follow instructions at https://docs.astral.sh/uv/getting-started/installation/)
# Create and activate virtual environment
uv venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate
Install required dependencies:
uv add "mcp[cli]" httpx
Run the Memgraph MCP server:
uv run server.py
Download and install Claude for Desktop
Add the Memgraph server to Claude's configuration:
On macOS/Linux:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows:
code $env:AppData\Claude\claude_desktop_config.json
Add the following configuration (adjust paths to match your system):
{
"mcpServers": {
"mpc-memgraph": {
"command": "/full/path/to/uv",
"args": [
"--directory",
"/full/path/to/mcp-memgraph",
"run",
"server.py"
]
}
}
}
Note: Replace /full/path/to/uv
with the actual path to your uv executable. You can find this by running which uv
on macOS/Linux or where uv
on Windows.
Run Memgraph with MAGE extensions and schema information enabled:
docker run -p 7687:7687 memgraph/memgraph-mage --schema-info-enabled=True
The --schema-info-enabled=True
flag is required to allow the LLM to run the SHOW SCHEMA INFO
query.
This tool allows you to execute Cypher queries against your Memgraph database. Example usage in Claude:
Please run the query: MATCH (n) RETURN n LIMIT 10
This resource provides information about your Memgraph database schema, including node labels, relationship types, and properties. This helps the LLM understand your data model.
Note: This requires the --schema-info-enabled=True
configuration flag when starting Memgraph.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.