MemgraphAI

MCP Server

Use Memgraph as a Model Context Protocol (MCP) server with Claude Code, Cursor, Windsurf, and any MCP-compatible client. Give your AI assistant persistent memory.

What is MCP?

The Model Context Protocol (MCP) is an open standard for connecting AI assistants to external tools and data sources. Memgraph's MCP server exposes memory tools that let any compatible AI assistant remember, recall, and learn from interactions.

Setup: Claude Code

The fastest way to set up — one command:

bash
# Install the SDK
pip install memgraph-sdk

# One-command setup (auto-detects Claude Code)
memgraph setup --key mg_your_api_key

Or manually add to your Claude Code MCP config (~/.claude/claude_desktop_config.json):

json
{
  "mcpServers": {
    "memgraph": {
      "command": "python",
      "args": ["-m", "memgraph_sdk.mcp"],
      "env": {
        "MEMGRAPH_API_KEY": "mg_your_api_key",
        "MEMGRAPH_API_URL": "https://api.memgraph.ai/v1"
      }
    }
  }
}

Setup: Cursor

Add to your Cursor MCP settings (.cursor/mcp.json in your project root):

json
{
  "mcpServers": {
    "memgraph": {
      "command": "python",
      "args": ["-m", "memgraph_sdk.mcp"],
      "env": {
        "MEMGRAPH_API_KEY": "mg_your_api_key",
        "MEMGRAPH_API_URL": "https://api.memgraph.ai/v1"
      }
    }
  }
}

Available Tools

Once connected, your AI assistant gets access to these memory tools:

memgraph_remember

Store a memory as a searchable belief with vector embedding

Params: text (string, required), category (decision | architecture | bug_fix | preference | general)
Example: After fixing a bug: "The auth middleware was using hardcoded SECRET_KEY"
memgraph_search

Search memories by semantic similarity

Params: query (string, required), limit (int, default 5)
Example: "What do we know about the auth middleware?"
memgraph_profile

Get the user's memory profile — beliefs, preferences, and consolidated facts

Params: None
Example: View aggregated user preferences and history

MCP Resources

The MCP server also exposes readable resources:

URIDescription
memgraph://project/statusServer connection status and version
memgraph://memory/recentRecently stored memories
memgraph://memory/profileUser profile and preferences summary

Usage Tips

Add to CLAUDE.md

Add instructions to your project's CLAUDE.md to tell Claude when to use memory tools:

markdown
## MCP Memory Tools
You have Memgraph MCP tools. Use `memgraph_remember` after completing features.
Use `memgraph_recall("recent project context")` at session start.
Use categories

Always specify a category when remembering. This helps with retrieval:decision, architecture, bug_fix, preference, general.

Recall at session start

Use memgraph_recall at the beginning of each session to load project context. This gives the AI assistant continuity across sessions.

Environment Variables

VariableRequiredDescription
MEMGRAPH_API_KEYYesYour API key (starts with mg_)
MEMGRAPH_API_URLNoAPI base URL (default: https://api.memgraph.ai/v1)
MEMGRAPH_TENANT_IDNoTenant ID (auto-resolved from API key if not set)

Next steps