MemoryThreads
Persistent, searchable conversation memory shared across Claude Code and Codex, enabling cross-session recall and thread continuity via hybrid BM25 and vector search.
README
MemoryThreads
Persistent, searchable conversation memory shared across Claude Code and Codex.
MemoryThreads is a local MCP server that auto-captures every conversation turn from both Claude Code and OpenAI Codex into one SQLite database, then makes that history instantly searchable from any future session - hybrid BM25 (FTS5) + vector (sqlite-vec) recall, with cross-platform thread continuity. Start work in Claude Code, continue it in Codex, and either side can recall the full shared history.
No cloud, no account - everything lives in ~/.claude/memory-server/ on your machine.
Why
LLM coding sessions are stateless - close the terminal and the context is gone. MemoryThreads fixes that:
- Never re-explain.
recall_context("that auth bug from last week")pulls the actual prior turns. - Cross-tool. Claude Code and Codex write into and read from the same memory, so switching tools never loses the thread.
- Automatic. Hooks capture turns on every session; you don't manage it.
- Fast + private. Local SQLite, FTS5 + sqlite-vec. Your conversations never leave your machine.
How it works
Claude Code ─┐ ┌─ recall_context / search_docs
├─ hooks ─► jobs queue ─► worker.js ─► SQLite ◄─┤ (MCP tools)
Codex ─┘ (capture) (parse + embed) └─ mt launch (resume)
- Capture. Session hooks (Stop, PreCompact, UserPromptSubmit) queue each session's transcript for ingestion. A launchd file-watcher (
incremental-sync.js) also ingests Claude Code turns continuously. - Parse + embed.
worker.jsparses transcripts (dual-format: Claude Code JSONL and Codex rollout JSONL viatranscript-parser.js), stores turns + threads, and embeds each turn (OpenAItext-embedding-3-small, 1536-dim) into a sqlite-vec table. - Recall. The MCP server (
server.js) exposesrecall_context, which runs hybrid BM25 + cosine search over turns/threads and returns the matches to the model. - Continuity. A
canonical_thread_idlinks a Claude Code stream and a Codex stream into one logical MemoryThread, so continuation works across both tools without sharing native session files.
MCP tools
| Tool | Purpose |
|---|---|
recall_context(query, resolution=0, include_threads) |
Hybrid BM25 + vector search. resolution 0 = raw turns (default), 1 = full threads, 2 = thread key-exchanges. |
search_docs(query) |
FTS5 search over ingested reference docs. |
ingest_doc(source, tags?, title?) |
Add a reference doc (URL, llms.txt, or local file). |
list_docs / delete_doc |
Manage ingested docs. |
save_thread(name, ...) |
Bookmark the current session as a named MemoryThread. |
list_threads / activate_thread / delete_thread |
Manage and resume bookmarks. |
Slash commands & CLI
/mt-save <name>,/mt-list,/mt-delete <name>,/mt-doc-ingest <source>mt launch(terminal) - interactive picker to resume a saved thread.
Data model
One SQLite DB (data/memory.db). Core tables: threads, turns, turns_fts (FTS5), turn_embeddings (sqlite-vec), plus saved_threads, active_memory_threads, docs, tool_uses, summaries, recovery_buffer, and the worker jobs queue. Full DDL in SCHEMA.md.
Recall operates directly over conversation turns and threads - there is no extracted-knowledge layer.
Setup
See SETUP.md for the full guide. In short:
npm install- Put
OPENAI_API_KEY=...in.env(gitignored). - Register the MCP server:
claude mcp add --scope user memory node ~/.claude/memory-server/server.js(and the[mcp_servers.memory]block in~/.codex/config.tomlfor Codex). - Add the hooks block to
~/.claude/settings.jsonand~/.codex/hooks.json. - Start the worker via the launchd watchdog.
Hooks
| Event | Script | Role |
|---|---|---|
SessionStart |
session-start-cold.sh / session-start-compact.sh |
Status line; compaction recovery |
UserPromptSubmit |
user-prompt-submit.cjs |
Inject relevant prior turns + active-thread context |
PreCompact |
pre-compact.sh |
Snapshot recent turns to recovery_buffer before compaction |
Stop |
stop.cjs |
Queue the session transcript for ingestion |
The same hook scripts serve both Claude Code (settings.json) and Codex (hooks.json).
Tech stack
Node.js (ES modules) · better-sqlite3 · sqlite-vec · OpenAI embeddings · @modelcontextprotocol/sdk · SQLite FTS5.
Privacy
All data is local. .env (your API key) and data/ (the DB) are gitignored and never committed.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。