This is a Model Context Protocol (MCP) server implementation that integrates with Mem0, providing AI agents with persistent memory capabilities. It allows agents to save, retrieve, and semantically search memories, creating a more cohesive and context-aware AI experience.
Before installing the MCP-Mem0 server, ensure you have:
Install uv if you don't have it:
pip install uv
Clone the repository:
git clone https://github.com/coleam00/mcp-mem0.git
cd mcp-mem0
Install dependencies:
uv pip install -e .
Create a configuration file:
cp .env.example .env
Build the Docker image:
docker build -t mcp/mem0 --build-arg PORT=8050 .
Create and configure your .env
file based on the .env.example
template
Configure the following environment variables in your .env
file:
Variable | Description | Example |
---|---|---|
TRANSPORT |
Transport protocol (sse or stdio) | sse |
HOST |
Host to bind to when using SSE transport | 0.0.0.0 |
PORT |
Port to listen on when using SSE transport | 8050 |
LLM_PROVIDER |
LLM provider (openai, openrouter, or ollama) | openai |
LLM_BASE_URL |
Base URL for the LLM API | https://api.openai.com/v1 |
LLM_API_KEY |
API key for the LLM provider | sk-... |
LLM_CHOICE |
LLM model to use | gpt-4o-mini |
EMBEDDING_MODEL_CHOICE |
Embedding model to use | text-embedding-3-small |
DATABASE_URL |
PostgreSQL connection string | postgresql://user:pass@host:port/db |
Set TRANSPORT=sse
in your .env
file, then run:
uv run src/main.py
This runs the MCP server as an API endpoint that clients can connect to.
docker run --env-file .env -p 8050:8050 mcp/mem0
After starting the server with SSE transport, connect to it using this configuration:
{
"mcpServers": {
"mem0": {
"transport": "sse",
"url": "http://localhost:8050/sse"
}
}
}
For Windsurf users:
{
"mcpServers": {
"mem0": {
"transport": "sse",
"serverUrl": "http://localhost:8050/sse"
}
}
}
For n8n users: Use host.docker.internal
instead of localhost
:
http://host.docker.internal:8050/sse
For Claude Desktop, Windsurf, or other MCP clients:
{
"mcpServers": {
"mem0": {
"command": "your/path/to/mcp-mem0/.venv/Scripts/python.exe",
"args": ["your/path/to/mcp-mem0/src/main.py"],
"env": {
"TRANSPORT": "stdio",
"LLM_PROVIDER": "openai",
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_API_KEY": "YOUR-API-KEY",
"LLM_CHOICE": "gpt-4o-mini",
"EMBEDDING_MODEL_CHOICE": "text-embedding-3-small",
"DATABASE_URL": "YOUR-DATABASE-URL"
}
}
}
}
{
"mcpServers": {
"mem0": {
"command": "docker",
"args": ["run", "--rm", "-i",
"-e", "TRANSPORT",
"-e", "LLM_PROVIDER",
"-e", "LLM_BASE_URL",
"-e", "LLM_API_KEY",
"-e", "LLM_CHOICE",
"-e", "EMBEDDING_MODEL_CHOICE",
"-e", "DATABASE_URL",
"mcp/mem0"],
"env": {
"TRANSPORT": "stdio",
"LLM_PROVIDER": "openai",
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_API_KEY": "YOUR-API-KEY",
"LLM_CHOICE": "gpt-4o-mini",
"EMBEDDING_MODEL_CHOICE": "text-embedding-3-small",
"DATABASE_URL": "YOUR-DATABASE-URL"
}
}
}
}
The server provides three main memory management tools:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.