Sign In

cc-bridge-mcp-server

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-bridge-mcp-server

MCP server for inter-Claude-Code session communication bridge

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
14
40%
Maintainers
1
Weekly downloads
 
Created
Source

cc-bridge-mcp-server

MCP server for inter-Claude-Code session communication bridge.

Quick Start

Step 1: Add .mcp.json to both project repositories:

{
  "mcpServers": {
    "cc-bridge": {
      "command": "npx",
      "args": ["-y", "cc-bridge-mcp-server"],
      "env": {}
    }
  }
}

Or use the CLI:

claude mcp add --transport stdio cc-bridge -- npx -y cc-bridge-mcp-server

Step 2: Restart Claude Code in both repos. The bridge tools are now available.

What It Does

Two Claude Code instances -- one working on a backend repo, another on a frontend repo -- need to negotiate testing scenarios and debug collaboratively in real-time without mixing their accumulated project context.

CC_Backend                                CC_Frontend
    |                                         |
    +-- .mcp.json --> cc-bridge-mcp-server    |
    |                    |                    |
    |                    +-- ~/cloud_code_bridge/cc-bridge-state.json
    |                    |                    |
    |                    |   <-- .mcp.json ---+
    |                                         |
    +-- claude --resume <sessionId> -p "msg" -+

Each CC instance spawns its own MCP server process via stdio transport. Shared state is persisted to ~/cloud_code_bridge/cc-bridge-state.json with file locking so both processes see the same peer registry and message history.

Messages are relayed by calling claude --resume <sessionId> -p "message" as a subprocess. File locking uses fs.writeFile with flag: "wx" (O_CREAT | O_EXCL), stale lock detection via process.kill(pid, 0), and atomic writes via temp-file-then-rename.

Tools Reference

The server exposes six tools, all prefixed with cc_:

cc_register_peer

Register a Claude Code session as a named peer on the bridge.

ParameterTypeRequiredDescription
peerIdstringyesUnique identifier, e.g. "backend" or "frontend"
sessionIdstringyesClaude Code session ID (used with --resume)
cwdstringyesAbsolute path to the project working directory
labelstringyesHuman-readable label, e.g. "CC_Backend" or "CC_Frontend"

cc_deregister_peer

Remove a previously registered peer from the bridge.

ParameterTypeRequiredDescription
peerIdstringyesPeer ID to deregister, e.g. "backend"

cc_send_message

Send a message from one registered peer to another. The message is relayed by resuming the target's Claude Code session via CLI subprocess. Returns the target's response.

ParameterTypeRequiredDescription
fromPeerIdstringyesPeer ID of the sender, e.g. "backend"
toPeerIdstringyesPeer ID of the recipient, e.g. "frontend"
messagestringyesThe message content to send

cc_list_peers

List all currently registered peers. Returns peer IDs, session IDs, working directories, labels, and a potentiallyStale flag for peers idle beyond the configured timeout. No parameters.

cc_get_history

Retrieve the message history for the bridge. Returns messages in chronological order, most recent last.

ParameterTypeRequiredDescription
peerIdstringnoFilter history to messages involving this peer
limitnumbernoMaximum number of messages to return (default 50)

cc_health_check

Diagnose the bridge's operational status. No parameters required.

Checks performed:

  • State file -- Can the state directory be read and written?
  • Lock mechanism -- Can file locks be acquired and released?
  • Claude CLI -- Is the claude binary available and responsive?

Response fields:

FieldTypeDescription
healthybooleanAll checks passed
serverVersionstringCurrent server version
statePathstringPath to state file
claudePathstringPath to Claude CLI
checksobjectPer-check pass/fail with detail messages
timestampstringISO timestamp of the check

Configuration

All settings are configured via environment variables with sensible defaults:

VariableDefaultDescription
CC_BRIDGE_STATE_PATH~/cloud_code_bridgeDirectory for state file and logs
CC_BRIDGE_TIMEOUT_MS120000 (2 min)CLI subprocess timeout in milliseconds
CC_BRIDGE_CHAR_LIMIT0 (unlimited)Max characters in relayed message (0 = no limit)
CC_BRIDGE_LOG_LEVELinfoLog verbosity: debug, info, warn, error
CC_BRIDGE_CLAUDE_PATHclaudePath to the Claude Code CLI executable
CC_BRIDGE_STALE_TIMEOUT_MS1800000 (30 min)Idle time before peer is flagged stale (0 = disabled)

To override defaults, set environment variables in your .mcp.json:

{
  "mcpServers": {
    "cc-bridge": {
      "command": "npx",
      "args": ["-y", "cc-bridge-mcp-server"],
      "env": {
        "CC_BRIDGE_STATE_PATH": "/custom/path",
        "CC_BRIDGE_LOG_LEVEL": "debug"
      }
    }
  }
}

Usage Workflow

  • Start two Claude Code sessions, one per repo. Note each session ID.

  • In CC_Backend, register both peers:

    Use cc_register_peer:
      peerId: "backend", sessionId: "<backend-session-id>",
      cwd: "/path/to/backend", label: "CC_Backend"
    
    Use cc_register_peer:
      peerId: "frontend", sessionId: "<frontend-session-id>",
      cwd: "/path/to/frontend", label: "CC_Frontend"
    
  • Send a message from backend to frontend:

    Use cc_send_message:
      fromPeerId: "backend", toPeerId: "frontend",
      message: "What endpoint does the login form POST to?"
    
  • The bridge resumes the frontend CC session, delivers the message, and returns the response.

  • Check message history at any time:

    Use cc_get_history to see all exchanges, or filter by peerId.
    
  • When done, deregister peers:

    Use cc_deregister_peer:
      peerId: "backend"
    

Troubleshooting

NVM/PATH: "npx not found" or server fails to start

MCP servers are spawned as subprocesses and may not inherit your NVM configuration.

Option 1: Use absolute path to npx

Find your npx path with which npx (e.g., /Users/you/.nvm/versions/node/v22.11.0/bin/npx), then update .mcp.json:

{
  "mcpServers": {
    "cc-bridge": {
      "command": "/Users/you/.nvm/versions/node/v22.11.0/bin/npx",
      "args": ["-y", "cc-bridge-mcp-server"]
    }
  }
}

Option 2: Use claude mcp add (handles PATH automatically)

claude mcp add --transport stdio cc-bridge -- npx -y cc-bridge-mcp-server

Option 3: Ensure NVM loads in non-interactive shells

Add to ~/.zshrc or ~/.bashrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

State file location

The bridge stores state at ~/cloud_code_bridge/cc-bridge-state.json by default.

  • Override with: CC_BRIDGE_STATE_PATH=/your/path
  • Logs are stored at: <state-path>/logs/
  • First-run config is persisted to ~/.cc-bridge-config.json

Common errors

ErrorCauseFix
CLI_NOT_FOUNDclaude not on PATHInstall Claude Code or set CC_BRIDGE_CLAUDE_PATH
CLI_TIMEOUTResponse took > 2 minIncrease CC_BRIDGE_TIMEOUT_MS
LOCK_TIMEOUTLock held by dead processDelete <state-path>/cc-bridge-state.json.lock
STATE_CORRUPTInvalid JSON in stateAuto-recovers; backup saved as .corrupt.<timestamp>
PEER_NOT_FOUNDTarget peer not registeredRegister both peers before sending messages

Development

Build from source:

git clone https://github.com/eaisdevelopment/cc-bridge-mcp-server.git
cd cc-bridge-mcp-server
npm install
npm run build
npm test

Project Structure

src/
├── index.ts                 # Server entry point, registers tools, starts stdio transport
├── config.ts                # Environment variable loading and validation (zod)
├── constants.ts             # Server name and version from package.json
├── errors.ts                # BridgeError class and error code enum
├── logger.ts                # Timestamped file + stderr logger
├── startup.ts               # First-run prompt, config loading, CLI validation
├── types.ts                 # Core interfaces (PeerInfo, MessageRecord, etc.)
├── services/
│   ├── cc-cli.ts            # CLI subprocess wrapper (execFile with claude --resume)
│   ├── health-check.ts      # State file, lock, and CLI diagnostic checks
│   └── peer-registry.ts     # File-based shared state with locking
└── tools/
    ├── register-peer.ts     # cc_register_peer
    ├── deregister-peer.ts   # cc_deregister_peer
    ├── send-message.ts      # cc_send_message
    ├── list-peers.ts        # cc_list_peers
    ├── get-history.ts       # cc_get_history
    └── health-check.ts      # cc_health_check

npm Scripts

ScriptCommandDescription
npm run buildtscCompile TypeScript to dist/
npm run devtsx watch src/index.tsDevelopment mode with auto-reload
npm startnode dist/index.jsRun compiled server
npm run cleanrm -rf distRemove build artifacts
npm testvitest runRun test suite
npm run test:watchvitestRun tests in watch mode
npm run test:coveragevitest run --coverageRun tests with coverage report

License

ISC

Keywords

mcp

FAQs

Package last updated on 10 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts