context-bridge
Enables Claude Code to search and retrieve past chat history from Claude.ai exports and Claude Code sessions, allowing the AI to reference previous conversations and decisions.
README
Context Bridge — operating doc
See PLAN.md for the original design rationale. This file is the practical
"how do I actually run this" companion.
Installation
bash install.sh
The wizard creates a .venv, installs dependencies, registers the MCP server
with Claude Code (global by default, so it's available in every session), and
writes a .env file for local config.
Configuration — .env (created by the wizard, gitignored) supports:
| Variable | Default | Purpose |
|---|---|---|
CONTEXT_BRIDGE_DB_PATH |
./chat_memory.db |
Where the database lives |
Edit .env directly to change these after initial setup. See .env.example for
the template.
Getting your Claude.ai export
There is no API for this — the export is pull-only, triggered manually:
- Go to Claude.ai → Settings → Account → Export Data
- Anthropic emails you a
.dmsfile attachment (has been a few minutes in my exp) - Run
./build_all.sh path/to/export.dms— it handles the rename, unpack, and rebuild
Abstract overview
Claude.ai export (.zip) ~/.claude/projects/**/*.jsonl
│ unzip │ ingest_code_sessions.py
▼ │ (incremental, walk parentUuid tree)
data/inspect/ │
│ ingest.py + embed.py │
│ (full rebuild via build_db.py) │
└──────────────────┬────────────────────┘
▼
chat_memory.db (SQLite — chunks + sessions + meta)
│ source: 'claude_ai' | 'claude_code'
│ server.py: search_chat_history, get_conversation
▼
Claude Code session, via "context-bridge" MCP
build_db.py always parses the entire data/inspect/ export and re-embeds
everything, but before the atomic replace it merges back any claude_ai
chunks from the previous DB whose conversation/project UUID is absent from the
new export. This means a partial export (e.g. 90-day-only) is safe — older
history that isn't in the new export is preserved from the old DB.
One exception: if the embedding model changes between builds, the merge is
skipped (mixing vectors from two models would corrupt search). In that case run
build_db.py with a full export to get a clean rebuild.
Command cheat sheet
Refresh the DB from a new export (standard workflow — run this whenever you pull a new Claude.ai export):
cd context_bridge
./build_all.sh data/chat-archive-<date>.dms
Pass the export file (.dms or .zip) and build_all.sh handles the unpack
step automatically. Omit the argument if data/inspect/ is already populated.
Run the MCP server manually (for a quick smoke check outside Claude Code):
cd context_bridge
./run_server.sh
(This is also what install.sh registers as the context-bridge MCP server —
no separate setup needed once the venv/deps exist.)
Sanity-check ingest/parsing only (no embedding, no DB write — just see what the export produces):
cd context_bridge
python3 ingest.py # defaults to ./data/inspect
Run the retrieval/smoke tests:
cd context_bridge
python3 smoke_test.py
python3 retrieval_smoke_test.py
python3 mcp_smoke_test.py
Refresh the DB from new Claude Code sessions (incremental — safe to re-run any time; skips already-ingested sessions):
cd context_bridge
python3 ingest_code_sessions.py
How the MCP server is actually used
The server registers two tools with Claude at session start: search_chat_history
and get_conversation. Their schemas cost ~100–200 tokens each for the lifetime
of the session, whether or not they're ever called.
What triggers a search: the tool description drives autonomous behavior.
The current description is reactive — Claude calls search_chat_history when
it notices it's about to re-derive something it suspects has been covered before.
In a narrow coding task it may never fire; in a design or planning conversation
it may fire more.
The most reliable pattern: ask explicitly.
"Search the context bridge for [topic]."
This produces a direct, well-formed tool call rather than leaving query construction to Claude's autonomous judgment. Semantic search rewards descriptive phrases over single keywords — "what did we decide about chunking strategy" retrieves better than "chunking".
Current retrieval limitation: search_chat_history has no locality signal.
A query from a sol_reason session ranks sol_reason sessions no higher than
sessions from synesthesia, djmgmt, or any other project. This is the Phase 3
gap (current_project parameter — see PLAN.md). Until Phase 3 is implemented,
cross-project noise is a known retrieval quality ceiling.
Notes / known constraints
- Export is manual, pull-only (Claude.ai Settings → Account → Export Data) — no API/webhook trigger.
build_db.pywrites to a.tmpfile andos.replaces it into place, so a crash mid-rebuild never leaves a half-writtenchat_memory.dblive.chat_memory.dbanddata/are gitignored — they're local build artifacts and data files, not 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 模型以安全和受控的方式获取实时的网络信息。