Mem0 MCP Self-hosted MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add -e "MEM0_USER_ID=${MEM0_USER_ID}" mem0-mcp-selfhosted -- uvx --from git+https://github.com/elvismdev/mem0-mcp-selfhosted.git mem0-mcp-selfhosted
Required:MEM0_USER_ID+ 2 optional
README.md

Self-hosted mem0 MCP server for Claude Code.

mem0-mcp-selfhosted

Self-hosted mem0 MCP server for Claude Code. Run a complete memory server against self-hosted Qdrant + Neo4j + Ollama, with your choice of Anthropic (Claude) or Ollama as the main LLM.

Uses the mem0ai package directly as a library, supports both Claude's OAT token and fully local Ollama setups, and exposes 11 MCP tools for full memory management.

Prerequisites

Service Required Purpose
Qdrant Yes Vector memory storage and search
Ollama Yes Embedding generation (bge-m3) and optionally local LLM
Neo4j 5+ Optional Knowledge graph (entity relationships)
Google API Key Optional Required only for gemini/gemini_split graph providers

Python >= 3.10 and uv.

Authentication: The default setup uses Claude (Anthropic) as the LLM for fact extraction. No API key needed, the server automatically uses your Claude Code session token. For fully local setups, set MEM0_PROVIDER=ollama. See Authentication for advanced options.

Quick Start

Default (Anthropic)

Add the MCP server globally (available across all projects):

claude mcp add --scope user --transport stdio mem0 \
  --env MEM0_USER_ID=your-user-id \
  -- uvx --from git+https://github.com/elvismdev/mem0-mcp-selfhosted.git mem0-mcp-selfhosted

All defaults work out of the box: Qdrant on localhost:6333, Ollama embeddings on localhost:11434 with bge-m3 (1024 dims). Override any default via --env (see Configuration).

uvx automatically downloads, installs, and runs the server in an isolated environment, no manual installation needed. Claude Code launches it on demand when the MCP connection starts.

The server auto-reads your OAT token from ~/.claude/.credentials.json, no manual token configuration needed.

Fully Local (Ollama)

For a fully local setup with no cloud dependencies, use Ollama for both the main LLM and embeddings:

claude mcp add --scope user --transport stdio mem0 \
  --env MEM0_PROVIDER=ollama \
  --env MEM0_LLM_MODEL=qwen3:14b \
  --env MEM0_USER_ID=your-user-id \
  -- uvx --from git+https://github.com/elvismdev/mem0-mcp-selfhosted.git mem0-mcp-selfhosted

MEM0_PROVIDER=ollama cascades to both the main LLM and graph LLM providers. Same infrastructure defaults apply (Qdrant on localhost:6333, bge-m3 embeddings). Per-service overrides (e.g. MEM0_LLM_URL, MEM0_EMBED_URL) still work when needed.

Or add it to a single project by creating .mcp.json in the project root:

{
  "mcpServers": {
    "mem0": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/elvismdev/mem0-mcp-selfhosted.git", "mem0-mcp-selfhosted"],
      "env": {
        "MEM0_PROVIDER": "ollama",
        "MEM0_LLM_MODEL": "qwen3:14b",
        "MEM0_USER_ID": "your-user-id"
      }
    }
  }
}

Try It

Restart Claude Code, then:

> Search my memories for TypeScript preferences
> Remember that I prefer Hatch for Python packaging
> Show me all entities in my knowledge graph

CLAUDE.md Integration

Add these rules to your project's CLAUDE.md (or ~/.claude/CLAUDE.md for global use) so Claude Code proactively uses memory tools throughout the session:

# MCP Servers

- **mem0**: Persistent memory across sessions. At the start of each session, `search_memories` for relevant context before asking the user to re-explain anything. Use `add_memory` whenever you discover project architecture, coding conventions, debugging insights, key decisions, or user preferences. Use `update_memory` when prior context changes. Save information like: "This project uses PostgreSQL with Prisma", "Tests run with pytest -v", "Auth uses JWT validated in middleware". When in doubt, save it, future sessions benefit from over-remembering.

This gives Claude Code behavioral instructions to actively search and save memories during the session. For best results, combine with Claude Code Hooks, the CLAUDE.md rules tell Claude how to use memory tools mid-session, while hooks handle the automatic injection and saving at session boundaries.

Claude Code Hooks

Session hooks automate memory at session boundaries, injecting memories on startup and saving summaries on exit. This happens automatically without manual tool calls.

Hook Event What it does
mem0-hook-context SessionStart (startup, compact) Searches mem0 for project-relevant memories and injects them as additionalContext
mem0-hook-stop Stop Reads the last ~3 user/assistant exchanges from th

Tools (3)

search_memoriesSearch for relevant context in memory.
add_memoryAdd new information to persistent memory.
update_memoryUpdate existing memory entries.

Environment Variables

MEM0_USER_IDrequiredUnique identifier for the user
MEM0_PROVIDERLLM provider for memory processing (e.g., ollama)
MEM0_LLM_MODELModel to use for memory processing

Configuration

claude_desktop_config.json
{"mcpServers": {"mem0": {"command": "uvx", "args": ["--from", "git+https://github.com/elvismdev/mem0-mcp-selfhosted.git", "mem0-mcp-selfhosted"], "env": {"MEM0_PROVIDER": "ollama", "MEM0_LLM_MODEL": "qwen3:14b", "MEM0_USER_ID": "your-user-id"}}}}

Try it

Search my memories for TypeScript preferences.
Remember that I prefer Hatch for Python packaging.
Show me all entities in my knowledge graph.
What do I usually do when I encounter a 404 error in this project?

Frequently Asked Questions

What are the key features of Mem0 MCP Self-hosted?

Persistent memory storage across different Claude Code sessions. Support for self-hosted Qdrant vector database and Neo4j knowledge graph. Flexible LLM provider support including Anthropic and local Ollama. Automatic memory injection and summarization via session hooks. Exposes 11 MCP tools for comprehensive memory management.

What can I use Mem0 MCP Self-hosted for?

Maintaining project-specific coding conventions and architecture knowledge. Storing debugging insights and resolutions for recurring issues. Tracking user preferences for tools, libraries, and workflows. Building a persistent knowledge graph of project entities and relationships.

How do I install Mem0 MCP Self-hosted?

Install Mem0 MCP Self-hosted by running: claude mcp add --scope user --transport stdio mem0 --env MEM0_USER_ID=your-user-id -- uvx --from git+https://github.com/elvismdev/mem0-mcp-selfhosted.git mem0-mcp-selfhosted

What MCP clients work with Mem0 MCP Self-hosted?

Mem0 MCP Self-hosted works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Mem0 MCP Self-hosted docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare