memory-mcp Loading last commit info...
.dockerignore
.gitignore
README.md
compose.yaml
memory-mcp.slnx
README.md

Memory MCP

A Persistent Memory Tool with support for embeddings, designed for LLM/AI agent situations using the Model Context Protocol (MCP). It enables AI agents to store, search, and retrieve contextual information across sessions, providing long-term memory capabilities.

Features

  • Store context - Save text with tags, project names, and session IDs
  • Search memory - Find relevant past context using text search or vector embeddings
  • Session summaries - Retrieve all context stored for a specific session
  • Multiple backends - Switch between ChromaDB and MongoDB
  • HTTP API - Test and interact with memory endpoints via REST
  • MCP stdio transport - Native integration with MCP clients (Claude Desktop, Cursor, etc.)

Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   MCP Client    │────▶│  Memory MCP      │────▶│  ChromaDB /     │
│ (Claude, etc.)  │     │  Server          │     │  MongoDB        │
└─────────────────┘     └──────────────────┘     └─────────────────┘
                              │
                              ▼
                        ┌──────────────────┐
                        │  HTTP Endpoints  │
                        │  (for testing)   │
                        └──────────────────┘

Memory Backends

BackendSearch TypeEmbeddings
ChromaDBVector similaritySHA256-based (simple) or external embedding service
MongoDBText index + vectorSHA256-based (simple) with Atlas vector search ready

MCP Tools

ToolDescription
Store item in persistent memoryStore a memory entry with tags, project, and session_id
Get item(s) from persistent memorySearch through stored memory for relevant past context
Get session summaryGet a summary of all context stored in a given session

HTTP Endpoints

EndpointMethodDescription
/memory/storePOSTStore a new memory entry
/memory/searchPOSTSearch stored memories
/memory/session-summaryPOSTGet session summary

Example Requests

# Store a memory
curl -X POST http://localhost:5000/memory/store \
  -H "Content-Type: application/json" \
  -d '{
    "text": "The user is building a React application with TypeScript",
    "tags": ["react", "typescript", "frontend"],
    "project": "my-app",
    "sessionId": "session-001"
  }'

# Search memories
curl -X POST http://localhost:5000/memory/search \
  -H "Content-Type: application/json" \
  -d '{
    "searchQuery": "React application",
    "tags": ["react"],
    "project": "my-app"
  }'

# Get session summary
curl -X POST http://localhost:5000/memory/session-summary \
  -H "Content-Type: application/json" \
  -d '{
    "sessionId": "session-001"
  }'

Running Locally

Prerequisites

  • .NET 10 SDK
  • A database backend:
    • ChromaDB: docker run -p 8000:8000 ghcr.io/chroma-core/chroma:latest
    • MongoDB: docker run -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mcpuser -e MONGO_INITDB_ROOT_PASSWORD=mcppassword mongo:8

Build and Run

# Build the project
dotnet build

# Run with ChromaDB (default)
dotnet run --project memory-mcp

# Run with MongoDB
export MEMORY_BACKEND=mongo
export MONGO_CONNECTION_STRING="mongodb://mcpuser:mcppassword@localhost:27017"
export MONGO_DATABASE=mcp
export MONGO_COLLECTION=tapes
dotnet run --project memory-mcp

The HTTP API will be available at http://localhost:5000.

Testing with HTTP Client

Open memory-mcp/test/memory.http in JetBrains Rider to interactively test all endpoints.

Running with Docker Compose

# Build and start all services
docker compose up -d

# View logs
docker compose logs -f memory-mcp

This starts:

  • MongoDB on port 27017 with authentication
  • Memory MCP on port 5000, configured to use MongoDB

ChromaDB Setup

Modify compose.yaml to use ChromaDB:

services:
  memory-mcp:
    environment:
      - MEMORY_BACKEND=chromadb
    # ... rest of config

Environment Variables

VariableDescriptionDefault
MEMORY_BACKENDDatabase backend (chromadb or mongo)chromadb
MONGO_CONNECTION_STRINGMongoDB connection stringmongodb://localhost:27017
MONGO_DATABASEMongoDB database namemcp
MONGO_COLLECTIONMongoDB collection nametapes

MCP Client Configuration

Add to your MCP client configuration (e.g., Claude Desktop claude_desktop_config.json):

{
  "mcpServers": {
    "memory": {
      "command": "dotnet",
      "args": ["run", "--project", "/path/to/memory-mcp/memory-mcp"],
      "env": {
        "MEMORY_BACKEND": "mongo",
        "MONGO_CONNECTION_STRING": "mongodb://mcpuser:mcppassword@localhost:27017"
      }
    }
  }
}
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover