Mem0

Memory and knowledge

MCP server for long term agent memory with Mem0. Also useful as a template to get you started building your own MCP server with Python!

Your AI app calls the Mem0 MCP server, which does the memory and knowledge work and sends the result back to the chat.

About Mem0

Mem0 is a community MCP server from coleam00, filed in our directory under memory and knowledge. MCP server for long term agent memory with Mem0. Also useful as a template to get you started building your own MCP server with Python!

Mem0 runs on your own machine: your AI app starts it with the command docker run -i --rm and talks to it over standard input and output.

At a glance

Publisher
coleam00 (community)
Runs
Locally on your machine
Install from
Docker image: mcp/mem0
Written in
Python
License
MIT
GitHub stars
686

How to set up Mem0

  1. Have Docker running on the machine that runs your AI app, because Mem0 starts as a container.
  2. Check the Mem0 README for keys or settings; the registry lists none that Mem0 requires.
  3. Add Mem0 to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Mem0 tools to confirm the connection.
  5. Run one read-only task with Mem0 first, and keep your app asking before each tool call until the results look right.

Mem0 compared with similar servers

  • Open Second Brain by itechmeat has fewer GitHub stars than Mem0 (637 against 686); both are community servers, and both run locally.
  • Swarmvault by swarmclawai has more GitHub stars than Mem0 (741 against 686); both are community servers, and both run locally.
  • Caura by caura-ai has fewer GitHub stars than Mem0 (578 against 686); both are community servers, and Caura runs as a remote server and Mem0 runs on your own machine.

Before you connect Mem0

  • Give Mem0 its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Mem0 tool call until you trust what it does with them.
  • Treat text that Mem0 fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Mem0 on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Mem0

How marketing and sales teams put Mem0 to work, by company size. Pick the size closest to yours and start Mem0 on one use case.

Small business

  • A small business can give Mem0 its offers, FAQs and tone of voice once, so every draft starts from the same facts.
  • Founders can use Mem0 to keep notes from calls and decisions, then ask what was agreed with a customer weeks later.
  • Mem0 runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing teams can connect Mem0 to positioning docs and past campaigns, so agents write on message without a long prompt each time.
  • Sales and marketing can share one knowledge base through Mem0, so answers about pricing and features match across teams.
  • Start Mem0 on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can use Mem0 with permissions that follow the source documents, so an agent only recalls what the person asking may see.
  • Large orgs can make Mem0 the approved memory layer for agents, with retention rules and a way to delete what shouldn't be kept.
  • Mem0 is a community server, so have security review the code and pin a version before Mem0 touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Mem0 README

From coleam00/mcp-mem0 on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

MCP-Mem0: Long-Term Memory for AI Agents

A template implementation of the Model Context Protocol (MCP) server integrated with Mem0 for providing AI agents with persistent memory capabilities.

Use this as a reference point to build your MCP servers yourself, or give this as an example to an AI coding assistant and tell it to follow this example for structure and code correctness!

Overview

This project demonstrates how to build an MCP server that enables AI agents to store, retrieve, and search memories using semantic search. It serves as a practical template for creating your own MCP servers, simply using Mem0 and a practical example.

The implementation follows the best practices laid out by Anthropic for building MCP servers, allowing seamless integration with any MCP-compatible client.

Features

The server provides three essential memory management tools:

  1. save_memory: Store any information in long-term memory with semantic indexing
  2. get_all_memories: Retrieve all stored memories for comprehensive context
  3. search_memories: Find relevant memories using semantic search

Prerequisites

  • Python 3.12+
  • Supabase or any PostgreSQL database (for vector storage of memories)
  • API keys for your chosen LLM provider (OpenAI, OpenRouter, or Ollama)
  • Docker if running the MCP server as a container (recommended)

Installation

Using uv
  1. Install uv if you don't have it:

    pip install uv
    
  2. Clone this repository:

    git clone https://github.com/coleam00/mcp-mem0.git
    cd mcp-mem0
    
  3. Install dependencies:

    uv pip install -e .
    
  4. Create a .env file based on .env.example:

    cp .env.example .env
    
  5. Configure your environment variables in the .env file (see Configuration section)

Using Docker (Recommended)
  1. Build the Docker image:

    docker build -t mcp/mem0 --build-arg PORT=8050 .
    
  2. Create a .env file based on .env.example and configure your environment variables

Configuration

The following environment variables can be configured 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

Running the Server

Using uv
SSE Transport
# Set TRANSPORT=sse in .env then:
uv run src/main.py

The MCP server will essentially be run as an API endpoint that you can then connect to with config shown below.

Stdio Transport

With stdio, the MCP client iself can spin up the MCP server, so nothing to run at this point.

Using Docker
SSE Transport
docker run --env-file .env -p:8050:8050 mcp/mem0

The MCP server will essentially be run as an API endpoint within the container that you can then connect to with config shown below.

Stdio Transport

With stdio, the MCP client iself can spin up the MCP server container, so nothing to run at this point.

Integration with MCP Clients

SSE Configuration

Once you have the server running with SSE transport, you can connect to it using this configuration:

{
  "mcpServers": {
    "mem0": {
      "transport": "sse",
      "url": "http://localhost:8050/sse"
    }
  }
}

Note for Windsurf users: Use serverUrl instead of url in your configuration:

{
  "mcpServers": {
    "mem0": {
      "transport": "sse",
      "serverUrl": "http://localhost:8050/sse"
    }
  }
}

Note for n8n users: Use host.docker.internal instead of localhost since n8n has to reach outside of it's own container to the host machine:

So the full URL in the MCP node would be: http://host.docker.internal:8050/sse

Make sure to update the port if you are using a value other than the default 8050.

Python with Stdio Configuration

Add this server to your MCP configuration for Claude Desktop, Windsurf, or any other MCP client:

{
  "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"
      }
    }
  }
}
Docker with Stdio Configuration
{
  "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"
      }
    }
  }
}

Building Your Own Server

This template provides a foundation for building more complex MCP servers. To build your own:

  1. Add your own tools by creating methods with the @mcp.tool() decorator
  2. Create your own lifespan function to add your own dependencies (clients, database connections, etc.)
  3. Modify the utils.py file for any helper functions you need for your MCP server
  4. Feel free to add prompts and resources as well with @mcp.resource() and @mcp.prompt()

Questions about Mem0

What is the Mem0 MCP server?

MCP server for long term agent memory with Mem0. Also useful as a template to get you started building your own MCP server with Python!. Mem0 is maintained by coleam00 on GitHub at coleam00/mcp-mem0, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Mem0 MCP server?

Add Mem0 to your AI app's MCP config with the command docker run -i --rm mcp/mem0. In Claude Code, run claude mcp add --transport stdio mem0 -- docker run -i --rm mcp/mem0. To run Mem0 this way you need Docker running.

Does Mem0 need an API key?

The registry lists no required keys for Mem0. Check the Mem0 README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Mem0 an official MCP server?

No. Mem0 is a community server maintained by coleam00. Community servers can be excellent; read the code and the open issues before you give Mem0 access to company data.

What license is Mem0 under?

Mem0 is released under the MIT license, according to its GitHub repository. The license covers the code of Mem0; the service it connects to has its own terms.