mcp-claude-memory
A smart, self-maintaining memory system for Claude Code that persists across machines using Postgres, with semantic recall, confidence-based self-healing, and background maintenance via dreaming.
README
memhub
Smart, self-maintaining, cross-machine memory for Claude Code — Postgres-backed, no rented LLM brain.
mem0 and Honcho are memory stores that pay a separate LLM (OpenAI) to do the thinking. memhub flips that: in Claude Code the LLM is already in the room, so Claude does the extraction, reasoning, and background reconciliation itself — for free. The backend is just Postgres.
npm install -g memhub
memhub init
What you get
- Follows you across machines — every machine points at one shared Postgres, so office / home / laptop share a single brain. Postgres is the sync.
- Works in every project — registered at user scope, so the memory tools are available everywhere, not per-repo.
- Automatic or manual capture — choose
auto(Claude saves and updates memories silently as you work, no commands) ormanual(only when you ask). Manualremember/forgetwork in both modes. - Semantic recall — optional embeddings (OpenAI or local Ollama, no key required) give vector search blended with full-text via Reciprocal Rank Fusion. Without embeddings it falls back to Postgres full-text — it works with just a Postgres URL.
- Self-healing (living memory) — every fact tracks source, confidence, and freshness. Confidence grows as
facts are re-confirmed; the
reviewtool surfaces stale memories; contradictions get superseded. - Background dreaming —
memhub dreamruns a Honcho-style reasoning pass: it derives new facts (logical deductions + behavioral inductions), resolves contradictions, and maintains a stable peer-card identity summary — all powered by your own Claude, no rented model. Schedule it with cron. - Yours — plain rows in your own Postgres, no opaque vendor store, no required LLM API key.
Setup
npm install -g memhub
memhub init # global setup, then restart Claude Code
The wizard asks for:
- Postgres connection string (Supabase / Neon / Railway / self-hosted all work).
- Namespace — your identity; the same namespace on another machine shares one brain.
- Capture mode —
auto(recommended) ormanual. - Embeddings provider —
none(full-text only),openai,ollama, orcloudflare.
It migrates the schema, registers the MCP server at user scope, and (in auto mode) installs a small
instruction block into ~/.claude/CLAUDE.md.
Add another machine by running the same init with the same Postgres URL, namespace, and capture mode.
Note: Switching embedding provider or model does not re-embed existing memories — older memories remain searchable via full-text until they are saved again.
Memory tools (used by Claude)
| Tool | Purpose |
|---|---|
remember |
Store a distilled fact (content, kind, tags, source, confidence). |
recall |
Hybrid full-text + vector search. |
review |
List stale memories to reconcile. |
confirm |
Mark a fact still true (refreshes freshness, raises confidence). |
supersede |
Replace an outdated fact with a corrected one. |
forget |
Archive a fact. |
list |
Browse / audit memories. |
history |
Show how a fact evolved (its superseded versions). |
In auto mode Claude recalls before remembering to avoid duplicates, and calls these tools proactively; you can also just say "remember this" / "forget that".
Dreaming (background maintenance)
memhub dream # run a maintenance pass now
memhub dream --print-cron # print a crontab line to schedule it
The dream is a Honcho-style reasoning pass over your distilled facts. It first archives exact-duplicate
memories, then launches a headless Claude (claude -p, scoped to only the memhub tools — no shell/file
access) that:
- Deduces new facts — logical implications of what you've stated (e.g. "writes the Rust scanner" ⇒ "proficient in Rust").
- Induces patterns — behavioral tendencies and preferences spanning ≥ 2 facts, with confidence by evidence count.
- Resolves contradictions — supersedes outdated or conflicting facts.
- Maintains a peer-card — a compact, stable identity summary.
Every memory carries a level (explicit = what you stated, deductive, or inductive); derived facts
record their source memory ids (provenance), and only explicit facts count toward the auto-trigger
so the dream can't feed on its own output. The reasoning step needs the claude CLI logged in on the machine
running the job; if it's unavailable, the duplicate cleanup still runs and the reasoning step is skipped.
Two layers, so you know what's automatic:
- In auto capture mode,
memhub serveruns a lightweight mechanical de-dupe on startup when it's been a while and new memories have accumulated — no cron, noclaudeneeded. - The full reasoning dream also fires automatically in auto mode: when
memhub servestarts and a dream is due, it spawnsmemhub dreamas a detached background process — no cron, no user action. The spawned dream setsMEMHUB_DREAMING=1so its own nested server skips auto-dream (no recursion). In manual capture mode, nothing runs on its own.
Scheduling the nightly dream (optional)
This is an optional extra for machines where you rarely open Claude Code (so serve seldom starts and the
auto-dream above rarely fires). If you open Claude Code regularly you don't need it.
memhub schedule # print the right scheduler for your OS
memhub schedule --install # install it (writes/loads the job)
memhub schedule is cross-platform: on Linux it prints a cron line (add it via crontab -e, or let
--install write your crontab); on macOS it prints a launchd LaunchAgent plist and --install writes it
to ~/Library/LaunchAgents/com.memhub.dream.plist and launchctl loads it. Both run the dream nightly at 03:00,
logging to ~/.memhub/dream.log.
It sets PATH explicitly so the scheduled job can find both memhub and claude — these usually live in
nvm and ~/.local/bin, which cron/launchd do not include in their minimal default PATH.
Requirements
- Node ≥ 20.
- A Postgres database. For semantic embeddings, Postgres with the
pgvectorextension (Supabase / Neon provide it; self-hosted needsCREATE EXTENSION vector, done automatically when you enable a provider).
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 模型以安全和受控的方式获取实时的网络信息。