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
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.