Memory MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add --transport http memory-mcp-6634 http://localhost:8766/mcp
Required:OPENAI_API_KEYDB_PASSWORD
README.md

Persistent, self-organizing semantic memory for AI agents

memory-mcp

Persistent, self-organizing semantic memory for AI agents — served as an MCP server.


What is this?

memory-mcp is a Model Context Protocol server that gives AI agents durable, searchable memory backed by PostgreSQL and pgvector. Drop it into any MCP-compatible client (Claude Code, Cursor, Windsurf, etc.) and your agent gains the ability to remember, retrieve, and reason over information across sessions — without you managing any schema or storage logic.

What it does autonomously:

  • Chunks and embeds incoming text
  • Categorizes memories into a hierarchical taxonomy (ltree dot-paths)
  • Deduplicates against existing memories and resolves conflicts
  • Synthesizes a System Primer — a compressed, always-current summary of everything it knows — and surfaces it at session start
  • Expires stale memories via TTL and prompts for verification of aging facts

Why memory-mcp?

memory-mcp Simple vector DB LangChain / LlamaIndex memory
Schema management Automatic Manual Manual
Deduplication Semantic + LLM None None
Taxonomy Auto-assigned ltree None None
Session bootstrap System Primer Manual RAG Manual
Conflict resolution LLM-evaluated None None
Ephemeral context Built-in (TTL store) No No
Self-hostable Yes (Docker) Varies No
MCP-native Yes No No

Architecture

AI Agent (Claude Code / Cursor / Windsurf)
        │  HTTP (MCP — Streamable HTTP)
        ▼
┌──────────────────────────────────────────┐
│              server.py                    │
│  ┌─────────────────┐ ┌─────────────────┐ │
│  │ Production MCP  │ │   Admin MCP     │ │
│  │   :8766/mcp     │ │   :8767/mcp     │ │
│  └────────┬────────┘ └────────┬────────┘ │
│           │  tools/           │           │
│  ┌────────▼──────────────────▼────────┐  │
│  │  ingestion · search · context      │  │
│  │  crud · admin_tools · context_store│  │
│  └────────────────┬───────────────────┘  │
│                   │                       │
│  ┌────────────────▼───────────────────┐  │
│  │         Background Workers          │  │
│  │  Ingestion Queue · TTL Daemon       │  │
│  │  System Primer Auto-Regeneration    │  │
│  └────────────────┬───────────────────┘  │
└───────────────────┼──────────────────────┘
                    │  asyncpg
                    ▼
         PostgreSQL + pgvector
         ┌─────────────────┐
         │ memories        │  chunks, embeddings, ltree paths
         │ memory_edges    │  sequence_next, relates_to, supersedes
         │ ingestion_staging│ async job queue
         │ context_store   │  ephemeral TTL store
         └─────────────────┘
                    │
         ┌──────────▼──────────┐
         │  Backup Service     │  pg_dump → private GitHub repo
         └─────────────────────┘

Two servers, one process:

  • Production (:8766) — tools safe for the agent to call freely
  • Admin (:8767) — superset including destructive tools (delete, prune, bulk-move). Point your agent at production; use admin for maintenance.

Quickstart (Docker)

Prerequisites: Docker + Docker Compose, an OpenAI API key.

# 1. Clone
git clone https://github.com/isaacriehm/memory-mcp.git
cd memory-mcp

# 2. Configure
cp .env.example .env
$EDITOR .env   # set OPENAI_API_KEY and DB_PASSWORD at minimum

# 3. Start
docker compose up -d

# Production MCP endpoint: http://localhost:8766/mcp
# Admin MCP endpoint:      http://localhost:8767/mcp

To rebuild after code changes:

docker compose up -d --build memory-api

Connecting to an MCP Client

Claude Code

Add to your project's .claude/settings.json or ~/.claude/settings.json:

{
  "mcpServers": {
    "memory": {
      "type": "http",
      "url": "http://localhost:8766/mcp"
    }
  }
}

Or via the CLI:

claude mcp add memory --transport http http://localhost:8766/mcp

Then add this instruction to your CLAUDE.md so the agent always bootstraps memory at session start:

## Memory
At the start of every session, call `initialize_context` before anything else.
This returns your System Primer — your identity, current knowledge taxonomy, and retrieval guide.
Always consult it before answering questions about prior context.

Cursor / Windsurf

Add to your MCP settings (.cursor/mcp.json or equivalent):

{
  "mcpServers": {
    "memory": {
      "url": "http://localhost:8766/mcp"
    }
  }
}

MCP Tools

Production Tools (`:8766`)

Tool Description
initialize_context **Ca

Tools (1)

initialize_contextRetrieves the System Primer containing identity, knowledge taxonomy, and retrieval guide.

Environment Variables

OPENAI_API_KEYrequiredAPI key for OpenAI services
DB_PASSWORDrequiredPassword for the PostgreSQL database

Configuration

claude_desktop_config.json
{"mcpServers": {"memory": {"type": "http", "url": "http://localhost:8766/mcp"}}}

Try it

Initialize my memory context and summarize the current knowledge taxonomy.
Store this project documentation in my memory so I can reference it in future sessions.
What do you know about the architecture of the current project based on my stored memories?
Find all memories related to the authentication module and summarize them.

Frequently Asked Questions

What are the key features of Memory MCP?

Autonomous chunking and embedding of incoming text. Hierarchical taxonomy management using ltree dot-paths. Semantic deduplication and conflict resolution. Automatic generation of a System Primer for session bootstrapping. Ephemeral context storage with TTL-based expiration.

What can I use Memory MCP for?

Maintaining long-term project context across multiple coding sessions in Claude Code or Cursor.. Building a self-organizing knowledge base for research agents.. Managing ephemeral session data that needs to expire automatically after a set time.. Ensuring AI agents have a consistent identity and knowledge guide at the start of every interaction..

How do I install Memory MCP?

Install Memory MCP by running: git clone https://github.com/isaacriehm/memory-mcp.git && cd memory-mcp && cp .env.example .env && docker compose up -d

What MCP clients work with Memory MCP?

Memory MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Memory MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare