Sponsored by Deepsite.site

Claude Context Sync

Created By
ybin4548a month ago
Share context, detect file conflicts, and send messages across parallel Claude Code sessions
Overview

claude-context-sync

npm License: MIT

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)

LanguageDetected Symbols
TypeScript/JavaScriptfunction, class, interface, type, enum, const
Pythondef, class
Swiftfunc, class, struct, protocol, enum, extension
Gofunc, type (struct/interface)
Rustfn, struct, enum, trait, impl

Unsupported file types fall back to file-level conflict detection.

Requirements

  • Node.js 20+
  • Claude Code CLI (claude command 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:

Development

git clone https://github.com/ybin4548/claude-context-sync.git
cd claude-context-sync
npm install
npm run build
npm test

License

MIT

Server Config

{
  "mcpServers": {
    "claude-context-sync": {
      "command": "npx",
      "args": [
        "-y",
        "claude-context-sync",
        "serve"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Tavily Mcp
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Amap Maps高德地图官方 MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
WindsurfThe new purpose-built IDE to harness magic
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
ChatWiseThe second fastest AI chatbot™