If you've been running multiple Claude Code instances on the same project — maybe one handling the backend refactor while another tackles the frontend — you've probably hit the wall I hit last week.
Two agents. Same codebase. Both editing files. Neither knows what the other is doing. One rewrites an API response format, the other is still consuming the old format. You end up playing human router, copy-pasting context between terminal tabs like it's 2005 and you're manually syncing files over FTP.
There has to be a better way. And now there is.
The Root Problem: AI Agents Are Isolated by Design
Each Claude Code instance runs in its own process with its own context window. That's actually a good thing for most use cases — you don't want your "fix this CSS bug" agent polluted with context about database migrations.
But when you're doing coordinated work across a codebase, isolation becomes a problem. Agent A changes an interface, Agent B doesn't know. You get merge conflicts, broken contracts, and a lot of wasted tokens re-doing work.
The core issue isn't that the agents are dumb. It's that they have no communication channel. They're like two developers working in the same repo who never talk to each other. We all know how that ends.
The Solution: claude-peers-mcp
claude-peers-mcp is an MCP (Model Context Protocol) server that gives your Claude Code instances the ability to message each other ad-hoc. Think of it as a local message bus for your AI agents.The concept is straightforward: each Claude Code instance registers itself as a peer, and any peer can send messages to any other peer. No central orchestrator, no complex setup — just direct agent-to-agent communication.
How MCP Makes This Work
If you're not familiar with MCP, here's the quick version: it's a protocol that lets you extend Claude Code's capabilities by connecting it to external tool servers. Claude Code can call tools exposed by these servers, and the servers can provide resources back.
clause-peers-mcp leverages this by running a shared MCP server that exposes messaging tools to every connected Claude Code instance. When Agent A needs to tell Agent B something, it calls a tool through MCP, and the message gets delivered.
Step-by-Step Setup
First, clone the repo and install dependencies:
git clone https://github.com/louislva/claude-peers-mcp.git
cd claude-peers-mcp
npm installNext, you need to register it as an MCP server in your Claude Code configuration. Add it to your .claude/settings.json (or the project-level equivalent):
{
"mcpServers": {
"claude-peers": {
"command": "node",
"args": ["/absolute/path/to/claude-peers-mcp/index.js"],
"env": {}
}
}
}Make sure you use the absolute path — relative paths in MCP configs are a classic footgun that'll have you debugging for 20 minutes before you notice.
Now when you launch multiple Claude Code instances in the same project, they'll each connect to the same MCP server and can discover and message each other.
Practical Usage: Coordinating a Refactor
Here's where it gets interesting. Say you're splitting a monolith into separate modules. You've got one agent restructuring the data layer and another updating the API routes.
You can tell the data-layer agent:
"When you change any exported interface, message your peer about what changed and the new type signature."
And tell the API agent:
"Before modifying any route handler, check with your peer if the underlying data types have changed."
The agents handle the coordination themselves. Here's roughly what the communication looks like from the agent's perspective:
// Agent A (data layer) sends a message after changing a type
// This happens through MCP tool calls automatically
{
tool: "send_message",
arguments: {
to: "agent-b",
message: "Changed UserResponse type: removed 'legacyId' field, added 'uuid' field (string). Update route handlers accordingly."
}
}
// Agent B (API routes) receives and adapts
// It can query for messages or get notified
{
tool: "get_messages",
arguments: {}
}
// Returns the message from Agent A, so Agent B knows
// to update its handlers before touching that codeThis is a simplified representation — the actual tool names and schemas are defined by the MCP server — but the flow is accurate.
Debugging When Peers Can't Find Each Other
The most common issue I've seen is agents failing to discover their peers. Nine times out of ten, it's one of these:
- Different MCP server instances: Each Claude Code instance needs to connect to the same server process. If they're spawning separate processes, they can't communicate. Check your config paths.
- Stale connections: If you restart one agent but not the MCP server, the peer list might be stale. Restart the server to clear state.
- Permission issues: MCP servers run as child processes of Claude Code. Make sure the script is executable (
chmod +x) and Node is in your PATH.
A quick sanity check:
# Verify the MCP server starts cleanly on its own
node /path/to/claude-peers-mcp/index.js
# You should see it initialize without errors
# Ctrl+C to stop, then let Claude Code manage itIf that errors out, you've found your problem before Claude Code even enters the picture.
When You Actually Need This (and When You Don't)
Let me be honest — for most day-to-day coding tasks, you don't need inter-agent communication. If you're fixing a bug or adding a feature in one area of the codebase, a single agent is fine.
You want peer communication when:
- Large refactors that touch multiple layers simultaneously
- Parallel feature work where two streams might create conflicts
- Review + implement workflows where one agent reviews while another codes
- Monorepo coordination across packages that depend on each other
You probably don't need it when:
- Working on isolated features
- Doing sequential tasks (just use one agent)
- The "coordination" is really just you wanting to feel productive by running more agents
More agents doesn't automatically mean faster. Coordination has overhead. Two agents that communicate well will outperform five agents that step on each other.
Prevention: Structuring Multi-Agent Work
Beyond the tooling, here are patterns I've found that reduce coordination pain:
- Assign clear boundaries: Give each agent a specific directory or module. "You own
/src/api, you own/src/data" reduces conflicts dramatically. - Establish conventions upfront: Tell both agents the naming conventions, error handling patterns, and type conventions before they start.
- Use the filesystem as a contract: Shared type definition files become the source of truth. Both agents read from them, one agent writes to them.
- Start with the interfaces: Have one agent define the interfaces first, commit them, then let the other agent implement against those interfaces.
This isn't just AI advice — it's the same stuff that makes human teams work better. Clear ownership, explicit contracts, and communication when boundaries get crossed.
The Bigger Picture
What's exciting about claude-peers-mcp isn't just the tool itself — it's what it represents. MCP is turning into the nervous system for AI-assisted development. We started with giving agents access to files and terminals. Then we gave them web search and documentation lookup. Now we're giving them the ability to talk to each other.
The pattern of "multiple specialized agents coordinating through a shared protocol" is going to become standard. If you're building workflows around AI coding assistants, getting comfortable with MCP and multi-agent patterns now will pay off.
Just remember: the goal isn't to have the most agents running. It's to have the right agents, with the right context, talking when they need to. Everything else is noise.
