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:
# Install the SDK
pip install memgraph-sdk
# One-command setup (auto-detects Claude Code)
memgraph setup --key mg_your_api_keyOr manually add to your Claude Code MCP config (~/.claude/claude_desktop_config.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):
{
"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_rememberStore a memory as a searchable belief with vector embedding
memgraph_searchSearch memories by semantic similarity
memgraph_profileGet the user's memory profile — beliefs, preferences, and consolidated facts
MCP Resources
The MCP server also exposes readable resources:
| URI | Description |
|---|---|
memgraph://project/status | Server connection status and version |
memgraph://memory/recent | Recently stored memories |
memgraph://memory/profile | User profile and preferences summary |
Usage Tips
Add instructions to your project's CLAUDE.md to tell Claude when to use memory tools:
## MCP Memory Tools
You have Memgraph MCP tools. Use `memgraph_remember` after completing features.
Use `memgraph_recall("recent project context")` at session start.Always specify a category when remembering. This helps with retrieval:decision, architecture, bug_fix, preference, general.
Use memgraph_recall at the beginning of each session to load project context. This gives the AI assistant continuity across sessions.
Environment Variables
| Variable | Required | Description |
|---|---|---|
MEMGRAPH_API_KEY | Yes | Your API key (starts with mg_) |
MEMGRAPH_API_URL | No | API base URL (default: https://api.memgraph.ai/v1) |
MEMGRAPH_TENANT_ID | No | Tenant ID (auto-resolved from API key if not set) |
Next steps
- Python SDK — Full programmatic API for advanced use cases
- Cognitive Sidecar — Auto-recall and auto-learn without tools
- Quick Start — Get started with Memgraph in 5 minutes
