HiveMind
Orchestrates multiple AI coding agents using the Copilot CLI as the underlying intelligence engine for parallel task execution, hierarchical planning, and safe concurrent file access.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@HiveMindparallel code review for all changed files"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π HiveMind - MCP Subagent Orchestrator
A high-concurrency, asynchronous MCP (Model Context Protocol) Orchestrator that coordinates multiple AI coding agents using the Copilot CLI as the underlying intelligence engine. Built on an Actor Model architecture for non-blocking operations, robust fault tolerance, and strict resource synchronization.
π Table of Contents
Related MCP server: session-coord-mcp
π― Overview
HiveMind enables a Main Agent to spawn and coordinate multiple Subagents, each running isolated Copilot CLI instances. This allows for:
Parallel task execution across multiple files/modules
Hierarchical planning with dependency-aware scheduling
Safe concurrent file access via lock management
Unified observability with structured logging and tracing
Problem Solved
Traditional single-agent coding assistants struggle with:
Large codebases requiring parallel analysis
Multi-file refactoring with dependencies
Long-running tasks that block the main thread
Resource contention when multiple tools access files
HiveMind solves these by orchestrating a swarm of specialized agents that work concurrently while respecting file locks and execution order.
β¨ Key Features
Feature | Description |
π Autonomous Execution | Submit a task and let the orchestrator plan, schedule, and execute without polling |
π File Locking (Warden) | Pessimistic locking with deadlock detection and wait queues |
π Hierarchical Planning | Break complex tasks into dependency graphs with parallel execution groups |
π MCP Integration | Exposes orchestration capabilities as MCP tools |
π Observability | Structured logging, OpenTelemetry tracing, and real-time metrics |
πΎ Persistence | SQLite-based checkpointing with crash recovery |
ποΈ Dashboard | REST API + WebSocket for real-time monitoring |
ποΈ Architecture
HiveMind uses a three-layer architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONTROL PLANE β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββ βββββββββββββββββββββββ β
β β Orchestratorβ βTask Planner β β Scheduler β β Resource Warden β β
β β Core ββββ (Decomposer) ββββ ββββ (Lock Manager) β β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA PLANE β
β ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β Event Bus (IPC) β β Trace Aggregator β β
β β Pub/Sub Message Passing β β Logs, Metrics, Spans β β
β ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXECUTION PLANE β
β βββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββββββββββ β
β β Agent Pod β β Agent Pod β β Agent Pod β ... β Copilot CLI β β
β β 1 β β 2 β β N β β (Child Process) β β
β βββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββRequest Flow
Main Agent calls MCP tool (e.g.,
submit_task_auto)Planner analyzes task, creates dependency graph
Scheduler creates execution groups respecting dependencies
Warden acquires file locks before each group executes
Agent Pods spawn Copilot CLI processes in parallel
Results aggregated and returned to Main Agent
π§© Components
Core Components
Component | Location | Description |
Orchestrator Core |
| Central coordination, lifecycle management |
Agent Manager |
| Agent pool, pod lifecycle, message routing |
Event Bus |
| Pub/sub messaging, async communication |
Lock Manager |
| File locking, deadlock detection, wait queues |
Planner |
| Task decomposition, dependency graphs |
CLI Adapter |
| Copilot CLI spawning, I/O handling |
MCP Layer |
| Tool definitions, request handling |
Tracing |
| Structured logging, OpenTelemetry |
Persistence |
| SQLite, checkpointing, recovery |
Dashboard |
| REST API, WebSocket server |
Type System
Module | Description |
| Agent status, config, results |
| Job lifecycle, subtasks, progress |
| Lock modes, handles, conflicts |
| Event bus messages, channels |
| MCP tool schemas, responses |
| CLI command construction, options |
π¦ Installation
Prerequisites
Node.js 20+
npm or yarn
GitHub Copilot CLI installed and authenticated
Git for version control
Install
# Clone the repository
git clone https://github.com/sureshsankaran/mcp-subagent-orchestrator.git
cd mcp-subagent-orchestrator
# Install dependencies
npm install
# Build the project
npm run buildVerify Installation
# Run tests
npm test
# Check build output
ls dist/Quick Demo
Run the end-to-end demo to see all features in action:
# Run comprehensive demo showcasing all phases (1-7)
npm run demo:e2e
# Run basic component demo
npm run demoThe demo showcases:
Event Bus - Pub/sub messaging with wildcard patterns
State Machine - Agent lifecycle transitions
Lock Manager - Resource locking with deadlock detection
DAG - Task dependency graphs with parallel execution groups
MCP Tools - 14+ orchestration tools exposed via MCP
Structured Logging - Winston logger with JSON/pretty formats
Distributed Tracing - OpenTelemetry integration
Metrics Registry - Counters, histograms, and gauges
Health Checks - Component health monitoring
Full Orchestration - End-to-end task execution simulation
π Usage
As an MCP Server
Register HiveMind as an MCP server in your AI tool configuration:
{
"mcpServers": {
"hivemind": {
"command": "node",
"args": ["path/to/mcp-subagent-orchestrator/dist/index.js"],
"env": {
"GH_TOKEN": "your-github-token"
}
}
}
}Programmatic Usage
import { OrchestratorCore, OrchestratorConfig } from 'mcp-subagent-orchestrator';
// Create orchestrator
const config: OrchestratorConfig = {
maxConcurrentAgents: 5,
workspacePath: '/path/to/workspace',
persistence: {
enabled: true,
dbPath: '.hivemind/state.db'
}
};
const orchestrator = new OrchestratorCore(config);
await orchestrator.initialize();
// Spawn a single agent
const agent = await orchestrator.spawnAgent('Fix the authentication bug in auth.ts');
const result = await orchestrator.waitForAgent(agent.id);
// Submit an autonomous job
const job = await orchestrator.submitJob('Refactor the entire API layer to use async/await');
const status = await orchestrator.waitForJob(job.id);MCP Tool Examples
// Spawn a focused subagent
await mcp.callTool('spawn_agent', {
task: 'Review auth.ts for security vulnerabilities',
config: {
system_instruction: 'You are a security expert. Be thorough.',
allowed_paths: ['src/auth/'],
read_only: true
}
});
// Submit autonomous job (orchestrator handles everything)
await mcp.callTool('submit_task_auto', {
instruction: 'Add comprehensive unit tests to all service files',
strategy: 'parallel',
max_agents: 4
});
// Monitor job progress
await mcp.callTool('get_job_status', { job_id: 'job-123' });
// Acquire file lock (for manual coordination)
await mcp.callTool('acquire_lock', {
resource: 'src/api/users.ts',
mode: 'exclusive',
timeout_ms: 30000
});βοΈ Configuration
Environment Variables
Variable | Description | Default |
| GitHub token with Copilot access | Required |
| Logging level (debug/info/warn/error) |
|
| Maximum concurrent agents |
|
| SQLite database path |
|
| Dashboard server port |
|
| Override detected CLI type ( | auto-detect |
| Absolute path to CLI binary (bypass detection) | auto-detect |
| Enable OpenTelemetry |
|
Orchestrator Config (file-first)
Configuration is loaded in this order: user overrides β env β hivemind.config.json β defaults.
Add a hivemind.config.json at the repo root to set project-wide defaults (used for both decomposition and spawned agents):
{
"cli": {
// Force a specific adapter type instead of auto-preference (copilot_v2 > copilot_v1 > codex > gh_copilot > claude)
"preferred_cli_type": "codex",
// Optional explicit binary path (skips detection)
"preferred_cli_path": "/usr/local/bin/codex",
// Existing options
"cli_command": "copilot",
"default_timeout_ms": 300000,
"auto_approve_tools": true
}
}interface OrchestratorConfig {
// Agent management
maxConcurrentAgents: number; // Max parallel agents
agentTimeout: number; // Agent execution timeout (ms)
agentPoolSize: number; // Pre-warmed agent pool size
// Workspace
workspacePath: string; // Root workspace path
trustedFolders: string[]; // Pre-trusted Copilot folders
// Locking
lockTimeout: number; // Default lock acquisition timeout
deadlockDetection: boolean; // Enable deadlock detection
// Persistence
persistence: {
enabled: boolean;
dbPath: string;
checkpointInterval: number; // Checkpoint frequency (ms)
};
// Observability
logging: {
level: 'debug' | 'info' | 'warn' | 'error';
format: 'json' | 'pretty';
};
// Security
toolApproval: {
allowedShellCommands: string[];
deniedShellCommands: string[];
};
// CLI (decomposition + spawned agents)
cli: {
cli_command: string;
preferred_cli_type?: 'copilot_v2' | 'copilot_v1' | 'codex' | 'gh_copilot' | 'claude' | 'unknown';
preferred_cli_path?: string;
default_timeout_ms: number;
auto_approve_tools: boolean;
};
}π API Reference
MCP Tools
Tool | Description |
| Spawn a single subagent with a task |
| Submit job for autonomous execution |
| Get current job status and progress |
| Get hierarchical view of job subtasks |
| Cancel a running job |
| Manually acquire a file lock |
| Release a held lock |
| List all active locks |
| Stream logs for job/agent |
| Get orchestrator health status |
REST API Endpoints
Endpoint | Method | Description |
| GET | List all agents |
| POST | Spawn new agent |
| GET | Get agent details |
| DELETE | Kill agent |
| GET | List all jobs |
| POST | Submit new job |
| GET | Get job details |
| POST | Cancel job |
| GET | List active locks |
| GET | Health check |
| GET | Prometheus metrics |
π οΈ Development
Scripts
# Build TypeScript
npm run build
# Watch mode
npm run build:watch
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Lint code
npm run lint
npm run lint:fix
# Format code
npm run format
# Clean build artifacts
npm run cleanTesting
# Run all tests
npm test
# Run specific test file
npm test -- tests/unit/locks/LockManager.test.ts
# Run with coverage
npm run test:coverageCode Quality
ESLint for linting
Prettier for formatting
Jest for testing
TypeScript strict mode enabled
π Project Structure
mcp-subagent-orchestrator/
βββ src/
β βββ agents/ # Agent pod management
β βββ cli/ # Copilot CLI adapter
β βββ core/ # Orchestrator core
β βββ dashboard/ # REST API & WebSocket
β βββ errors/ # Custom error classes
β βββ ipc/ # Event bus & messaging
β βββ locks/ # Lock manager (Warden)
β βββ mcp/ # MCP tool definitions
β βββ persistence/ # SQLite & checkpointing
β βββ planner/ # Task decomposition
β βββ tracing/ # Logging & telemetry
β βββ types/ # TypeScript interfaces
β βββ utils/ # Shared utilities
β βββ index.ts # Main entry point
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
βββ tasks/ # Phase task breakdowns
βββ dist/ # Compiled output
βββ spec.md # Full specification
βββ TASKS.md # Development roadmap
βββ package.jsonπΊοΈ Roadmap
The project is developed in 9 phases:
Phase | Name | Status | Tasks |
1 | Project Skeleton & Interfaces | β Complete | 68 |
2 | Nervous System (EventBus/IPC) | π In Progress | 52 |
3 | CLI Abstraction Layer | β³ Planned | 68 |
4 | File Warden (Lock Manager) | β³ Planned | 58 |
5 | Hierarchical Planner | β³ Planned | 72 |
6 | MCP Exposure | β³ Planned | 58 |
7 | Observability | β³ Planned | 52 |
8 | Persistence & Recovery | β³ Planned | 62 |
9 | Dashboard & REST API | β³ Planned | 55 |
Total: ~542 detailed subtasks
See TASKS.md for detailed task breakdowns.
π€ Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Development Guidelines
Follow TypeScript strict mode
Write tests for new features
Update documentation as needed
Use conventional commit messages
π License
This project is licensed under the ISC License - see the LICENSE file for details.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sureshsankaran/mcp-subagent-orchestrator'
If you have feedback or need assistance with the MCP directory API, please join our Discord server