Multi-Agent Coordination Bus MCP
by Parswanadh
README.md
# Multi-Agent Coordination Bus MCP
The communication backbone that enables true multi-agent systems. This MCP server provides agent-to-agent coordination, message routing, task distribution, consensus mechanisms, and shared state management.
## Overview
```
┌─────────────────────────────────────────────────────────────┐
│ MULTI-AGENT COORDINATION BUS MCP │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Agent A │ │ Agent B │ │ Agent C │ │
│ │ (register) │ │ (register) │ │ (register) │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │ │
│ └─────────────────┼─────────────────┘ │
│ │ │
│ ┌───────▼────────┐ │
│ │ Coordination │ │
│ │ Bus │ │
│ ├────────────────┤ │
│ │ • Discovery │ │
│ │ • Routing │ │
│ │ • Queues │ │
│ │ • Consensus │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
## Features
### 1. Agent Registration & Discovery
- Register agents with capabilities and metadata
- Discover agents by capability, status, or role
- Automatic heartbeat tracking and stale agent detection
### 2. Message Passing
- Direct agent-to-agent messaging
- Broadcast to multiple agents
- Topic-based pub/sub communication
- Message prioritization (low, normal, high)
- Conversation threading with reply-to support
### 3. Task Distribution
- Create tasks with required capabilities
- Claim tasks based on agent capabilities
- Auto-assign tasks to available agents
- Track task status and results
### 4. Consensus & Voting
- Create voting proposals
- Cast votes with multiple consensus algorithms:
- Majority (>50%)
- Unanimous (100%)
- Supermajority (default 2/3)
- Plurality (most votes)
- Real-time consensus calculation
### 5. Shared State
- Versioned key-value storage
- Optimistic locking with version requirements
- State change notifications
- Compare-and-set operations
## Installation
```bash
npm install coordination-mcp-parswanadh
```
## Configuration
### Environment Variables
```bash
# Storage backend
COORDINATION_BACKEND=memory # or redis
REDIS_URL=redis://localhost:6379
# Time-to-live settings (milliseconds)
MESSAGE_TTL=86400000 # 24 hours
TASK_TTL=604800000 # 7 days
STATE_TTL=2592000000 # 30 days
# Heartbeat settings (milliseconds)
HEARTBEAT_INTERVAL=30000 # 30 seconds
HEARTBEAT_TIMEOUT=120000 # 2 minutes
```
### Claude Desktop Configuration
```json
{
"mcpServers": {
"coordination": {
"command": "node",
"args": ["path/to/coordination-mcp/build/index.js"],
"env": {
"COORDINATION_BACKEND": "redis",
"REDIS_URL": "redis://localhost:6379"
}
}
}
}
```
## MCP Tools
### Agent Registration
#### `agent_register`
Register an agent with the coordination bus.
```json
{
"agentId": "agent-1",
"capabilities": ["coding", "typescript", "testing"],
"metadata": {
"role": "developer",
"model": "claude-opus-4-6",
"specialization": "backend-development"
}
}
```
#### `agent_discover`
Discover agents based on capability or status.
```json
{
"capability": "coding",
"status": "active",
"limit": 10
}
```
### Messaging
#### `send_message`
Send a direct message from one agent to another.
```json
{
"from": "agent-1",
"to": "agent-2",
"message": {
"type": "request",
"content": "Please analyze this code"
},
"priority": "high",
"conversationId": "conv-123"
}
```
#### `receive_messages`
Retrieve messages for an agent.
```json
{
"agentId": "agent-2",
"limit": 50
}
```
#### `broadcast_message`
Send a message to multiple agents.
```json
{
"from": "agent-1",
"message": {"text": "Team announcement"},
"recipientIds": ["agent-2", "agent-3", "agent-4"]
}
```
#### `publish_message` / `subscribe_topic`
Topic-based pub/sub messaging.
```json
// Subscribe
{"agentId": "agent-1", "topic": "code-review"}
// Publish
{
"from": "agent-2",
"topic": "code-review",
"message": {"pr": "PR-123", "files": ["server.ts"]}
}
```
### Tasks
#### `create_task`
Create a new task that can be claimed by agents.
```json
{
"task": "Implement authentication system",
"requiredCapabilities": ["coding", "security"],
"priority": "high"
}
```
#### `claim_task`
Claim a pending task.
```json
{
"taskId": "task-123",
"agentId": "agent-1"
}
```
#### `complete_task`
Mark a task as completed or failed.
```json
{
"taskId": "task-123",
"result": {"files": ["auth.ts"], "testsPassed": true}
}
```
#### `auto_assign_tasks`
Automatically assign pending tasks to available agents.
```json
{
"maxTasksPerAgent": 5,
"maxTasksToAssign": 100
}
```
### Consensus
#### `propose_vote`
Create a voting proposal.
```json
{
"proposal": "Which database should we use?",
"options": ["PostgreSQL", "MongoDB", "Redis"],
"participants": ["agent-1", "agent-2", "agent-3"],
"createdBy": "agent-1",
"threshold": "majority"
}
```
#### `cast_vote`
Cast a vote on a proposal.
```json
{
"voteId": "vote-123",
"agentId": "agent-1",
"choice": "PostgreSQL"
}
```
#### `get_consensus`
Calculate current consensus.
```json
{
"voteId": "vote-123",
"threshold": "majority"
}
```
### Shared State
#### `state_get`
Get a value from shared state.
```json
{
"key": "project.status",
"version": 5
}
```
#### `state_set`
Set a value in shared state.
```json
{
"key": "project.status",
"value": "in-development",
"createdBy": "agent-1"
}
```
## Examples
### Two-Agent Communication
```typescript
import { InMemoryStorage } from 'coordination-mcp-parswanadh/storage';
import { AgentRegistry } from 'coordination-mcp-parswanadh/agents';
import { MessageRouter } from 'coordination-mcp-parswanadh/messaging';
const storage = new InMemoryStorage();
await storage.initialize();
const registry = new AgentRegistry(storage);
const router = new MessageRouter(storage);
// Register agents
await registry.register({
agentId: 'agent-a',
capabilities: ['coding'],
});
await registry.register({
agentId: 'agent-b',
capabilities: ['research'],
});
// Send message
await router.send({
from: 'agent-a',
to: 'agent-b',
message: { text: 'Please research MCP patterns' },
});
// Receive messages
const messages = await router.receive({
agentId: 'agent-b',
});
```
### Team Coordination
```typescript
// Register team members
await registry.register({
agentId: 'planner',
capabilities: ['planning', 'architecture'],
metadata: { role: 'Team Lead' },
});
await registry.register({
agentId: 'developer',
capabilities: ['coding', 'testing'],
metadata: { role: 'Developer' },
});
// Create task
const task = await taskManager.create({
task: 'Implement API endpoints',
requiredCapabilities: ['coding'],
priority: 'high',
});
// Auto-assign to capable agents
const agents = await registry.getAllAgents();
await taskManager.autoAssign(agents.map(a => ({
id: a.id,
capabilities: a.capabilities
})));
```
### Consensus Decision
```typescript
// Create vote
const vote = await consensusService.propose({
proposal: 'Deploy to production?',
options: ['Yes', 'No', 'Defer'],
participants: ['agent-1', 'agent-2', 'agent-3'],
createdBy: 'agent-1',
});
// Cast votes
await consensusService.castVote({
voteId: vote.voteId,
agentId: 'agent-1',
choice: 'Yes',
});
// Get consensus
const result = await consensusService.getConsensus(vote.voteId);
console.log(`Consensus: ${result.consensus}, Agreement: ${result.agreement * 100}%`);
```
## Storage Backends
### In-Memory (Default)
- Fast, no external dependencies
- Data persists only while server is running
- Good for development and testing
### Redis
- Persistent storage
- Supports multiple server instances
- Better for production use
## Architecture
```
coordination-mcp/
├── src/
│ ├── agents/ # Agent registration and discovery
│ ├── messaging/ # Message routing and pub/sub
│ ├── tasks/ # Task distribution and tracking
│ ├── consensus/ # Voting and consensus algorithms
│ ├── state/ # Shared state management
│ ├── storage/ # Storage abstraction (memory/redis)
│ ├── tools/ # MCP tool definitions
│ └── server.ts # Main MCP server
├── tests/ # Unit tests
├── examples/ # Usage examples
└── README.md
```
## API Reference
### AgentRegistry
- `register(options)` - Register an agent
- `discover(options)` - Discover agents
- `getAgent(agentId)` - Get agent info
- `heartbeat(agentId)` - Update heartbeat
- `getStaleAgents(timeout)` - Get stale agents
### MessageRouter
- `send(options)` - Send a message
- `receive(options)` - Receive messages
- `broadcast(from, message, recipients)` - Broadcast message
- `publish(from, topic, message)` - Publish to topic
- `subscribe(agentId, topic)` - Subscribe to topic
### TaskManager
- `create(options)` - Create a task
- `claim(options)` - Claim a task
- `complete(options)` - Complete a task
- `getTask(taskId)` - Get task details
- `autoAssign(agents, options)` - Auto-assign tasks
### ConsensusService
- `propose(options)` - Create a vote
- `castVote(options)` - Cast a vote
- `getConsensus(voteId, options)` - Get consensus
- `completeVote(voteId)` - Complete a vote
### StateService
- `get(options)` - Get state value
- `set(options)` - Set state value
- `delete(key)` - Delete state value
- `watch(options, callback)` - Watch for changes
- `getKeys()` - Get all keys
## Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
## License
MIT License - see LICENSE file for details.
## Vision
> "Enable true multi-agent systems where specialized agents collaborate through a standardized communication protocol."
This is the foundation for agent teams, markets, and societies.
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues