claude-context-sync
Share context, detect file conflicts, and send messages across parallel Claude Code sessions
README
claude-context-sync
MCP server that automatically summarizes and shares context across parallel Claude Code sessions.
When you run multiple Claude Code sessions on different tasks, each session is unaware of what the others are doing. claude-context-sync watches your session logs, generates structured summaries on demand, and provides real-time file conflict detection and cross-session messaging.
Features
- Session context sharing — any session can see what others are working on
- File conflict detection — real-time alerts when multiple sessions edit the same file
- Symbol-level conflicts — detects shared function/class/interface edits (TypeScript, Python, Swift, Go, Rust)
- Cross-session messaging — send messages between sessions without switching terminals
- Lazy evaluation — zero cost when tools aren't called
- Auto-cleanup — tracked data is removed when sessions end
Installation
npm install -g claude-context-sync
context-sync init
That's it. The next time you open Claude Code, the MCP server starts automatically. The init command also registers a conflict detection hook.
MCP Tools
list_sessions
Returns active Claude Code sessions with their current status, task summary, and any file conflicts.
get_session_context
Returns the full structured summary for a specific session. Automatically re-summarizes if stale. Includes conflict information.
Parameters: sessionId (string)
get_all_changes
Returns changed files and decisions across all sessions, with optional project filtering.
Parameters: project (string, optional)
send_message
Sends a message to another session. Omit targetSessionId to broadcast to all sessions in the same project.
Parameters: fromSessionId (string), message (string), project (string), targetSessionId (string, optional)
get_messages
Returns message history for a session.
Parameters: sessionId (string), unreadOnly (boolean, optional)
resolve_conflicts
Clears resolved files from the conflict tracking list.
Parameters: sessionId (string), files (string[])
How It Works
Context Sharing
[Always running] Watcher: detects .jsonl changes → sets stale flag (zero cost)
↓
[On tool call] MCP Tool invoked → summarizes only stale sessions
↓
Extractor → Generator (claude -p) → Store → Response
Conflict Detection
[Always running] Watcher: detects .jsonl changes
↓
FileTracker: parses Write/Edit tool_use events
↓
SymbolResolver: identifies enclosing function/class/type
↓
Writes per-session touched files
[Every message] Hook (UserPromptSubmit): checks for new conflicts
↓
Alerts Claude once per new conflict → Claude notifies user
Messaging
Session A: send_message → writes to ~/.claude/context-sync/messages/{targetId}/
↓
Session B: Hook detects unread message → injects into AI context
↓
Claude reads and relays to user → marks as read
Architecture
Single MCP server process — no separate daemon. Claude Code launches it automatically via stdio transport.
src/
├── mcp/server.ts # MCP server + 6 tools
├── watcher/
│ ├── watcher.ts # File watching (chokidar)
│ ├── scheduler.ts # Hybrid summarization strategy
│ ├── file-tracker.ts # Real-time file edit tracking
│ └── symbol-resolver.ts # Pattern-based symbol detection
├── summarizer/
│ ├── extractor.ts # .jsonl parsing + stratified sampling
│ └── generator.ts # claude -p invocation
├── messaging/
│ └── messenger.ts # Cross-session message passing
├── store/store.ts # Local summary cache
├── cli.ts # CLI (init + serve + hook registration)
└── types.ts # Shared types
Summarization Strategy
- Incremental: updates existing summary with new messages (default)
- Full: regenerates from scratch (after 4 incremental updates)
- Stratified sampling: for large sessions (500+ messages), samples head + middle + tail
- Cached: returns stored summary if nothing changed (zero cost)
Supported Languages (Symbol Detection)
| Language | Detected Symbols |
|---|---|
| TypeScript/JavaScript | function, class, interface, type, enum, const |
| Python | def, class |
| Swift | func, class, struct, protocol, enum, extension |
| Go | func, type (struct/interface) |
| Rust | fn, struct, enum, trait, impl |
Unsupported file types fall back to file-level conflict detection.
Requirements
- Node.js 20+
- Claude Code CLI (
claudecommand available) jq(for conflict detection hook)
Feedback
We'd love to hear from you! If you have feature requests, bug reports, or just want to share how you use claude-context-sync:
- GitHub Discussions — ideas, questions, show & tell
- GitHub Issues — bug reports, feature requests
Development
git clone https://github.com/ybin4548/claude-context-sync.git
cd claude-context-sync
npm install
npm run build
npm test
License
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。