Mem0 MCP server

Integrates with Mem0's memory storage to provide persistent memory streams with semantic search capabilities, enabling recall of user preferences and conversation history across interactions.
Back to servers
Provider
Sadi Uysal
Release date
Mar 24, 2025
Language
TypeScript

The mem0 MCP Server provides a TypeScript implementation of the Model Context Protocol, enabling memory stream functionality through Mem0 integration. This server allows you to create, append to, search, read from, and delete memory streams with seamless Mem0 integration.

Prerequisites

Before installing and using the mem0 MCP Server, ensure you have:

  1. Node.js and npm installed on your system
  2. A Mem0 API key (available from mem0.ai)

Installation and Setup

Install the necessary dependencies:

npm install

Configuration

Set your Mem0 API key as an environment variable:

export MEM0_API_KEY=your-api-key-here

Building the Server

Compile the TypeScript code:

npm run build

Starting the Server

Launch the server:

npm start

Verifying Installation

Run the test client to verify that everything is working correctly:

npm test

Using the MCP Server

The server provides several tools for managing memory streams:

Creating a Memory Stream

Create a new memory stream with optional initial content:

// Example request
{
  "tool": "create-memory-stream",
  "parameters": {
    "name": "My Memory Stream",
    "initialContent": "Initial memories to store",
    "userId": "user123",  // optional
    "agentId": "agent456" // optional
  }
}

This returns a stream ID and metadata for future operations.

Appending Content to a Stream

Add new content to an existing memory stream:

// Example request
{
  "tool": "append-to-stream",
  "parameters": {
    "streamId": "stream123",
    "content": "New information to remember",
    "role": "user" // or "assistant"
  }
}

Searching Memories

Use Mem0's semantic search to find relevant memories:

// Example request
{
  "tool": "search-memories",
  "parameters": {
    "query": "What did we discuss about machine learning?",
    "userId": "user123",
    "agentId": "agent456", // optional
    "threshold": 0.7 // optional similarity threshold
  }
}

Reading from a Stream

Retrieve content from a memory stream:

// Example request
{
  "tool": "read-stream",
  "parameters": {
    "streamId": "stream123",
    "startIndex": 0, // optional
    "endIndex": 10   // optional
  }
}

Deleting a Stream

Remove a memory stream:

// Example request
{
  "tool": "delete-stream",
  "parameters": {
    "streamId": "stream123"
  }
}

Resource-Based Access

The server also supports resource-based access to memory streams:

  • memory://{streamId} - Access a specific memory stream's content directly
  • memory:// - List all available memory streams

For example, you can use these resource URIs in compatible MCP clients to directly access memory stream content without using the specific tool endpoints.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later