# Agent Coordinator A **Model Context Protocol (MCP) server** that enables multiple AI agents to coordinate their work seamlessly across codebases without conflicts. Built with Elixir for reliability and fault tolerance. ## ๐ŸŽฏ What is Agent Coordinator? Agent Coordinator is a **unified MCP proxy server** that enables multiple AI agents to collaborate seamlessly without conflicts. As shown in the architecture diagram above, it acts as a single interface connecting multiple agents (Purple Zebra, Yellow Elephant, etc.) to a comprehensive ecosystem of tools and task management. **The coordinator orchestrates three core components:** - **Task Registry**: Intelligent task queuing, agent matching, and automatic progress tracking - **Agent Manager**: Agent registration, heartbeat monitoring, and capability-based assignment - **Codebase Registry**: Cross-repository coordination, dependency management, and workspace organization **Plus a Unified Tool Registry** that seamlessly combines: - Native coordination tools (register_agent, get_next_task, etc.) - Proxied MCP tools from external servers (read_file, search_memory, etc.) - VS Code integration tools (get_active_editor, run_command, etc.) Instead of agents conflicting over files or duplicating work, they connect through a single MCP interface that automatically routes tool calls, tracks all operations as coordinated tasks, and maintains real-time communication via personal agent inboxes and shared task boards. **Key Features:** - **๐Ÿค– Multi-Agent Coordination**: Register multiple AI agents (GitHub Copilot, Claude, etc.) with different capabilities - **๏ฟฝ Unified MCP Proxy**: Single MCP server that manages and unifies multiple external MCP servers - **๐Ÿ“ก External Server Management**: Automatically starts, monitors, and manages MCP servers defined in `mcp_servers.json` - **๐Ÿ› ๏ธ Universal Tool Registry**: Combines tools from all external servers with native coordination tools - **๐ŸŽฏ Intelligent Tool Routing**: Automatically routes tool calls to the appropriate server or handles natively - **๐Ÿ“ Automatic Task Tracking**: Every tool usage becomes a tracked task with agent coordination - **โšก Real-Time Communication**: Agents can communicate and share progress via heartbeat system - **๐Ÿ”Œ Dynamic Tool Discovery**: Automatically discovers new tools when external servers start/restart - **๐ŸŽฎ Cross-Codebase Support**: Coordinate work across multiple repositories and projects - **๐Ÿ”Œ MCP Standard Compliance**: Works with any MCP-compatible AI agent or tool ## ๐Ÿš€ How It Works ```ascii โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚AI AGENTS & TOOLS CONNECTIONโ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ Agent 1 (Purple Zebra) Agent 2(Yellow Elephant) Agent N (...) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€MCP Protocolโ”ผ(Single Interface)โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ AGENT COORDINATOR (Unified MCP Server) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Task Registry โ”‚ โ”‚ Agent Manager โ”‚ โ”‚Codebase Registry โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ โ”‚โ€ข Task Queuing โ”‚ โ”‚โ€ข Registration โ”‚ โ”‚โ€ข Cross-Repo โ”‚ โ”‚ โ”‚ โ”‚โ€ข Agent Matching โ”‚ โ”‚โ€ข Heartbeat โ”‚ โ”‚โ€ข Dependencies โ”‚ โ”‚ โ”‚ โ”‚โ€ข Auto-Tracking โ”‚ โ”‚โ€ข Capabilities โ”‚ โ”‚โ€ข Workspace Mgmt โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ UNIFIED TOOL REGISTRY โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ โ”‚ Native Tools: register_agent, get_next_task, โ”‚ โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•• โ”‚ โ”‚ create_task_set, complete_task, ... โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Proxied MCP Tools: read_file, write_file, โ”‚ โ”‚ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ทโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”‘ โ”‚ โ”‚ search_memory, get_docs, ... โ”‚ โ”‚ โ”‚ Task Board โ”‚ โ”‚ โ”‚ VS Code Tools: get_active_editor, set_selection, โ”‚ โ”‚ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฅ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚ โ”‚ get_workspace_folders, run_command, ... โ”‚ โ”‚ โ”ƒ Agent 1 INBOX โ”ƒโ”‚ Agent 1 Q โ”ƒ Agent 2 Q โ”‚ โ”ƒ Agent 2 INBOX โ”ƒ โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฅ โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚ โ”‚ Routes to appropriate server or handles natively โ”‚ โ”‚ โ”ƒ current: task 3 โ”ƒโ”‚ โœ“ Task 1 โ”ƒ โœ“ Task 1 โ”‚ โ”ƒ current: task 2 โ”ƒ โ”‚ โ”‚ Configure MCP Servers to run via MCP_TOOLS_FILE โ”‚ โ”‚ โ”ƒ [ complete task ] โ”ฃโ”ฅ โœ“ Task 2 โ”ƒ โž” Task 2 โ”โ”โ”ซ [ complete task ] โ”ƒ<โ”€โ” โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›โ”‚ โž” Task 3 โ”ƒ โ€ฆ Task 3 โ”‚ โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฅ โ”‚ โ”‚ โ”‚ Agent 3 Q โ”ƒ Agent 4 Q โ”‚ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚ โ”‚ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฅ โ”ƒ Agent 4 INBOX โ”ƒ<โ”€โ”ค Personal inboxes โ”‚ โ”‚ โœ“ Task 1 โ”ƒ โž” Task 1 โ”‚ โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚ โ”‚ โ”‚ โœ“ Task 2 โ”ƒ โ€ฆ Task 2 โ”‚ โ”ƒ current: task 2 โ”ƒ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โœ“ Task 3 โ”ƒ โ€ฆ Task 3 โ”โ”โ”ซ [ complete task ] โ”ƒ โ”‚ โ”‚ EXTERNAL MCP SERVERS โ”‚ โ”•โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”™ โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ Agent 3 INBOX โ”ƒ<โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”™ โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ” โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ” โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ” โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ” โ”‚ โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚ MCP 1 โ”‚ โ”‚ โ”‚ MCP 2 โ”‚ โ”‚ โ”‚ MCP 3 โ”‚ โ”‚ โ”‚ MCP 4 โ”‚ โ”‚ โ”ƒ current: none โ”ƒ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”ƒ [ view history ] โ”ƒ โ”‚โ€ข tool 1โ”‚ โ”‚ โ”‚โ€ข tool 1โ”‚ โ”‚ โ”‚โ€ข tool 1โ”‚ โ”‚ โ”‚โ€ข tool 1โ”‚ โ”‚ โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚โ€ข tool 2โ”‚ โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚ โ”‚โ€ข tool 3โ”‚โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”โ”‚โ€ข tool 3โ”‚โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”โ”‚โ€ข tool 3โ”‚โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”โ”‚โ€ข tool 3โ”‚โ”Œโ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ” โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚ MCP 5 โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚ MCP 6 โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚ MCP 7 โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚ MCP 8 โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚โ€ข tool 1โ”‚ โ”‚โ€ข tool 1โ”‚ โ”‚โ€ข tool 1โ”‚ โ”‚โ€ข tool 1โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚โ€ข tool 2โ”‚ โ”‚โ€ข tool 3โ”‚ โ”‚โ€ข tool 3โ”‚ โ”‚โ€ข tool 3โ”‚ โ”‚โ€ข tool 3โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ๐Ÿ”ฅ WHAT HAPPENS: 1. Agent Coordinator reads mcp_servers.json config 2. Spawns & initializes all external MCP servers 3. Discovers tools from each server via MCP protocol 4. Builds unified tool registry (native + external) 5. Presents single MCP interface to AI agents 6. Routes tool calls to appropriate servers 7. Automatically tracks all operations as tasks 8. Maintains heartbeat & coordination across agents ``` ## ๐Ÿ”ง MCP Server Management & Unified Tool Registry Agent Coordinator acts as a **unified MCP proxy server** that manages multiple external MCP servers while providing its own coordination capabilities. This creates a single, powerful interface for AI agents to access hundreds of tools seamlessly. ### ๐Ÿ“ก External Server Management The coordinator automatically manages external MCP servers based on configuration in `mcp_servers.json`: ```json { "servers": { "mcp_filesystem": { "type": "stdio", "command": "bunx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/ra"], "auto_restart": true, "description": "Filesystem operations server" }, "mcp_memory": { "type": "stdio", "command": "bunx", "args": ["-y", "@modelcontextprotocol/server-memory"], "auto_restart": true, "description": "Memory and knowledge graph server" }, "mcp_figma": { "type": "http", "url": "http://127.0.0.1:3845/mcp", "auto_restart": true, "description": "Figma design integration server" } }, "config": { "startup_timeout": 30000, "heartbeat_interval": 10000, "auto_restart_delay": 1000, "max_restart_attempts": 3 } } ``` **Server Lifecycle Management:** 1. **๐Ÿš€ Startup**: Reads config and spawns each external server process 2. **๐Ÿ” Discovery**: Sends MCP `initialize` and `tools/list` requests to discover available tools 3. **๐Ÿ“‹ Registration**: Adds discovered tools to the unified tool registry 4. **๐Ÿ’“ Monitoring**: Continuously monitors server health and heartbeat 5. **๐Ÿ”„ Auto-Restart**: Automatically restarts failed servers (if configured) 6. **๐Ÿ›ก๏ธ Cleanup**: Properly terminates processes and cleans up resources on shutdown ### ๐Ÿ› ๏ธ Unified Tool Registry The coordinator combines tools from multiple sources into a single, coherent interface: **Native Coordination Tools:** - `register_agent` - Register agents with capabilities - `create_task` - Create coordination tasks - `get_next_task` - Get assigned tasks - `complete_task` - Mark tasks complete - `get_task_board` - View all agent status - `heartbeat` - Maintain agent liveness **External Server Tools (Auto-Discovered):** - **Filesystem**: `read_file`, `write_file`, `list_directory`, `search_files` - **Memory**: `search_nodes`, `store_memory`, `recall_information` - **Context7**: `get-library-docs`, `search-docs`, `get-library-info` - **Figma**: `get_code`, `get_designs`, `fetch_assets` - **Sequential Thinking**: `sequentialthinking`, `analyze_problem` - **VS Code**: `run_command`, `install_extension`, `open_file`, `create_task` **Dynamic Discovery Process:** ```ascii โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” MCP Protocol โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Agent โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ Agent โ”‚ โ”‚ Coordinator โ”‚ โ”‚ Coordinator โ”‚ โ”‚ โ”‚ initialize โ”‚ โ”‚ โ”‚ 1. Starts โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ 2. Responds โ”‚ โ”‚ External โ”‚ โ”‚ with info โ”‚ โ”‚ Server โ”‚ tools/list โ”‚ โ”‚ โ”‚ โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ 3. Returns โ”‚ โ”‚ 4. Registers โ”‚ โ”‚ tool list โ”‚ โ”‚ Tools โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### ๐ŸŽฏ Intelligent Tool Routing When an AI agent calls a tool, the coordinator intelligently routes the request: **Routing Logic:** 1. **Native Tools**: Handled directly by Agent Coordinator modules 2. **External Tools**: Routed to the appropriate external MCP server 3. **VS Code Tools**: Routed to integrated VS Code Tool Provider 4. **Unknown Tools**: Return helpful error with available alternatives **Automatic Task Tracking:** - Every tool call automatically creates or updates agent tasks - Maintains context of what agents are working on - Provides visibility into cross-agent coordination - Enables intelligent task distribution and conflict prevention **Example Tool Call Flow:** ```bash Agent calls "read_file" โ†’ Coordinator routes to filesystem server โ†’ Updates agent task โ†’ Sends heartbeat โ†’ Returns file content ``` ## ๐Ÿ› ๏ธ Prerequisites Choose one of these installation methods: ### Option 1: Docker (Recommended - No Elixir Installation Required) - **Docker**: 20.10+ and Docker Compose - **Node.js**: 18+ (for external MCP servers via bun) ### Option 2: Manual Installation - **Elixir**: 1.16+ with OTP 26+ - **Mix**: Comes with Elixir installation - **Node.js**: 18+ (for external MCP servers via bun) ## โšก Quick Start ### Option A: Docker Setup (Easiest) #### 1. Get the Code ```bash git clone https://github.com/your-username/agent_coordinator.git cd agent_coordinator ``` #### 2. Run with Docker Compose ```bash # Start the full stack (MCP server + NATS + monitoring) docker-compose up -d # Or start just the MCP server docker-compose up agent-coordinator # Check logs docker-compose logs -f agent-coordinator ``` #### 3. Configuration Edit `mcp_servers.json` to configure external MCP servers, then restart: ```bash docker-compose restart agent-coordinator ``` ### Option B: Manual Setup #### 1. Get the Code ```bash git clone https://github.com/your-username/agent_coordinator.git cd agent_coordinator mix deps.get ``` #### 2. Start the MCP Server ```bash # Start the MCP server directly ./scripts/mcp_launcher.sh # Or in development mode mix run --no-halt ``` ### 3. Configure Your AI Tools #### For Docker Setup If using Docker, the MCP server is available at the container's stdio interface. Add this to your VS Code `settings.json`: ```json { "github.copilot.advanced": { "mcp": { "servers": { "agent-coordinator": { "command": "docker", "args": ["exec", "-i", "agent-coordinator", "/app/scripts/mcp_launcher.sh"], "env": { "MIX_ENV": "prod" } } } } } } ``` #### For Manual Setup Add this to your VS Code `settings.json`: ```json { "github.copilot.advanced": { "mcp": { "servers": { "agent-coordinator": { "command": "/path/to/agent_coordinator/scripts/mcp_launcher.sh", "args": [], "env": { "MIX_ENV": "dev" } } } } } } } } ``` ### 4. Test It Works #### Docker Testing ```bash # Test with Docker docker-compose exec agent-coordinator /app/bin/agent_coordinator ping # Run example (if available in container) docker-compose exec agent-coordinator mix run examples/full_workflow_demo.exs # View logs docker-compose logs -f agent-coordinator ``` #### Manual Testing ```bash # Run the demo to see it in action mix run examples/full_workflow_demo.exs ``` ## ๐Ÿณ Docker Usage Guide ### Available Docker Commands #### Basic Operations ```bash # Build the image docker build -t agent-coordinator . # Run standalone container docker run -d --name agent-coordinator -p 4000:4000 agent-coordinator # Run with custom config docker run -d \ -v ./mcp_servers.json:/app/mcp_servers.json:ro \ -p 4000:4000 \ agent-coordinator ``` #### Docker Compose Operations ```bash # Start full stack docker-compose up -d # Start only agent coordinator docker-compose up -d agent-coordinator # View logs docker-compose logs -f agent-coordinator # Restart after config changes docker-compose restart agent-coordinator # Stop everything docker-compose down # Remove volumes (reset data) docker-compose down -v ``` #### Development with Docker ```bash # Start in development mode docker-compose -f docker-compose.yml -f docker-compose.dev.yml up # Interactive shell for debugging docker-compose exec agent-coordinator bash # Run tests in container docker-compose exec agent-coordinator mix test # Watch logs during development docker-compose logs -f ``` ### Environment Variables Configure the container using environment variables: ```bash # docker-compose.override.yml example version: '3.8' services: agent-coordinator: environment: - MIX_ENV=prod - NATS_HOST=nats - NATS_PORT=4222 - LOG_LEVEL=info ``` ### Custom Configuration #### External MCP Servers Mount your own `mcp_servers.json`: ```bash docker run -d \ -v ./my-mcp-config.json:/app/mcp_servers.json:ro \ agent-coordinator ``` #### Persistent Data ```bash docker run -d \ -v agent_data:/app/data \ -v nats_data:/data \ agent-coordinator ``` ### Monitoring & Health Checks #### Container Health ```bash # Check container health docker-compose ps # Health check details docker inspect --format='{{json .State.Health}}' agent-coordinator # Manual health check docker-compose exec agent-coordinator /app/bin/agent_coordinator ping ``` #### NATS Monitoring Access NATS monitoring dashboard: ```bash # Start with monitoring profile docker-compose --profile monitoring up -d # Access dashboard at http://localhost:8080 open http://localhost:8080 ``` ### Troubleshooting #### Common Issues ```bash # Check container logs docker-compose logs agent-coordinator # Check NATS connectivity docker-compose exec agent-coordinator nc -z nats 4222 # Restart stuck container docker-compose restart agent-coordinator # Reset everything docker-compose down -v && docker-compose up -d ``` #### Performance Tuning ```bash # Allocate more memory docker-compose up -d --scale agent-coordinator=1 \ --memory=1g --cpus="2.0" ``` ## ๐ŸŽฎ How to Use Once your AI agents are connected via MCP, they can: ### Register as an Agent ```bash # An agent identifies itself with capabilities register_agent("GitHub Copilot", ["coding", "testing"], codebase_id: "my-project") ``` ### Create Tasks ```bash # Tasks are created with requirements create_task("Fix login bug", "Authentication fails on mobile", priority: "high", required_capabilities: ["coding", "debugging"] ) ``` ### Coordinate Automatically The coordinator automatically: - **Matches** tasks to agents based on capabilities - **Queues** tasks when no suitable agents are available - **Tracks** agent heartbeats to ensure they're still working - **Handles** cross-codebase tasks that span multiple repositories ### Available MCP Tools All MCP-compatible AI agents get these tools automatically: | Tool | Purpose | |------|---------| | `register_agent` | Register an agent with capabilities | | `create_task` | Create a new task with requirements | | `get_next_task` | Get the next task assigned to an agent | | `complete_task` | Mark current task as completed | | `get_task_board` | View all agents and their status | | `heartbeat` | Send agent heartbeat to stay active | | `register_codebase` | Register a new codebase/repository | | `create_cross_codebase_task` | Create tasks spanning multiple repos | ## ๐Ÿงช Development & Testing ### Running Tests ```bash # Run all tests mix test # Run with coverage mix test --cover # Try the examples mix run examples/full_workflow_demo.exs mix run examples/auto_heartbeat_demo.exs ``` ### Code Quality ```bash # Format code mix format # Run static analysis mix credo # Type checking mix dialyzer ``` ## ๐Ÿ“ Project Structure ```text agent_coordinator/ โ”œโ”€โ”€ lib/ โ”‚ โ”œโ”€โ”€ agent_coordinator.ex # Main module โ”‚ โ””โ”€โ”€ agent_coordinator/ โ”‚ โ”œโ”€โ”€ mcp_server.ex # MCP protocol implementation โ”‚ โ”œโ”€โ”€ task_registry.ex # Task management โ”‚ โ”œโ”€โ”€ agent.ex # Agent management โ”‚ โ”œโ”€โ”€ codebase_registry.ex # Multi-repository support โ”‚ โ””โ”€โ”€ application.ex # Application supervisor โ”œโ”€โ”€ examples/ # Working examples โ”œโ”€โ”€ test/ # Test suite โ”œโ”€โ”€ scripts/ # Helper scripts โ””โ”€โ”€ docs/ # Technical documentation โ”œโ”€โ”€ README.md # Documentation index โ”œโ”€โ”€ AUTO_HEARTBEAT.md # Unified MCP server details โ”œโ”€โ”€ VSCODE_TOOL_INTEGRATION.md # VS Code integration โ””โ”€โ”€ LANGUAGE_IMPLEMENTATIONS.md # Alternative language guides ``` ## ๐Ÿค” Why This Design? **The Problem**: Multiple AI agents working on the same codebase step on each other, duplicate work, or create conflicts. **The Solution**: A coordination layer that: - Lets agents register their capabilities - Intelligently distributes tasks - Tracks progress and prevents conflicts - Scales across multiple repositories **Why Elixir?**: Built-in concurrency, fault tolerance, and excellent for coordination systems. ## ๐Ÿš€ Alternative Implementations While this Elixir version works great, you might want to consider these languages for broader adoption: ### Go Implementation - **Pros**: Single binary deployment, great performance, large community - **Cons**: More verbose concurrency patterns - **Best for**: Teams wanting simple deployment and good performance ### Python Implementation - **Pros**: Huge ecosystem, familiar to most developers, excellent tooling - **Cons**: GIL limitations for true concurrency - **Best for**: AI/ML teams already using Python ecosystem ### Rust Implementation - **Pros**: Maximum performance, memory safety, growing adoption - **Cons**: Steeper learning curve, smaller ecosystem - **Best for**: Performance-critical deployments ### Node.js Implementation - **Pros**: JavaScript familiarity, event-driven nature fits coordination - **Cons**: Single-threaded limitations, callback complexity - **Best for**: Web teams already using Node.js ## ๐Ÿค Contributing Contributions are welcome! Here's how: 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add some amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines. ## ๐Ÿ“„ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - [Model Context Protocol](https://modelcontextprotocol.io/) for the agent communication standard - [Elixir](https://elixir-lang.org/) community for the excellent ecosystem - AI development teams pushing the boundaries of collaborative coding --- **Agent Coordinator** - Making AI agents work together, not against each other.