Agent Communication MCP
Facilitates autonomous AI agent collaboration on software projects through file-based task management and inter-agent communication via the Model Context Protocol.
README
Agent Communication MCP
A Multi-Agent Communication System using Model Context Protocol (MCP) with file-based storage for autonomous AI agent collaboration.
Overview
This system enables autonomous AI agents/LLMs to collaborate on software development projects while maintaining independence over their respective codebases. Each agent manages its own development context, memory, and task queue through file-based storage, while communicating and coordinating with other agents via MCP services.
Features
- Real MCP Server: Implements proper Model Context Protocol server that agents connect to
- File-Based Agent Memory: Each agent maintains context and tasks as simple files for immediate productivity
- JSON-RPC Communication: Standard JSON-RPC over stdio for MCP protocol compliance
- Autonomous Agent Operation: Real agents connect and communicate via MCP protocol
- Dependency Management: Clear consumer-producer relationships between agents
- Task Coordination: File-based request-response mechanism for cross-agent collaboration
- Automatic Incorporation Tasks: When an agent completes a task created by another agent, an incorporation task is automatically created for the creator to review and integrate changes
- HTTP API Wrapper: REST API for easier testing and integration
- Docker Support: Containerized deployment with monitoring capabilities
Quick Start
Global Installation (Recommended)
-
Install globally:
npm install -g agent-communication-mcp -
Start the MCP server:
agent-mcp server -
Configure Claude Desktop: Add to your Claude Desktop config (
~/Library/Application Support/Claude/claude_desktop_config.json):{ "mcpServers": { "agent-communication-mcp": { "command": "agent-mcp", "args": ["server"], "env": { "NODE_ENV": "production" } } } } -
Restart Claude Desktop and start using AI agents!
Local Development
-
Install dependencies:
npm install -
Start the MCP server:
npm start -
Test MCP connections:
npm run test:mcp -
Run the HTTP API (for easier testing):
npm run api
Using Docker
Prerequisites
- Docker Desktop: Download and install from docker.com
- Ensure Docker Desktop is running before executing any Docker commands
Setup and Run
-
Setup Docker environment:
npm run docker:setupWindows Users: This command automatically detects your platform and uses PowerShell scripts for Windows compatibility.
-
Build and run with Docker:
npm run docker:runNote: If you get connection errors, ensure Docker Desktop is running and try again.
-
View logs:
npm run docker:logs -
Stop the system:
npm run docker:down
Troubleshooting Docker on Windows
If you encounter issues:
- "Docker is not running": Start Docker Desktop and wait for it to fully initialize
- Permission errors: Run your terminal as Administrator
- Build failures: Try
docker system pruneto clean up disk space - Port conflicts: Ensure port 3000 is not in use by other applications
For detailed Windows setup instructions, see the Windows Docker Setup Guide.
Architecture
Agent Structure
Each AI agent consists of:
- Agent ID: Unique identifier for the LLM agent
- Context Memory: Markdown file containing agent's knowledge and state
- Task Queue: File-based ordered list of tasks with priorities and dependencies
- Codebase: The software project the AI agent is responsible for developing
- Relationships: Consumer/producer mappings with other agents
- MCP Service: Model Context Protocol service for communication
File Structure
agents/
├── agent-id/
│ ├── context.md # Agent's knowledge base and current state
│ ├── tasks/
│ │ ├── active.json # Current active tasks
│ │ ├── pending.json # Queued tasks
│ │ ├── completed.json # Historical completed tasks
│ │ └── requests/ # Inter-agent communication
│ │ ├── incoming/ # Tasks received from other agents
│ │ └── outgoing/ # Tasks sent to other agents
│ ├── relationships.json # Consumer/producer mappings
│ └── mcp_config.json # MCP service configuration
Usage Examples
Creating Agents
const { AgentCommunicationSystem } = require('./src/index');
const system = new AgentCommunicationSystem();
await system.start();
// Register agents
const frontendAgent = await system.registerAgent('frontend-agent');
const apiAgent = await system.registerAgent('api-agent');
const dbAgent = await system.registerAgent('database-agent');
Establishing Relationships
// Frontend consumes API services
await frontendAgent.relationshipManager.addProducer('api-agent');
await apiAgent.relationshipManager.addConsumer('frontend-agent');
Creating Task Requests
await system.createTaskRequest('frontend-agent', 'api-agent', {
title: 'Create User Authentication API',
description: 'Need REST endpoints for user login, logout, and registration',
priority: 'high',
deliverables: ['/api/auth/login', '/api/auth/logout', '/api/auth/register'],
metadata: {
estimated_effort: '8 hours',
tags: ['authentication', 'api', 'security']
}
});
Managing Tasks
// Get agent's task queue
const taskQueue = agent.taskQueue;
// Add a task
const task = new Task({
title: 'Implement user registration',
description: 'Create user registration endpoint with validation',
priority: 'high',
agent_id: 'api-agent'
});
await taskQueue.addTask(task);
// Activate a task
await taskQueue.activateTask(task.id);
// Complete a task
await taskQueue.completeTask(task.id, ['user-registration.js', 'validation-schema.js']);
// When an agent completes a task created by another agent,
// an incorporation task is automatically created for the creator
// to review and incorporate the changes
Automatic Incorporation Task Guidance
When an agent completes a task that was created by a different agent, the MCP server provides detailed guidance and metadata to help the LLM agent create an appropriate incorporation task for the original creator.
How it works:
- Agent A creates a task for Agent B
- Agent B completes the task using
task/updatewith status 'completed' - MCP server detects cross-agent completion and provides incorporation guidance
- LLM agent can use the guidance to create an incorporation task for Agent A
MCP Server Response for Cross-Agent Task Completion:
When completing a task created by another agent, the task/update method returns:
{
"success": true,
"message": "Task completed",
"task": { /* completed task data */ },
"incorporation_needed": true,
"incorporation_guidance": {
"message": "This task was created by creator-agent. Consider creating an incorporation task...",
"creator_agent": "creator-agent",
"completed_by": "worker-agent",
"original_task": { /* original task details */ },
"suggested_incorporation_task": {
"title": "Incorporate changes from: [Original Task Title]",
"description": "Task has been completed by worker-agent. Please review and incorporate...",
"agent_id": "creator-agent",
"created_by": "worker-agent",
"target_agent_id": "creator-agent",
"reference_task_id": "original-task-id",
"deliverables": ["file1.js", "file2.js"],
"metadata": {
"incorporation_task": true,
"original_task_id": "original-task-id",
"completed_by": "worker-agent",
"tags": ["incorporation", "review"]
}
},
"implementation_steps": [
"1. Create a new task for agent 'creator-agent' using the suggested_incorporation_task data",
"2. Use the task/create method with agentId='creator-agent'",
"3. The incorporation task will help creator-agent review and integrate the deliverables"
]
}
}
Example Usage:
// Complete a cross-agent task
const response = await mcpClient.request('task/update', {
agentId: 'worker-agent',
taskId: 'task-123',
status: 'completed',
deliverables: ['login.js', 'register.js', 'auth-middleware.js']
});
// Check if incorporation guidance is provided
if (response.incorporation_needed) {
// Create incorporation task using the suggested data
await mcpClient.request('task/create', {
agentId: response.incorporation_guidance.creator_agent,
task: response.incorporation_guidance.suggested_incorporation_task
});
}
Claude Desktop Integration
Setup with Claude Desktop
-
Install globally:
npm install -g agent-communication-mcp -
Add to Claude Desktop config:
{ "mcpServers": { "agent-communication-mcp": { "command": "agent-mcp", "args": ["server"] } } } -
Use with Claude:
Please register a new agent with ID "frontend-dev" for React development. Create a task for frontend-dev to build a login form with validation. Show me the status of all agents in the system.
See Claude Desktop Integration Guide for detailed instructions.
MCP Communication
The system uses Model Context Protocol for inter-agent communication with these message types:
- TASK_REQUEST: Request for implementation or assistance
- TASK_RESPONSE: Response to a previous request
- STATUS_UPDATE: Progress updates on tasks
- DEPENDENCY_NOTIFICATION: Dependency changes
- INTEGRATION_TEST: Integration test requests
- COMPLETION_NOTIFICATION: Task completion notifications
- CONTEXT_SYNC: Context synchronization between agents
Monitoring
The system includes comprehensive monitoring capabilities:
const SystemMonitor = require('./src/monitoring/SystemMonitor');
const monitor = new SystemMonitor(system);
await monitor.start();
// Get system status
const status = await monitor.getSystemStatus();
// Generate health report
const report = await monitor.generateHealthReport();
Docker Deployment
Environment Variables
NODE_ENV: Environment (development/production)MCP_LOG_LEVEL: Logging level (debug/info/warn/error)MCP_POLL_INTERVAL: Message polling interval in msMCP_MAX_AGENTS: Maximum number of agentsMCP_MONITOR_INTERVAL: Monitoring interval in ms
Docker Commands
# Setup environment (cross-platform)
npm run docker:setup
# Build and run (cross-platform)
npm run docker:run
# Build images only
npm run docker:build
# Start services
npm run docker:up
# View logs
npm run docker:logs
# Stop services
npm run docker:down
# Clean up
npm run docker:clean
Windows-Specific Notes
- All Docker commands are cross-platform compatible and automatically detect Windows
- PowerShell scripts are used on Windows for better compatibility
- Ensure Docker Desktop is running before executing any commands
- If using WSL2, ensure proper integration is enabled in Docker Desktop settings
Development
Project Structure
src/
├── core/
│ ├── Agent.js # Core agent class
│ ├── Task.js # Task management
│ ├── TaskQueue.js # Task queue operations
│ └── RelationshipManager.js # Agent relationships
├── communication/
│ └── CommunicationProtocol.js # MCP communication
├── monitoring/
│ ├── SystemMonitor.js # System monitoring
│ └── monitor-daemon.js # Docker monitoring daemon
└── index.js # Main entry point
Running Tests
npm test
npm run test:watch
Development Mode
npm run dev # Runs with --watch flag for auto-restart
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For questions and support, please open an issue on the GitHub repository.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。