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.
Before installing and using the mem0 MCP Server, ensure you have:
Install the necessary dependencies:
npm install
Set your Mem0 API key as an environment variable:
export MEM0_API_KEY=your-api-key-here
Compile the TypeScript code:
npm run build
Launch the server:
npm start
Run the test client to verify that everything is working correctly:
npm test
The server provides several tools for managing memory streams:
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.
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"
}
}
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
}
}
Retrieve content from a memory stream:
// Example request
{
"tool": "read-stream",
"parameters": {
"streamId": "stream123",
"startIndex": 0, // optional
"endIndex": 10 // optional
}
}
Remove a memory stream:
// Example request
{
"tool": "delete-stream",
"parameters": {
"streamId": "stream123"
}
}
The server also supports resource-based access to memory streams:
memory://{streamId}
- Access a specific memory stream's content directlymemory://
- List all available memory streamsFor example, you can use these resource URIs in compatible MCP clients to directly access memory stream content without using the specific tool endpoints.
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.