by elvismdev
Self-hosted mem0 MCP server for Claude Code. Run a complete memory server against self-hosted Qdrant + Neo4j + Ollama while using Claude as the main LLM.
# Add to your Claude Code skills
git clone https://github.com/elvismdev/mem0-mcp-selfhostedGuides for using mcp servers skills like mem0-mcp-selfhosted.
Last scanned: 7/17/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-07-17T06:14:54.990Z",
"npmAuditRan": true,
"pipAuditRan": true,
"promptInjectionRan": true
}mem0-mcp-selfhosted is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by elvismdev. Self-hosted mem0 MCP server for Claude Code. Run a complete memory server against self-hosted Qdrant + Neo4j + Ollama while using Claude as the main LLM. It has 100 GitHub stars.
Yes. mem0-mcp-selfhosted passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/elvismdev/mem0-mcp-selfhosted" and add it to your Claude Code skills directory (see the Installation section above).
mem0-mcp-selfhosted is primarily written in Python. It is open-source under elvismdev on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mem0-mcp-selfhosted against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
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.
| 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.
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.
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"
}
}
}
}
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
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.
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 the transcript and saves a summary to mem0 via infer=True |
Both hooks are non-fatal, if mem0 is unreachable or any error occurs, Claude Code continues normally.
Install hooks into your project:
mem0-install-hooks
Or install globally (all projects):
mem0-install-hooks --global
This adds the hook entries to .claude/settings.json. The installer is idempotent, running it twice won't create duplicates.
On session start, the context hook searches mem0 with two queries (project architecture + recent session summaries), deduplicates by memory ID, and formats the results as numbered lines under a # mem0 Cross-Session Memory header. These are injected via the hook's additionalContext response field.
On session stop, the stop hook reads the JSONL transcript, extracts the last 6 user/assistant messages (a sliding window via bounded deque), builds a summary prompt, and calls memory.add(infer=True) to extract atomic facts. Graph is force-disabled in hooks to stay within the 15s/30s timeout budgets.
| Command | Function | Registered in pyproject.toml |
|---|---|---|
mem0-hook-context |
hooks:context_main |
SessionStart hook |
mem0-hook-stop |
hooks:stop_main |
Stop hook |
mem0-install-hooks |
hooks:install_main |
CLI installer |
Hooks and CLAUDE.md are complementary layers that work best together:
| Layer | Role | When |
|---|---|---|
| Hooks | Automated data flow, injects stored memories on startup, saves session summaries on exit | Session boundaries (start/stop) |
| CLAUDE.md | Behavioral instructions, tells Claude to actively search and save memories during the session | Throughout the session |
Hooks alone give you passive recall (memories appear at startup) and passive saving (summaries saved at exit). CLAUDE.md instructions add active mid-session behavior, Claude searches for relevant memories when encountering new topics, and saves important discoveries immediately rather than waiting for session end.
For the best experience, use both. Hooks ensure memories flow in and out automatically at session boundaries, while CLAUDE.md ensures Claude actively engages with memory tools during the session.
The server resolves an Anthropic token using a prioritized fallback chain:
| Priority | Source | Details |
|---|---|---|
| 1 | MEM0_ANTHROPIC_TOKEN env var |
Explicit, user-controlled |
| 2 | ~/.claude/.credentials.json |
Auto-reads Claude Code's OAT token (zero-config) |
| 3 | ANTHROPIC_API_KEY env var |
Standard pay-per-use API key |
| 4 | Disabled | Warns and disables Anthropic LLM features |
In Claude Code, priority 2 always wins, the credentials file exists as long as you're logged in. This means ANTHROPIC_API_KEY (priority 3) is never reached. To override the OAT token in Claude Code, use MEM0_ANTHROPIC_TOKEN (priority 1). ANTHROPIC_API_KEY is only useful for non-Claude-Code deployments (Docker, CI, standalone).
OAT tokens (sk-ant-oat...) use your Claude subscription. The server automatically detects the token type and configures the SDK accordingly. OAT tokens are automatically refreshed before expiry: the server proactively checks the token lifetime and refreshes via the Anthropic OAuth endpoint when nearing expiry (default: 30 minutes). On authentication failures, a 3-step defensive strategy kicks in, piggybacking on Claude Code's credentials file, self-refreshing via OAuth, and wait-and-retry, so long-running sessions survive token rotation seamlessly.
API keys (sk-ant-api...) use standard pay-per-use billing.
| Tool | Description |
|---|---|
add_memory |
Store text or conversation history as memories. Supports enable_graph, infer, metadata. |
search_memories |
Semantic search with optional filters, threshold, rerank, enable_graph. |
get_memories |
List/filter memories (non-search). Supports limit and scope filters. |
get_memory |
Fetch a single memory by UUID. |
update_memory |
Replace memory text. Re-embeds and re-indexes in Qdrant. |
delete_memory |
Delete a single memory by UUID. |
delete_all_memories |
Bulk-delete all memories in a scope. |
list_entities |
List users/agents/runs with memory counts. Uses Qdrant Facet API. |
delete_entities |
Cascade-delete an entity and all its memories. |
| Tool | Description |
|---|---|
search_graph |
Search Neo4j entities by name substring. Returns entities + outgoing relationships. |
get_entity |
Get all relationships for an entity (bidirectional: incoming + outgoing). |
The server registers a memory_assistant MCP prompt that provides Claude with a quick-start guide for using the memory tools effectively.
All tools use Pydantic `Anno