Model Context Protocol (MCP)

Memgraph offers Memgraph the Memgraph MCP Server

  • a lightweight server implementation of the Model Context Protocol (MCP) designed to connect Memgraph with LLMs.

mcp-server

Run Memgraph MCP server

  1. Install uv
  2. Install Claude for Desktop.
  3. Add the Memgraph server to Claude config:

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

$env:AppData\Claude\claude_desktop_config.json

Add the following config:

{
    "mcpServers": {
      "mpc-memgraph": {
        "command": "uv",
        "args": [
            "run",
            "--with",
            "mcp-memgraph",
            "--python",
            "3.13",
            "mcp-memgraph"
        ]
     }
   }
}

You may need to put the full path to the uv executable in the command field. You can get this by running which uv on MacOS/Linux or where uv on Windows. Make sure you pass in the absolute path to your server.

Chat with the database

  1. Run Memgraph MAGE:

    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.

  2. Open Claude Desktop and see the Memgraph tools and resources listed. Try it out! (You can load dummy data from Memgraph Lab Datasets)

Run Memgraph MCP server with Docker

Build the Docker image

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 install your local memgraph-toolbox into the image.

Run the Docker image

1. Streamable HTTP mode (recommended)

To expose the MCP HTTP server locally:

docker run --rm mcp-memgraph:latest

The server will be available at http://localhost:8000/mcp/

2. Stdio mode (for integration with MCP stdio clients)

Configure your MCP host to run the docker command and utilize stdio:

docker run --rm -i -e MCP_TRANSPORT=stdio mcp-memgraph:latest

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.

3. Custom Memgraph connection (external instance, no host network)

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

Connect from developer tools

Visual Studio Code (HTTP MCP extension)

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/"
    }
  }
}

The URL must end in /mcp/

Visual Studio Code (stdio using Docker)

You can also run the server using stdio for integration with MCP stdio clients:

  1. Open Visual Studio Code, open Command Palette (Ctrl+Shift+P or Cmd+Shift+P on Mac), and select MCP: Add server....
  2. Choose Command (stdio)
  3. Enter docker as the command to run.
  4. For Server ID enter mcp-memgraph.
  5. Choose “User” (adds to user-space 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"
      ]
    }
  }
}

Then open GitHub Copilot in Agent mode, and interact with Memgraph using natural language.

Resources

MCP server in Lab

Memgraph Lab has become an MCP Client and now has built-in support for MCP servers, including the Memgraph MCP Server. This means you can build your agentic applications powered by Memgraph MCP, Toolkit and Lab.

mcp-lab

More details about the MCP connection in Memgraph Lab can be found in the Memgraph Lab documentation.