News

Developer Engineers Real-time Communication Between Two Claude Code AI Instances Using JSON Files and Undocumented Channels

Developer Engineers Real-time Communication Between Two Claude Code AI Instances Using JSON Files and Undocumented Channels

The Challenge: Making Two Claude Code Instances Communicate

A developer faced an intriguing problem: with two Claude Code sessions open—one for backend coding, the other for running tests—the idea emerged to make them communicate directly. This endeavor, while taking several days and involving undocumented APIs and deep dives into Windows file locking, ultimately proved successful.

Why Files Over HTTP?

When operating multiple AI agents on the same machine, HTTP communication is an over-engineered solution. A shared filesystem offers a more efficient and direct approach. File-based messaging provides several advantages:

  • Zero Infrastructure: No servers, ports, or Docker containers are required.
  • Offline Delivery: Messages persist in a directory until read.
  • Atomic Writes: Utilizing a temporary file and then renaming it ensures that messages are always read completely, preventing partial reads.
  • Debuggability: Messages are plain JSON files, making cat inbox/*.json an effective monitoring tool.

The overall system is straightforward: Agent A writes a JSON file, Agent B's MCP server polls the directory, reads the file, and pushes it into its session.

The diagram illustrates the message flow between Agent A and Agent B via the filesystem: Agent A's MCP Server polls to-brave-fox/inbox/ for incoming messages and uses a send tool to deliver messages to to-calm-owl/inbox/, where Agent B's MCP Server picks them up.

The MCP Channels Exploration

Claude Code features an experimental capability known as "channels." This allows MCP servers to directly push notifications into a chat session without user intervention. This mechanism is crucial for cc2cc to achieve real-time message delivery, eliminating the need for users to repeatedly ask for new messages.

However, this feature is guarded by a flag: --dangerously-load-development-channels. The flag's name itself suggests its developmental and unsupported nature. Official documentation is virtually nonexistent, requiring the developer to reverse-engineer its functionality by examining Claude Code's source code, extensive trial and error, and persistent debugging.

Through this process, it was discovered that neither claude --dangerously-load-development-channels nor claude --dangerously-load-development-channels cc2cc worked as expected. The correct syntax, unearthed after significant effort, is:

claude --dangerously-load-development-channels server:cc2cc

The server: prefix proved to be a critical insight.

Self-Wake: Teaching the Agent to Boot Itself

A notable constraint is that MCP servers are passive. They respond to tool calls but cannot initiate them. This means that while an agent might be technically "alive" (its server running, polling, and ready), Claude Code...

↗ Read original source