memory-mcp
Persistent, searchable, versioned memory for AI agents, backed by Valkey and exposed as an MCP server over HTTP.
README
memory-mcp
Persistent, searchable, versioned memory for AI agents — backed by Valkey (Redis-compatible), exposed as an MCP server over HTTP.
Works with any MCP-compatible agent: Claude Code, Cursor, VS Code, and others.
What it does
- Stores named memory entries with tags, types, and project scopes
- Tag-intersection search, type/project filtering, and substring search
- Hit tracking (entries accessed more float to the top)
- Full version history with rollback
- Prometheus metrics endpoint
- Optional bearer token auth
Quick start
cp .env.example .env
# Optional: set MEMORY_MCP_AUTH_TOKEN in .env (see Auth section)
docker compose up -d
This pulls the pre-built image from GHCR. The MCP server is now available at http://127.0.0.1:3106/mcp.
To build locally instead:
docker compose build
docker compose up -d
Using an existing Redis or Valkey
By default docker compose up -d starts a bundled Valkey container. To connect to an existing Redis or Valkey instance instead, set VALKEY_URL and start only the memory-mcp service:
# .env
VALKEY_URL=redis://your-host:6379
docker compose up -d memory-mcp
Any Redis-compatible server (Redis 6+, Valkey, KeyDB, Upstash via rediss://, etc.) works. The server uses only basic data structures: hashes, lists, and sets.
Agent setup
Copy AGENTS.md from this repo into your project root. It tells your agent how to use the memory tools, what to store, and when.
Then register the MCP server with your agent client:
Claude Code
# Without auth
claude mcp add memory --transport http http://127.0.0.1:3106/mcp
# With auth
claude mcp add memory --transport http http://127.0.0.1:3106/mcp \
--header "Authorization: Bearer your-token"
Or add manually to ~/.claude.json:
{
"mcpServers": {
"memory": {
"type": "http",
"url": "http://127.0.0.1:3106/mcp",
"headers": { "Authorization": "Bearer your-token" }
}
}
}
Cursor
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
{
"mcpServers": {
"memory": {
"url": "http://127.0.0.1:3106/mcp",
"headers": { "Authorization": "Bearer your-token" }
}
}
}
VS Code (GitHub Copilot, MCP extension)
Add to .vscode/mcp.json in your project:
{
"servers": {
"memory": {
"type": "http",
"url": "http://127.0.0.1:3106/mcp",
"headers": { "Authorization": "Bearer your-token" }
}
}
}
Omit the headers / Authorization line in any config if you are not using auth.
Configuration
Copy .env.example to .env and edit as needed.
| Variable | Default | Description |
|---|---|---|
MEMORY_MCP_BIND |
127.0.0.1 |
Interface to bind on. Use 0.0.0.0 only with AUTH_TOKEN set. |
MEMORY_MCP_HOST_PORT |
3106 |
Port exposed on the host |
MEMORY_MCP_AUTH_TOKEN |
(empty) | Bearer token for /mcp. Empty = no auth. Generate: openssl rand -hex 32 |
MEMORY_MCP_MAX_ENTRIES_WARN |
300 |
Soft cap — warns on write when exceeded |
MEMORY_MCP_MAX_VERSIONS_PER_ENTRY |
20 |
Max version snapshots per entry |
MEMORY_MCP_MEM_LIMIT |
256m |
Container memory cap |
VALKEY_IMAGE |
valkey/valkey:9.0.3 |
Valkey image to use |
Auth
By default the server runs unauthenticated. This is safe when bound to loopback (127.0.0.1) and accessed only from the local machine.
To enable auth:
# Generate a token
openssl rand -hex 32
# Add to .env
MEMORY_MCP_AUTH_TOKEN=your-generated-token
docker compose up -d
All requests to POST /mcp must then include:
Authorization: Bearer <token>
GET /health and GET /metrics are always unauthenticated.
Available tools
| Tool | Description |
|---|---|
memory_search |
Search by tags (intersection), type, project, or text substring |
memory_get |
Fetch one entry by ID (increments hit counter) |
memory_set |
Create or update an entry (versioned on every write) |
memory_list |
List entries with optional type/project filter |
memory_delete |
Delete an entry (tombstone version written first) |
memory_history |
View version history for an entry |
memory_rollback |
Restore an entry to a previous version |
memory_prune_candidates |
Surface zero-hit stale entries for review (read-only) |
Memory types
pattern, decision, reference, feedback, incident, project, entity, state
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/mcp |
if configured | MCP JSON-RPC endpoint |
GET |
/health |
none | Health check |
GET |
/metrics |
none | Prometheus metrics |
Data model
Each entry is stored as a Redis hash at mem:<id>:
| Field | Description |
|---|---|
title |
Short descriptive title |
body |
Full content |
type |
Entry type |
tags |
Comma-separated tag list |
source |
Who wrote it |
project |
Project scope (empty = cross-project) |
created |
ISO date of creation |
updated |
ISO date of last update |
hits |
Times retrieved via memory_get |
ttl |
Expiry in seconds (optional) |
Version history is stored in a Redis list at memver:<id> (newest-first, capped at MAX_VERSIONS_PER_ENTRY).
Tag, type, and project indexes are Redis sets (tag:<name>, type:<name>, project:<name>).
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。