Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mem0/mcp-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Mem0 Memory MCP Server
A Model Context Protocol (MCP) server that provides memory storage and retrieval capabilities using Mem0. This tool allows you to store and search through memories, making it useful for maintaining context and making informed decisions based on past interactions.
Features
- Store memories with user-specific context
- Search through stored memories with relevance scoring
- Simple and intuitive API
- Built on the Model Context Protocol
- Automatic error handling
- Support for multiple user contexts
Installation
Running with npx
env MEM0_API_KEY=your-api-key-here npx -y @mem0/mcp
Manual Installation
npm install -g @mem0/mcp
Configuration for AI Tools
Running on Cursor
Configuring Cursor 🖥️
To configure Mem0 MCP in Cursor:
- Open Cursor Settings
- Go to Features > MCP Servers
- Click "+ Add New MCP Server"
- Enter the following:
- Name: "mem0-mcp" (or your preferred name)
- Type: "command"
- Command:
env MEM0_API_KEY=your-api-key-here npx -y @mem0/mcp
To configure Mem0 MCP using JSON configuration:
{
"mcpServers": {
"mem0-mcp": {
"command": "npx",
"args": ["-y", "@mem0/mcp"],
"env": {
"MEM0_API_KEY": "YOUR-API-KEY-HERE"
}
}
}
}
Running on VS Code
Add the following JSON block to your User Settings (JSON) file in VS Code:
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "apiKey",
"description": "Mem0 API Key",
"password": true
}
],
"servers": {
"mem0-memory": {
"command": "npx",
"args": ["-y", "@mem0/mcp"],
"env": {
"MEM0_API_KEY": "${input:apiKey}"
}
}
}
}
}
Available Tools
1. Add Memory Tool (add-memory)
Store new memories with user-specific context.
{
"name": "add-memory",
"arguments": {
"content": "User prefers dark mode interface",
"userId": "user123"
}
}
2. Search Memories Tool (search-memories)
Search through stored memories to retrieve relevant information.
{
"name": "search-memories",
"arguments": {
"query": "What are the user's interface preferences?",
"userId": "user123"
}
}
Response Format
Add Memory Response
{
"content": [
{
"type": "text",
"text": "Memory added successfully"
}
],
"isError": false
}
Search Memory Response
{
"content": [
{
"type": "text",
"text": "Memory: User prefers dark mode interface\nRelevance: 0.95\n---\nMemory: User mentioned liking minimal UI\nRelevance: 0.82\n---"
}
],
"isError": false
}
Configuration
Environment Variables
MEM0_API_KEY
: Your Mem0 API key (required)- Required for operation
- Can be obtained from Mem0 Dashboard
Development
Prerequisites
- Node.js (v14 or higher)
- A Mem0 API key
Setup
- Clone the repository
- Install dependencies:
npm install
- Create a
.env
file in the root directory and add your Mem0 API key:
MEM0_API_KEY=your-api-key-here
Running Development Server
To run the server in development mode:
npm run dev
Building
To build the project:
npm run build
Starting the Server
To start the server after building:
npm start
Error Handling
The server includes error handling for:
- API connection issues
- Invalid memory operations
- Search errors
- Authentication failures
Example error response:
{
"content": [
{
"type": "text",
"text": "Error: Failed to search memories: Invalid API key"
}
],
"isError": true
}
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT