The MCP Memory Server implements long-term memory capabilities for AI assistants following mem0 principles. It leverages PostgreSQL with pgvector for efficient vector similarity search, allowing assistants to store, retrieve, and search memories semantically.
Before installation, ensure you have:
PostgreSQL 14+ with pgvector extension:
CREATE EXTENSION vector;
Node.js 16+
Install dependencies:
npm install
Configure environment variables:
cp .env.sample .env
Configure your .env
file with appropriate settings:
# With username/password
DATABASE_URL="postgresql://username:password@localhost:5432/mcp_memory"
PORT=3333
# Local development with peer authentication
DATABASE_URL="postgresql:///mcp_memory"
PORT=3333
Initialize the database:
npm run prisma:migrate
Start the server:
npm start
For development with auto-reload:
npm run dev
Add the memory server to your Cursor configuration by modifying ~/.cursor/mcp.json
:
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/path/to/your/memory/src/server.js"
]
}
}
}
Replace /path/to/your/memory
with the actual path to your memory server installation. For example:
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/Users/username/workspace/memory/src/server.js"
]
}
}
}
The server will start automatically when Cursor launches. Verify it's working by visiting http://localhost:3333/mcp/v1/health
.
Connect to the server's event stream:
GET /mcp/v1/sse
Query parameters:
subscribe
: Comma-separated list of events to subscribe to (optional)Available events:
connected
: Sent on initial connectionmemory.created
: Sent when new memories are createdmemory.updated
: Sent when existing memories are updatedPOST /mcp/v1/memory
Content-Type: application/json
{
"type": "learning",
"content": {
"topic": "Express.js",
"details": "Express.js is a web application framework for Node.js"
},
"source": "documentation",
"tags": ["nodejs", "web-framework"],
"confidence": 0.95
}
GET /mcp/v1/memory/search?query=web+frameworks&type=learning&tags=nodejs
GET /mcp/v1/memory?type=learning&tags=nodejs,web-framework
GET /mcp/v1/health
All API responses follow the standard MCP format:
Success response:
{
"status": "success",
"data": {
// Response data
}
}
Error response:
{
"status": "error",
"error": "Error message"
}
Each memory entry contains:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "memory" '{"command":"node","args":["/path/to/your/memory/src/server.js"]}'
See the official Claude Code MCP documentation for more details.
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 > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/path/to/your/memory/src/server.js"
]
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/path/to/your/memory/src/server.js"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect