mem0-custom-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mem0-custom-mcpRemember that my birthday is Dec 10"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Mem0 Custom MCP Server
A custom Model Context Protocol (MCP) server that connects to self-hosted Mem0 API instances. Enables Claude Code to use your own Mem0 deployment for memory management.
Why This Exists
The official @mem0/mcp-server and community @pinkpixel/mem0-mcp packages only support:
Mem0's cloud platform (requires
MEM0_API_KEY)Supabase backend
Local storage
Neither supports connecting to custom self-hosted Mem0 API endpoints.
This custom MCP server bridges that gap by providing a wrapper around your self-hosted Mem0 API.
Related MCP server: Claude Memory
Features
✅ Connects to self-hosted Mem0 API at custom endpoints
✅ Implements MCP stdio protocol for Claude Code integration
✅ Supports all core Mem0 operations:
add_memory- Store new memoriessearch_memories- Semantic search through memoriesget_memories- Retrieve all memories for a userdelete_memory- Delete specific memories
✅ Environment variable configuration
✅ Full TypeScript implementation with type safety
✅ 120-second timeout for slow Mem0 API responses (handles LLM processing delays)
Installation
From GitHub (Recommended for now)
# Clone the repository
git clone https://github.com/emasoudy/mem0-custom-mcp.git
cd mem0-custom-mcp
# Install dependencies
npm install
# Build the project
npm run buildFrom npm (Future - when published)
# This will be available after npm publish
npm install -g mem0-custom-mcpConfiguration
The server is configured via environment variables:
MEM0_API_URL- Your Mem0 API endpoint (default:http://localhost:8888)DEFAULT_USER_ID- Default user ID for memory operations (default:default)
Example configurations:
Local:
http://localhost:8888Docker:
http://host.docker.internal:8888Remote/VPN:
http://your-server-ip:8888
Claude Code Configuration
You can configure this MCP server at either user level (available in all projects) or project level (specific project only).
Option 1: Using CLI (Recommended)
User-level (available everywhere):
claude mcp add mem0 \
--scope user \
--command node \
--arg "/absolute/path/to/mem0-custom-mcp/dist/index.js" \
--env MEM0_API_URL=http://localhost:8888 \
--env DEFAULT_USER_ID=defaultProject-level (specific project only):
cd /path/to/your/project
claude mcp add mem0 \
--scope project \
--command node \
--arg "/absolute/path/to/mem0-custom-mcp/dist/index.js" \
--env MEM0_API_URL=http://localhost:8888 \
--env DEFAULT_USER_ID=defaultOption 2: Manual Configuration
User-level - Edit ~/.claude.json:
{
"mcpServers": {
"mem0": {
"type": "stdio",
"command": "node",
"args": [
"/absolute/path/to/mem0-custom-mcp/dist/index.js"
],
"env": {
"MEM0_API_URL": "http://localhost:8888",
"DEFAULT_USER_ID": "default"
}
}
}
}Project-level - Edit .claude.json in your project root:
{
"projects": {
"your-project-path": {
"mcpServers": {
"mem0": {
"type": "stdio",
"command": "node",
"args": [
"/absolute/path/to/mem0-custom-mcp/dist/index.js"
],
"env": {
"MEM0_API_URL": "http://localhost:8888",
"DEFAULT_USER_ID": "default"
}
}
}
}
}
}Verify installation:
claude mcp list
# Should show "mem0" in the listDevelopment
npm run build- Compile TypeScript to JavaScriptnpm run dev- Build and run the servernpm start- Run the compiled server
Available Tools
add_memory
Store a new memory in Mem0.
Parameters:
content(required) - The content to storeuser_id(optional) - User ID (defaults to env DEFAULT_USER_ID)metadata(optional) - Additional metadata object
search_memories
Search memories using semantic search.
Parameters:
query(required) - Search query stringuser_id(optional) - User ID (defaults to env DEFAULT_USER_ID)limit(optional) - Maximum results (default: 10)
get_memories
Retrieve all memories for a user.
Parameters:
user_id(optional) - User ID (defaults to env DEFAULT_USER_ID)limit(optional) - Maximum results (default: 100)
delete_memory
Delete a specific memory by ID.
Parameters:
memory_id(required) - ID of the memory to delete
Architecture
This MCP server acts as a bridge between Claude Code and your self-hosted Mem0 API instance:
┌─────────────────────────┐
│ Claude Code │
└────────────┬────────────┘
│ MCP stdio protocol
│
┌────────────▼────────────┐
│ mem0-custom-mcp │ ← This MCP server (Node.js)
│ (MCP wrapper) │
└────────────┬────────────┘
│ HTTP REST API (localhost:8888 or custom URL)
│
┌────────────▼────────────┐
│ Self-Hosted Mem0 API │ ← Mem0 API server (Python/FastAPI)
│ (your-server:8888) │ Handles memory operations
└────────────┬────────────┘
│
┌────┴─────┐
│ │
┌────▼───┐ ┌──▼──────┐
│PGVector│ │ Neo4j │ ← Databases managed by Mem0 API
│(Vector)│ │ (Graph) │
└────────┘ └─────────┘Flow:
Claude Code calls MCP tools (add_memory, search_memories, etc.)
mem0-custom-mcp receives requests via MCP stdio protocol
mem0-custom-mcp forwards to Mem0 API via HTTP
Mem0 API processes requests and manages PostgreSQL/Neo4j databases
Results flow back through the chain to Claude Code
Note: This server does NOT directly access PostgreSQL or Neo4j. It communicates only with the Mem0 API endpoint, which handles all database operations.
Mem0 API Endpoints Used
This MCP server uses the following Mem0 API endpoints:
POST /v1/memories- Add new memoryBody:
{"messages": [{"role": "user", "content": "..."}], "user_id": "...", "metadata": {}}
GET /v1/memories/{user_id}- Get all memories for a userPath parameter: user_id
POST /v1/memories/search- Search memories with semantic searchBody:
{"query": "...", "user_id": "...", "limit": 10}
DELETE /v1/memories/{memory_id}- Delete a specific memoryPath parameter: memory_id
Troubleshooting
Server won't start
Check debug logs in ~/.claude/debug/ for error messages.
Common issues:
Mem0 API not accessible (check VPN connection)
Invalid endpoint URL
Port conflicts
Connection timeout
The MCP server has a built-in 120-second timeout for Mem0 API requests. This accommodates the time needed for:
OpenAI API calls to generate embeddings
LLM processing to extract entities and relationships
Database operations (PostgreSQL + Neo4j)
Typical memory creation takes 30-60 seconds when using GPT-5-mini.
If you need to adjust the timeout, modify src/index.ts line 59:
const timeoutId = setTimeout(() => controller.abort(), 120000); // 2 minutesTool errors
Verify your Mem0 API is running:
# For local deployment
curl http://localhost:8888/health
# For remote/VPN deployment
curl http://your-server-ip:8888/healthExpected response:
{"status":"ok","db_connected":true,"stores":{"vector":"postgresql","graph":"neo4j"}}Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development
# Clone and setup
git clone https://github.com/emasoudy/mem0-custom-mcp.git
cd mem0-custom-mcp
npm install
# Make changes to src/index.ts
# Build and test
npm run build
npm run dev # Build and runChangelog
See CHANGELOG.md for version history.
License
MIT License - see LICENSE for details.
Acknowledgments
Built for the Model Context Protocol
Works with Mem0 self-hosted instances
Designed for Claude Code
Support
Available Tools
4 toolsadd_memoryB
Store a new memory in Mem0
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The content to store as a memory | |
| user_id | No | User ID (defaults to env DEFAULT_USER_ID) | |
| metadata | No | Optional metadata |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose behavioral traits itself. It only states that it stores a memory, but doesn't clarify whether it overwrites, appends, requires specific permissions, or what side effects occur. The word 'new' implies no overwriting but leaves other behaviors undisclosed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no filler, but it is almost too terse, offering minimal substance. It is concise and front-loaded, more efficient than verbose, though it trades away helpful context.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has a complete schema and no output schema, the description covers only the basic action. It lacks usage context and behavioral caveats, but the schema mitigates some gaps. Overall, it is a minimally viable description for a straightforward create operation, but leaves room for improvement.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema covers all three parameters with descriptions (content, user_id, metadata), achieving 100% schema coverage. The description adds no additional parameter semantics, so the baseline score of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses the specific verb 'Store' targeting 'a new memory in Mem0', clearly distinguishing this write operation from sibling tools (search_memories, get_memories, delete_memory). The phrase 'new memory' confirms an insert action, leaving no ambiguity about its core function.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided regarding when to use this tool versus alternatives. The description does not mention that this is for creating memories, while search/get/delete are for reading/removing, nor does it note any prerequisites or edge cases like duplicate handling.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
delete_memoryB
Delete a specific memory by ID
| Name | Required | Description | Default |
|---|---|---|---|
| memory_id | Yes | ID of the memory to delete |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It only states the basic action without mentioning permanence, error behavior for nonexistent IDs, permissions, or side effects. This is a significant gap for a delete operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that is front-loaded with the action and object. Every word contributes meaning, with zero waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-parameter tool with no annotations and no output schema, the description is minimally adequate but lacks details about deletion behavior (e.g., success criteria, error cases). It is not misleading but leaves important behavioral context unspecified.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already provides 100% coverage for the single parameter (memory_id) with a clear description. The tool description adds no additional semantic information beyond what the schema states, so the baseline score of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states a specific action ('Delete') on a specific resource ('a specific memory') with a clear identifier ('by ID'). This distinguishes it from sibling tools like add_memory (create), search_memories (query), and get_memories (retrieve).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives, nor any exclusions or prerequisites beyond the implicit requirement of a memory ID. The description implies usage but offers no explicit context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_memoriesA
Retrieve all memories for a user
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results (default: 100) | |
| user_id | No | User ID (defaults to env DEFAULT_USER_ID) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full responsibility for behavioral disclosure. It only states the action without mentioning pagination, default limits, memory volume, ordering, or response format. For a retrieval tool that may return large datasets, this lack of behavioral context is a significant gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence with clear verb-object structure. Every word earns its place, and the information is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple with two optional parameters, but with no annotations and no output schema, the description is relatively thin. It lacks context about return format, behavior with large result sets, or how limit interacts with 'all memories'. Additional behavioral notes would improve completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already describes both parameters (limit and user_id) with 100% coverage. The description adds no additional parameter semantics, so the baseline score of 3 is appropriate since the schema handles the details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Retrieve') and resource ('all memories for a user'), clearly distinguishing this from sibling tools like search_memories (focused retrieval) and add/delete memory operations. The word 'all' explicitly communicates the bulk scope.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'all memories' implies a bulk retrieval use case, but the description does not explicitly mention when to prefer this over search_memories or other alternatives. No exclusions or prerequisites are stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_memoriesC
Search for memories using semantic search
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results (default: 10) | |
| query | Yes | Search query | |
| user_id | No | User ID (defaults to env DEFAULT_USER_ID) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry behavioral disclosure. It only states 'semantic search' and omits critical behavioral traits such as result ordering, pagination, prerequisites (like user_id), performance implications, or read-only status.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that starts with the action verb and resource, wasting no words. It is optimally structured for quick comprehension.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema, the description should explain return values and search behavior, but it does not. It also lacks details on default limit, user_id handling, and ranking semantics, making it incomplete for a search tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema includes descriptions for all three parameters (query, limit, user_id), providing 100% coverage. The description adds no extra parameter meaning beyond the schema, so it earns the baseline score of 3.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool performs a semantic search over memories, with a specific verb and resource. It distinguishes from sibling tools like get_memories by highlighting 'semantic search', though it could more explicitly contrast with them.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives like get_memories or add_memory. The description only defines what it does, leaving the agent without directional context for selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v1.1.0- First observed
add_memory - First observed
delete_memory - First observed
get_memories - First observed
search_memories
TDQS
Scored across 4 tools
Each tool serves a clearly distinct purpose: adding, searching, retrieving all, and deleting memories. The descriptions clearly differentiate search from retrieval, so there is no ambiguity.
All tools follow a consistent verb_noun pattern (add, search, get, delete + memory/memories). The singular/plural variation is minor and does not hinder predictability.
With only 4 tools, the server is well-scoped and focused on the fundamental memory operations. Each tool is essential and there is no bloat.
The set covers the core lifecycle of memories (create, read, search, delete), but lacks an update operation. This is a minor gap for a memory store, making the surface slightly incomplete.
Maintenance
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Cloud-hosted MCP server for durable AI memory
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
An MCP memory server. One memory your agents share — across models, devices and apps.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server that gives Claude Code cross-session memory persisted to a plain .claude-memory.md file in your repo.MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides Claude Code with persistent memory across sessions, including session checkpoints, image persistence, and bidirectional sync with claude.ai projects.1MIT
- AlicenseNot gradedqualityDmaintenanceA MCP server that gives Claude Code and other AI assistants long-term memory by automatically extracting technical knowledge from conversations and retrieving relevant experiences in future sessions.6 npmMIT
- AlicenseAqualityAmaintenanceA server that wraps a self-hosted mem0 REST API as MCP tools for Claude Desktop and Claude Code, enabling memory operations such as adding, searching, and managing memories via natural language.61MIT