mcp-claude-memory

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.

Category
访问服务器

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) or manual (only when you ask). Manual remember/forget work 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 review tool surfaces stale memories; contradictions get superseded.
  • Background dreamingmemhub dream runs 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 modeauto (recommended) or manual.
  • Embeddings providernone (full-text only), openai, ollama, or cloudflare.

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 serve runs a lightweight mechanical de-dupe on startup when it's been a while and new memories have accumulated — no cron, no claude needed.
  • The full reasoning dream also fires automatically in auto mode: when memhub serve starts and a dream is due, it spawns memhub dream as a detached background process — no cron, no user action. The spawned dream sets MEMHUB_DREAMING=1 so 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 pgvector extension (Supabase / Neon provide it; self-hosted needs CREATE EXTENSION vector, done automatically when you enable a provider).

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选