memory-mcp
A persistent, conflict-aware memory MCP server for AI coding assistants (Cursor, Claude Code).
README
memory-mcp
A persistent, conflict-aware memory MCP server for AI coding assistants (Cursor, Claude Code).
Every AI coding session starts from zero. This MCP server gives the AI a queryable memory store that survives across sessions - and unlike append-only tools, it detects when a new fact contradicts an older one and automatically invalidates the stale memory instead of letting both exist.
How it works
When you store a memory like "we switched from Postgres to SQLite":
- The content is embedded (OpenAI
text-embedding-3-small) - Vector search finds similar active memories
- Claude Haiku checks each candidate - does this contradict the new fact?
- Confirmed conflicts get invalidated (
valid_to = now) - never deleted - The new memory is inserted as currently true
- A supersession link is recorded so the history is traceable
Old facts are never deleted. You can query what was true at any point in time.
Tools
| Tool | Description |
|---|---|
store_memory |
Save a fact about the project. Detects and invalidates conflicts automatically. |
retrieve_context |
Hybrid vector + keyword search over currently-true memories. |
query_history |
Point-in-time query - what was true at a given timestamp? |
list_conflicts_resolved |
Audit log of every invalidation and why. |
Stack
- TypeScript + Node.js 18
- PostgreSQL 16 + pgvector (HNSW index, cosine similarity)
- OpenAI
text-embedding-3-small(1536 dims) - Anthropic Claude Haiku (conflict detection)
- MCP SDK (stdio transport)
- Zod (input validation)
Setup
# 1. Start Postgres
docker compose up -d
# 2. Install dependencies
npm install
# 3. Copy and fill in API keys
cp .env.example .env
# edit .env - add OPENAI_API_KEY and ANTHROPIC_API_KEY
# 4. Run migrations
npm run migrate
# 5. Start the server
npm run dev
Register in Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"developer-memory": {
"command": "node",
"args": ["/absolute/path/to/my-memory-mcp/dist/index.js"]
}
}
}
Build first: npm run build
Key design decisions
Invalidate, never delete - setting valid_to instead of deleting preserves history. Point-in-time queries (query_history) would be impossible otherwise.
Conflict similarity threshold: 0.45 - the spec suggested 0.75, but measured against labeled contradiction pairs on text-embedding-3-small, true conflicts score 0.50 to 0.82 cosine similarity. At 0.75 the candidate filter silently drops most real conflicts before the LLM sees them. 0.45 catches them all.
RRF over score averaging - cosine similarity and ts_rank live on incomparable scales. Reciprocal Rank Fusion uses only rank positions, so the two search legs fuse cleanly without normalization guesswork.
LLM default to no-conflict - if Claude returns an unparseable response, the code treats it as no conflict. A false negative leaves a stale memory (recoverable). A false positive deletes a true fact (worse).
Project structure
src/
├── index.ts entry point
├── config.ts env → typed config
├── types.ts shared interfaces
├── db.ts MemoryStore + migrations + vector/keyword search
├── embeddings.ts OpenAI embeddings client
├── memory.ts conflict detection + invalidation + ingestion pipeline
├── retrieval.ts RRF hybrid retrieval
└── server.ts MCP server + 4 tool handlers
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.