mcp-agents-memory
Long-term, time-ordered memory for AI agents β a shared memory pool that persists across sessions and machines, modeled on human memory.
Multiple agents (Claude Code, Codex, Gemini CLI, Grok, Antigravity, β¦) share one memory pool, accumulating and recalling memories in chronological order. Each platform/model gets its own view automatically, while project tags let collaborators see each other's relevant context.
π°π· νκ΅μ΄ README β
README.ko.mdDesign rationale and decisions βRESPEC.md
Motivation
- supermemory β a universal, semantic-graph memory layer
- Hermes Agent β
MEMORY.md-style self-updating memory, skills & rules
This project aims to combine the strengths of both: supermemory's recall and Hermes' self-curation, without their weaknesses (machine-locked storage, opaque mutation).
Core design
- Time-ordered, like human memory β every turn is stored raw in chronological order. No
fact_typetaxonomy. Older memories are summarized by tag and archived (soft-delete, never destroyed). - Automatic per-model separation β the
agent_platform/agent_modelcolumns alone separate memories per model. No manual categories. - Two asynchronous tracks β a Hot Path (instant raw INSERT, fast response) and a Cold Path (a background "librarian" that tags, embeds, clusters, and curates on a 1-minute / 5-message cadence).
- Tag-centric recall β recent days as raw text, older history as tag-centric summaries. Anything older is retrievable from the archive by date / tag / keyword.
Architecture
Two asynchronous tracks
βββββββββββββββββββ ββββββββββββββββββββββββββββ
β Agent β β MCP Server β
β (Claude Code, β ββββΆ β βΆ Hot Path (instant save)β βββΆ memory table
β Codex, ...) β ββββββββββββββββββββββββββββ (raw + role + platform/model)
βββββββββββββββββββ β
β rows with NULL p_tag/d_tag/embedding accumulate
βΌ
ββββββββββββββββββββββββββββββββ
β Cold Path (1 min / 5 msgs) β
β ββ Tagger β p_tag, d_tag β
β ββ Embedder β embedding β
β ββ Librarian β user profile β
β ββ Clusterer β tag summaries β
β ββ AliasPromoter β tag merges β
ββββββββββββββββββββββββββββββββ
The Cold Path's LLM roles (tagger / librarian / clusterer / project-alias judge) all run on a single shared backend β local Qwen3-14B via llama.cpp, or a cloud fallback (see Cold Path LLM backend).
Data model
memory β raw, time-ordered conversation log (single table, soft-delete archive)
users β core facts the Librarian promotes out of memory
project_tags β project tags, grown dynamically by the Cold Path
Multi-machine β server / client
When several machines share one database, the Cold Path (tagging / profiling / clustering / alias judging) must run on exactly one of them β otherwise machines double-process the same rows and double the cloud cost. The same package splits roles purely by config:
- Client: the MCP server your editor spawns is the terminal. Just add
COLD_PATH_ENABLED=false. - Server: run the Cold Path decoupled from the editor's lifetime, as a standalone daemon (processes even when no editor is open):
The daemon is a singleton via a PostgreSQL advisory lock β no matter how many instances exist, only the one holding the lock processes (dedup + automatic failover).mcp-agents-memory coldpath # Cold Path worker only, no MCP server (systemd recommended) - Buzz (optional):
mcp-agents-memory buzz-ingestcopies chat messages from the Buzz rooms a given identity is a member of into memory, one row per message, through the officialbuzzCLI. It also strips the quoted history from captured Buzz turns once every quoted message exists as a row (the original stays inraw_message;--no-recleanturns this off). Run it from a timer; see CHANGELOG 0.9.20β0.9.21 for the settings.
Cold Path LLM backend
Point LOCAL_LLM_BASE_URL at any OpenAI-compatible endpoint to use local / self-hosted inference (llama.cpp, ollama, β¦). If unset, a cloud model is used; LOCAL_GROK_FALLBACK=true falls back to Grok when local inference fails.
e.g. serve
Qwen3-14Bwith llama.cppllama-serveron an AMD/NVIDIA GPU and setLOCAL_LLM_BASE_URL=http://localhost:8080/v1β Cold Path cloud cost β $0. (Ajson_schemagrammar with thinking disabled guarantees valid JSON.)
Memory load rules
- Short-term: recent 2β3 days raw, or ~8000 tokens (whichever comes first). Token count is char-approximate (
chars / 1.7) to protect Hot Path latency. Window is env-tunable. - Model separation: by default, only memories with the same
agent_platform/agent_model. Ap_tagmatch (same project) pulls in collaborating agents' memories too. - Archive search: on a user cue ("a few days agoβ¦") or when older context is needed, retrieve from the archive by date / tag / keyword.
- Search fallback: when semantic (cosine) results fall below threshold, fall back to
ILIKE(env-tunable, starts at 0.3).
Tools
The server exposes 4 tools. Most clients only ever need the first three; save_message is a fallback.
memory_startup β session boot brief
Returns a markdown brief (recent conversations, active projects, user profile) so a new session picks up where the last left off. On supported clients it is injected automatically at connect; call it explicitly to refresh mid-session.
search_memory β unified read / search
search_memory({
query?: string, // semantic search (vector + ILIKE fallback)
p_tag?: string, // restrict to a project
date_range?: string, // e.g. "2026-04-29..", "last_week"
role?: 'user' | 'assistant',
agent_platform?: string, // restrict to a platform; omit or '*' = all
device_scope?: 'local' | 'global', // 'global' (default) = all machines; 'local' = this one
limit?: number, // default 10, max 50
include_archived?: boolean,
})
"When you don't remember, reach for this one." Agents just vary the parameters.
manage_knowledge β unified write / edit
manage_knowledge({
action: 'add' | 'update' | 'remove',
target: 'sub_profile' | 'memory',
content: string,
})
Use when the user explicitly says "remember this" / "forget that".
target='memory'= force-remember (is_pinned=true, importance bump, archive-exempt).manage_knowledgeskips the Cold Path and syncs tag + embedding immediately, so the memory is searchable the instant you say "got it".
save_message β transcript fallback
For platforms that don't auto-capture transcripts, the agent calls this each turn to persist the message. On auto-capturing clients (see below) it must not be called β that would duplicate rows.
Automatic capture
Auto-injection of the startup brief / auto-capture depends on the client, not the transport β some clients (e.g. desktop/web) don't expose those hooks, so they fall back to explicit tool calls.
Tech stack
Environment variables
See .env.example for the full, annotated list. The essentials:
# DB
DB_HOST=... DB_PORT=5432 DB_USER=... DB_PASS=... DB_NAME=...
# Keys
OPENAI_API_KEY=... # embedding (required)
XAI_API_KEY=... # Grok (Cold Path cloud + local fallback)
# Cold Path LLM backend β OpenAI-compatible endpoint for local inference (omit β cloud)
LOCAL_LLM_BASE_URL=http://localhost:8080/v1
LOCAL_GROK_FALLBACK=true
TAGGER_PROVIDER=local TAGGER_MODEL=qwen3-14b
LIBRARIAN_PROVIDER=local LIBRARIAN_MODEL=qwen3-14b
LIBRARIAN_ENABLED=true
# Hot/Cold path control
COLD_PATH_ENABLED=true # false = client terminal (no Cold Path); only the server is true
COLD_PATH_INTERVAL_SEC=60
COLD_PATH_BATCH_SIZE=5
# Memory load tunables
SHORT_TERM_DAYS=3
SHORT_TERM_TOKEN_LIMIT=8000
SEARCH_FALLBACK_THRESHOLD=0.3
# Agent identity (caller self-reports)
AGENT_PLATFORM=claude-code
AGENT_MODEL=opus-4-8
Client setup
Claude Code / Codex
# ~/.codex/config.toml
[mcp_servers.mcp-agents-memory]
command = "mcp-agents-memory"
args = []
Gemini CLI
// ~/.gemini/settings.json
{
"mcpServers": {
"mcp-agents-memory": {
"type": "stdio",
"command": "mcp-agents-memory",
"args": [],
"env": {},
"trust": true
}
}
}
Install globally with
npm i -g mcp-agents-memory, or pointcommandat a localbuild/index.js.
Guiding principle
Solving the problem in front of you must not break the whole structure.
Every change is checked against the RESPEC.md vision β "does this fix fit the big picture?" β before proceeding. "Just make it run" is a stop signal.
Reference docs
RESPEC.mdβ current vision, decisions, implementation detail (single source of truth)DEVLOG.mdβ operational issues, observations, ideasREADME.ko.mdβ Korean README