mem0-mcp
mem0-mcp-server
MCP server exposing Mem0 v2 API for AI agents to store, retrieve, and search long-term memories using semantic search through the standardized MCP protocol.
Overview
Mem0-MCP Server is a self-hosted MCP (Model Context Protocol) server that bridges AI agents with persistent memory storage. It enables intelligent context retention across conversations and sessions using Mem0's AsyncMemory API.
Key Features:
MCP Protocol Integration - Exposes Mem0 functionality via MCP tools
Semantic Memory Search - Similarity-based memory retrieval with vector search
Multi-Tenant Isolation - User/Agent/Session scoped memory isolation
Flexible Transport - stdio for local agents, SSE for remote connections
Configuration Management - Pydantic-based validation with environment variable support
Related MCP server: Amber
Documentation
Section | Description |
Complete API documentation for all modules and tools | |
Design pattern documentation (Singleton, Repository, etc.) | |
Getting started and advanced usage guides | |
Docker Compose configuration and service details | |
System architecture and component interactions |
Quick Start
Installation
# Clone and install
git clone https://github.com/your-org/mem0-mcp-server.git
cd mem0-mcp-server
uv sync
# Set environment variables
export OPENAI_API_KEY="your-api-key"Configuration
Create ~/.config/mem0-mcp-server/settings.json:
{
"vector_store": {
"provider": "redis",
"config": {
"redis_url": "redis://localhost:6379"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o"
}
},
"embedder": {
"provider": "openai",
"config": {
"model": "text-embedding-3-small"
}
}
}Running the Server
# SSE Transport (remote connections)
uv run python -m mcp_server.main
# stdio Transport (local AI agents)
export MCP_TRANSPORT=stdio
uv run python -m mcp_server.mainOpenCode Configuration
In ~/config/opencode/opencode.json
OpenCode Configuration
In ~/config/opencode/opencode.json
"mcp": {
"mem0": {
"type": "remote",
"enabled": true,
"url": "http://localhost:8050/sse"
}
}
MCP Tools
Tool | Description |
| Store information in long-term memory with semantic indexing |
| Search memories using semantic similarity |
| Retrieve specific memory by ID |
| Update existing memory content |
| Remove memory from storage |
| List memories with filtering and pagination |
Usage Example
# Add memory
result = await client.call_tool("add_memory", {
"messages": [{"role": "user", "content": "I prefer dark mode"}],
"user_id": "alice"
})
# Search memories
result = await client.call_tool("search_memories", {
"query": "theme preferences",
"filters": {"user_id": "alice"},
"limit": 5
})Architecture
AI Agent → FastMCP Server → MemoryManager → Mem0 AsyncMemory → Redis
│ │
├── SafeLogger (stdout/stderr) │
├── Transport (stdio/SSE) │
└── Config (Pydantic validation) │Components:
COMP-1: ConfigLoader - Configuration loading and validation
COMP-2: FastMCP Server - MCP protocol server
COMP-3: MemoryManager - Memory operations with multi-tenant isolation
COMP-4: MCP Tools - Tool definitions
COMP-5: SafeLogger - Output stream separation
Configuration
Parameter Precedence
Configuration values are resolved in order:
Tool parameters (direct)
Environment variables (with MCP_ prefix)
Config file values
Hardcoded defaults
Environment Variables
Variable | Default | Description |
| (required) | OpenAI API key for LLM |
|
| Transport type (stdio, sse) |
|
| Server bind address |
|
| Server bind port |
Deployment
Docker
# Using docker-compose
docker-compose up -d
# Using Makefile
make docker-up # Start services with docker compose
make docker-down # Stop services
make docker-logs # Show logsServices:
Service | Description |
| MCP server exposing Mem0 API on port 8050 |
| Ollama with |
| Ollama with |
See Deployment → Docker for detailed configuration.
Kubernetes
# Using Helm chart
helm install mem0-mcp ./charts/mem0-mcp-serverDevelopment
Command | Description |
| Install dependencies with uv |
| Lint code with ruff |
| Auto-fix linting issues |
| Type check with pyright |
| Run all tests |
| Run unit tests only |
| Run tests with coverage report |
| Build Docker image |
| Run development server |
Run multiple commands: make install && make lint && make typecheck && make test
See Makefile for all available commands including Docker management (docker-up, docker-down, docker-logs, etc.).
Project Structure
mem0-mcp/
├── src/mcp_server/
│ ├── __init__.py # FastMCP singleton
│ ├── lifespan.py # Resource lifecycle
│ ├── transport.py # Transport selection
│ ├── memory/
│ │ ├── manager.py # MemoryManager
│ │ └── lifespan.py # AsyncMemory lifecycle
│ ├── config/
│ │ ├── settings.py # Pydantic models
│ │ └── loader.py # Config file loading
│ ├── tools/
│ │ ├── add_memory.py
│ │ ├── search_memories.py
│ │ └── ...
│ └── utils/
│ └── safe_logger.py # Output separation
├── doc/
│ ├── api/ # API reference
│ ├── patterns/ # Pattern guides
│ ├── examples/ # Usage examples
│ └── architecture/ # Architecture docs
├── tests/
├── Makefile
├── Dockerfile
└── docker-compose.ymlLicense
MIT License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityBmaintenanceSelf-hosted remote MCP memory server for ChatGPT and AI agents.Last updated2MIT
- AlicenseAqualityAmaintenanceGives your AI persistent memory across conversations. Stores facts automatically, finds them by meaning using hybrid search with query expansion, and organizes everything into topics without manual tagging.Last updated18MIT
- Alicense-qualityCmaintenancePersistent semantic memory server for AI assistants via MCP, enabling long-term context retention and semantic search across conversations.Last updated11MIT
- Flicense-qualityBmaintenancePersistent semantic memory MCP server for AI agents with hybrid search, LLM scoring, and decay engine, fully local.Last updated2
Related MCP Connectors
User-owned memory for AI agents, Copilot, Claude, IDEs, CLIs, and chat apps over remote MCP.
Cloud-hosted MCP server for durable AI memory
Remote ChromaDB vector database MCP server with streamable HTTP transport
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/olk/mem0-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server