一个使用 mem0 的内存系统,用于 AI 应用程序。可作为一台立即可用的 MCP 服务器,为 AI 代理提供长期内存。
A Model Context Protocol (MCP) server that integrates with Mem0.ai to provide persistent memory capabilities for LLMs. It allows AI agents to store and retrieve information across sessions.
This server uses the mem0ai Node.js SDK for its core functionality.
add_memory: Stores a memory from text content or structured message arrays.content (string) or messages (array of role/content objects), userId (string), runId / sessionId (string), agentId (string), appId (string), metadata (object), infer (boolean), customInstructions (string), waitForCompletion (boolean, default: true), timeoutMs (number, default: 15000)waitForCompletion: false to get the eventId immediately.search_memories: Searches memories using semantic and BM25 hybrid filters.query (string), userId (string), runId / sessionId (string), agentId (string), appId (string), filters (object), threshold (number), topK (number), rerank (boolean), referenceDate (string)filters block to prevent API validation errors.search_memory: Backward-compatible alias for search_memories.list_memories: Paginated listing of memory records scoped by identifiers.userId (string), runId / sessionId (string), agentId (string), appId (string), filters (object), page (number), pageSize (number)get_memory: Retrieves a single memory record by its ID.memoryId (string)update_memory: Modifies the text or metadata of an existing memory.memoryId (string), text (string), metadata (object)delete_memory: Deletes a specific memory record by ID.memoryId (string)get_memory_history: Retrieves the audit trail of memory revisions (cloud only).memoryId (string)get_memory_capabilities: Exposes the feature matrix and support flags of the active backend storage mode.batch_update_memories: Performs bulk updates of text contents for multiple memories (cloud only).updates (array of { memoryId: string, text: string } objects)batch_delete_memories: Performs bulk deletions of multiple memories.memoryIds (array of strings), confirm (boolean, must be true to execute)rate_memory: Submits quality feedback evaluation for a memory record (cloud only).memoryId (string), feedback (string: positive, negative, very_negative), reason (string, optional)get_memory_event: Manually retrieves details of a specific background event job (cloud only).eventId (string)list_memory_events: Lists history logs of background memory processing events (cloud only).page (number), pageSize (number)create_memory_export: Initiates an asynchronous memory export query job (cloud only).schema (object), filters (object, optional), exportInstructions (string, optional)get_memory_export: Retrieves status and download metadata of a memory export job (cloud only).exportId (string)This server supports three storage modes:
Cloud Storage Mode ☁️ (Recommended for production)
MEM0_API_KEY environment variable)Supabase Storage Mode ️ (Recommended for self-hosting)
SUPABASE_URL and SUPABASE_KEY environment variables)OPENAI_API_KEY environment variable) for embeddingsLocal Storage Mode (Development/testing only)
OPENAI_API_KEY environment variable)You can run this server in three main ways:
To install Mem0 Memory Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @pinkpixel-dev/mem0-mcp-server --client claudeInstall the package globally and use the mem0-mcp command:
npm install -g @pinkpixel/mem0-mcpAfter global installation, you can run the server directly:
mem0-mcpConfigure your MCP client to use the global command:
{
"mcpServers": {
"mem0-mcp": {
"command": "mem0-mcp",
"args": [],
"env": {
"MEM0_API_KEY": "YOUR_MEM0_API_KEY_HERE",
"DEFAULT_USER_ID": "user123",
"DEFAULT_AGENT_ID": "your-agent-id",
"DEFAULT_APP_ID": "your-app-id"
}
}
}
}{
"mcpServers": {
"mem0-mcp": {
"command": "mem0-mcp",
"args": [],
"env": {
"SUPABASE_URL": "YOUR_SUPABASE_PROJECT_URL",
"SUPABASE_KEY": "YOUR_SUPABASE_ANON_KEY",
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"DEFAULT_USER_ID": "user123",
"DEFAULT_AGENT_ID": "your-agent-id",
"DEFAULT_APP_ID": "your-app-id"
}
}
}
}{
"mcpServers": {
"mem0-mcp": {
"command": "mem0-mcp",
"args": [],
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"DEFAULT_USER_ID": "user123"
}
}
}
}npx (Recommended for occasional use)Configure your MCP client (e.g., Claude Desktop, Cursor, Cline, Roo Code, etc.) to run the server using npx:
{
"mcpServers": {
"mem0-mcp": {
"command": "npx",
"args": [
"-y",
"@pinkpixel/mem0-mcp"
],
"env": {
"MEM0_API_KEY": "YOUR_MEM0_API_KEY_HERE",
"DEFAULT_USER_ID": "user123",
"DEFAULT_AGENT_ID": "your-agent-id",
"DEFAULT_APP_ID": "your-app-id"
}
}
}
}{
"mcpServers": {
"mem0-mcp": {
"command": "npx",
"args": [
"-y",
"@pinkpixel/mem0-mcp"
],
"env": {
"SUPABASE_URL": "YOUR_SUPABASE_PROJECT_URL",
"SUPABASE_KEY": "YOUR_SUPABASE_ANON_KEY",
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"DEFAULT_USER_ID": "user123",
"DEFAULT_AGENT_ID": "your-agent-id",
"DEFAULT_APP_ID": "your-app-id"
}
}
}
}{
"mcpServers": {
"mem0-mcp": {
"command": "npx",
"args": [
"-y",
"@pinkpixel/mem0-mcp"
],
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"DEFAULT_USER_ID": "user123"
}
}
}
}Note: This method requires you to git clone the repository first.
Clone the repository, install dependencies, and build the server:
git clone https://github.com/pinkpixel-dev/mem0-mcp
cd mem0-mcp
npm install
npm run buildThen, configure your MCP client to run the built script directly using node:
{
"mcpServers": {
"mem0-mcp": {
"command": "node",
"args": [
"/absolute/path/to/mem0-mcp/build/index.js"
],
"env": {
"MEM0_API_KEY": "YOUR_MEM0_API_KEY_HERE",
"DEFAULT_USER_ID": "user123",
"DEFAULT_AGENT_ID": "your-agent-id",
"DEFAULT_APP_ID": "your-app-id"
}
}
}
}{
"mcpServers": {
"mem0-mcp": {
"command": "node",
"args": [
"/absolute/path/to/mem0-mcp/build/index.js"
],
"env": {
"SUPABASE_URL": "YOUR_SUPABASE_PROJECT_URL",
"SUPABASE_KEY": "YOUR_SUPABASE_ANON_KEY",
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"DEFAULT_USER_ID": "user123",
"DEFAULT_AGENT_ID": "your-agent-id",
"DEFAULT_APP_ID": "your-app-id"
}
}
}
}{
"mcpServers": {
"mem0-mcp": {
"command": "node",
"args": [
"/absolute/path/to/mem0-mcp/build/index.js"
],
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"DEFAULT_USER_ID": "user123"
},
"disabled": false,
"alwaysAllow": [
"add_memory",
"search_memory",
"delete_memory"
]
}
}
}Important Notes:
/absolute/path/to/mem0-mcp/ with the actual absolute path to your cloned repositorybuild/index.js file, not the src/index.ts fileIf you choose to use Supabase storage mode, you'll need to set up your Supabase database with the required table.
Run these SQL commands in your Supabase SQL Editor:
…Add these to your MCP configuration:
SUPABASE_URL: Your Supabase project URL (e.g., https://your-project.supabase.co)SUPABASE_KEY: Your Supabase anon keyOPENAI_API_KEY: Your OpenAI API key (for embeddings)✅ Persistent Storage - Data survives server restarts ✅ Free Tier Available - Generous free tier for development ✅ Self-Hostable - Can run your own Supabase instance ✅ Scalable - Grows with your needs ✅ SQL Access - Direct database access for advanced queries ✅ Real-time Features - Built-in real-time subscriptions
The server uses four key parameters to organize and scope memories:
userId - Identifies the user (required)agentId - Identifies the LLM/agent making the tool call (optional)appId - Identifies the user's project/application - this controls project scope! (optional)sessionId - Identifies the conversation session (maps to run_id in Mem0) (optional)The MCP server supports environment variable fallbacks for user identification and project settings:
DEFAULT_USER_ID: Fallback user ID when not provided in tool callsDEFAULT_AGENT_ID: Fallback agent ID for identifying the LLM/agentDEFAULT_APP_ID: Fallback app ID for project scoping// You暂无开放 Issues,或尚未同步最近议题。