agent-pool-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vladislav Matiyasevich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # agent-pool-mcp
2
+
3
+ **MCP server for multi-agent orchestration** — parallel task delegation and cross-model peer review via [Gemini CLI](https://github.com/google-gemini/gemini-cli).
4
+
5
+ > Developed by [RND-PRO](https://rnd-pro.com)
6
+
7
+ Compatible with [Antigravity](https://antigravity.dev), Cursor, Windsurf, Claude Code, and any MCP-enabled coding agent.
8
+
9
+ ## Why?
10
+
11
+ AI coding assistants are powerful, but they work **sequentially** — one task at a time. Agent-pool turns your single Gemini subscription into a **parallel agent workforce**: your primary IDE agent delegates background tasks to Gemini CLI workers, all sharing the same authentication.
12
+
13
+ When the primary agent and Gemini workers are **different foundation models** (e.g. Claude + Gemini), `consult_peer` becomes a **cross-model reasoning amplifier** — two independent architectures reviewing each other eliminate systematic blind spots that plague single-model workflows.
14
+
15
+ ## How It Works
16
+
17
+ ```
18
+ ┌─────────────────────────────────┐
19
+ │ Primary IDE Agent │ ← Claude, GPT, Gemini, etc.
20
+ │ (Antigravity / Cursor / ...) │
21
+ └────────────┬────────────────────┘
22
+ │ MCP (stdio)
23
+ ┌────────────▼────────────────────┐
24
+ │ agent-pool-mcp │ ← This server
25
+ │ (task router + process mgmt) │
26
+ └──┬─────────┬─────────┬─────────┘
27
+ │ │ │
28
+ ▼ ▼ ▼
29
+ gemini gemini gemini ← Gemini CLI workers
30
+ (task1) (task2) (review) (same auth, parallel)
31
+ ```
32
+
33
+ ## Features
34
+
35
+ ### 🚀 Task Delegation
36
+ - **`delegate_task`** — Non-blocking task delegation to Gemini CLI (full filesystem access).
37
+ - **`delegate_task_readonly`** — Read-only analysis (plan mode). Supports `session_id` to resume previous analyses.
38
+ - **`get_task_result`** — Poll task status, retrieve results, and see live progress (last 200 tool/message events).
39
+ - **`cancel_task`** — Kill a running task and its entire process group immediately.
40
+
41
+ ### 📋 3-Tier Skill System
42
+ Skills are Markdown files with YAML frontmatter that extend agent behavior. Agent-pool manages skills in three tiers:
43
+ 1. **Project**: `.gemini/skills/` (local to repo, takes precedence).
44
+ 2. **Global**: `~/.gemini/skills/` (available across all projects).
45
+ 3. **Built-in**: Shipped with agent-pool (e.g., `code-reviewer`, `test-writer`, `doc-fixer`).
46
+
47
+ **Skill Tools:**
48
+ - **`list_skills`** — See all available skills and their tiers.
49
+ - **`install_skill`** — Copy a global or built-in skill to the project tier for local customization.
50
+ - **`create_skill` / `delete_skill`** — Manage skill files in project or global scope.
51
+
52
+ *Note: When delegating with a skill, agent-pool uses "hybrid activation" — it ensures the skill is available in the project and instructs Gemini CLI to activate it natively.*
53
+
54
+ ### 🛡️ Per-Task Policies
55
+ Restrict tool usage for specific tasks using YAML policies. Use built-in templates or custom paths:
56
+ - `policy: "read-only"` — Disables all file-writing and destructive shell tools.
57
+ - `policy: "safe-edit"` — Allows file modifications but blocks arbitrary shell execution.
58
+ - `policy: "/path/to/my-policy.yaml"` — Use a custom security policy.
59
+
60
+ ### 🤝 Cross-Model Peer Review
61
+ - **`consult_peer`** — Architectural review with structured verdicts (AGREE / SUGGEST_CHANGES / DISAGREE).
62
+ - Supports iterative rounds: propose → get feedback → revise → re-send until consensus.
63
+
64
+ ### 📊 System Awareness & Management
65
+ - **System Load Detection**: Automatically detects other running Gemini processes on the system and warns if the worker pool is saturated.
66
+ - **Session Management**: `list_sessions` allows resuming previous Gemini CLI conversations by UUID.
67
+
68
+ ## Remote Workers (SSH)
69
+
70
+ Run workers on remote servers via SSH — same interface, transparent stdio forwarding.
71
+ Create `agent-pool.config.json` in your project root or `~/.config/agent-pool/config.json`:
72
+
73
+ ```json
74
+ {
75
+ "runners": [
76
+ { "id": "local", "type": "local" },
77
+ { "id": "gpu", "type": "ssh", "host": "gpu-server", "cwd": "/home/dev/project" }
78
+ ],
79
+ "defaultRunner": "local"
80
+ }
81
+ ```
82
+
83
+ ## Nested Orchestration
84
+
85
+ Install agent-pool inside Gemini CLI to enable **hierarchical delegation** — workers can spawn their own workers.
86
+
87
+ | Variable | Purpose | Default |
88
+ |----------|---------|--------|
89
+ | `AGENT_POOL_DEPTH` | Current nesting level (auto-incremented) | `0` |
90
+ | `AGENT_POOL_MAX_DEPTH` | Max allowed depth | not set (no limit) |
91
+
92
+ See [parallel-work guide](examples/parallel-work.md) and built-in `orchestrator` skill for patterns.
93
+
94
+ ## Prerequisites
95
+
96
+ - **Node.js >= 20** — [Download](https://nodejs.org)
97
+ - **[Gemini CLI](https://github.com/google-gemini/gemini-cli)** — installed and authenticated:
98
+
99
+ ```bash
100
+ npm install -g @google/gemini-cli
101
+ gemini # First run: opens browser for OAuth
102
+ ```
103
+
104
+ ## Installation
105
+
106
+ Add to your IDE's MCP configuration:
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "agent-pool": {
112
+ "command": "npx",
113
+ "args": ["-y", "agent-pool-mcp"]
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ Restart your IDE — agent-pool-mcp will be downloaded and started automatically.
120
+
121
+ <details>
122
+ <summary>📍 Where is my MCP config file?</summary>
123
+
124
+ | IDE | Config path |
125
+ |-----|------------|
126
+ | Antigravity | `~/.gemini/antigravity/mcp_config.json` |
127
+ | Cursor | `.cursor/mcp.json` |
128
+ | Windsurf | `.windsurf/mcp.json` |
129
+ | Claude Code | Run: `claude mcp add agent-pool npx -y agent-pool-mcp` |
130
+
131
+ </details>
132
+
133
+ <details>
134
+ <summary>📦 Alternative: global install</summary>
135
+
136
+ ```bash
137
+ npm install -g agent-pool-mcp
138
+ ```
139
+
140
+ Then use `"command": "agent-pool-mcp"` in your MCP config (no npx needed).
141
+
142
+ </details>
143
+
144
+ ### Verify
145
+
146
+ ```bash
147
+ npx agent-pool-mcp --check
148
+ ```
149
+
150
+ This runs diagnostics: checks Node.js, Gemini CLI, authentication, and remote runner connectivity.
151
+
152
+ ### CLI Commands
153
+
154
+ ```bash
155
+ npx agent-pool-mcp --check # Doctor mode: diagnose prerequisites
156
+ npx agent-pool-mcp --init # Create template config (for SSH runners)
157
+ npx agent-pool-mcp --version # Show version
158
+ npx agent-pool-mcp --help # Full help
159
+ ```
160
+
161
+ ## MCP Ecosystem
162
+
163
+ Agent-pool works alongside other MCP servers:
164
+
165
+ | Layer | agent-pool-mcp | [project-graph-mcp](https://github.com/rnd-pro/project-graph-mcp) |
166
+ |-------|---------------|-------------------|
167
+ | **Primary IDE agent** | Delegates tasks, consults peer | Navigates codebase, runs analysis |
168
+ | **Gemini CLI workers** | Executes delegated tasks | Available as MCP tool inside Gemini CLI |
169
+
170
+ ## Security
171
+
172
+ - **Path Traversal Protection**: All skill and policy operations are sanitized to prevent access outside designated directories.
173
+ - **Process Isolation**: Tasks run as detached processes; `cancel_task` and server shutdown ensure no zombie processes remain by killing entire process groups.
174
+ - **Credential Safety**: Uses your local Gemini CLI authentication; no keys are stored or transmitted by this server.
175
+
176
+ ## Architecture
177
+
178
+ ```
179
+ index.js ← Entry point (stdio transport)
180
+ policies/ ← Tool restriction policies (YAML)
181
+ ├── read-only.yaml
182
+ └── safe-edit.yaml
183
+ skills/ ← Built-in Gemini CLI skills (Markdown)
184
+ ├── code-reviewer.md
185
+ ├── doc-fixer.md
186
+ ├── orchestrator.md
187
+ └── test-writer.md
188
+ src/
189
+ ├── cli.js ← CLI commands (--check, --init, --help)
190
+ ├── server.js ← MCP server setup + tool routing
191
+ ├── tool-definitions.js ← Tool schemas (JSON Schema)
192
+ ├── tools/
193
+ │ ├── consult.js ← Peer review via Gemini CLI
194
+ │ ├── results.js ← Task store + result formatting (TTL cleanup, ring buffer)
195
+ │ └── skills.js ← 3-tier skill management (project/global/built-in)
196
+ └── runner/
197
+ ├── config.js ← Runner config loader (local/SSH)
198
+ ├── gemini-runner.js ← Process spawning (streaming JSON, depth tracking)
199
+ ├── process-manager.js ← PID tracking, system load awareness, group kill
200
+ └── ssh.js ← Shell escaping, remote PID tracking
201
+ ```
202
+
203
+ **Process management:**
204
+ - **Detached Spawn**: Workers are spawned in their own process groups.
205
+ - **TTL Cleanup**: Completed task results are purged from memory after 10 minutes.
206
+ - **Live Events**: Progress polling uses a ring buffer to show the latest activity without overwhelming context.
207
+ - **Depth Tracking**: Nested orchestration support with optional `AGENT_POOL_MAX_DEPTH` limit.
208
+
209
+ ## License
210
+
211
+ MIT
package/index.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Agent Pool MCP Server — Entry Point
5
+ *
6
+ * Multi-agent task delegation and orchestration via Gemini CLI.
7
+ * Supports CLI modes: --check, --init, --version, --help.
8
+ *
9
+ * @module agent-pool
10
+ */
11
+
12
+ import { handleCli, validateStartup } from './src/cli.js';
13
+
14
+ // CLI mode: --check, --init, --version, --help
15
+ if (handleCli(process.argv)) {
16
+ // CLI command handled, don't start MCP server
17
+ } else {
18
+ // MCP server mode
19
+ startServer();
20
+ }
21
+
22
+ async function startServer() {
23
+ // Warn if prerequisites are missing (don't exit — let the agent handle it)
24
+ validateStartup();
25
+
26
+ // Import MCP deps only when starting server
27
+ const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
28
+ const { createServer } = await import('./src/server.js');
29
+
30
+ // Register SIGTERM/SIGINT handlers for process cleanup
31
+ await import('./src/runner/process-manager.js');
32
+
33
+ const server = createServer();
34
+ const transport = new StdioServerTransport();
35
+ await server.connect(transport);
36
+ console.error('[agent-pool] MCP server v1.0.0 started');
37
+ }
38
+
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "agent-pool-mcp",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "MCP Server for multi-agent task delegation and orchestration via Gemini CLI",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "agent-pool-mcp": "index.js"
9
+ },
10
+ "files": [
11
+ "index.js",
12
+ "src/",
13
+ "policies/",
14
+ "skills/",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "start": "node index.js"
20
+ },
21
+ "keywords": [
22
+ "mcp",
23
+ "model-context-protocol",
24
+ "gemini",
25
+ "gemini-cli",
26
+ "agent",
27
+ "multi-agent",
28
+ "delegation",
29
+ "orchestration",
30
+ "ai"
31
+ ],
32
+ "author": "Vladislav Matiyasevich",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/rnd-pro/agent-pool-mcp.git"
37
+ },
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.12.0"
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ # Read-only policy — prevents file modifications
2
+ # Use with delegate_task(policy: "read-only") for safe analysis tasks
3
+
4
+ - rule: ALWAYS deny
5
+ tool: write_file
6
+ - rule: ALWAYS deny
7
+ tool: edit_file
8
+ - rule: ALWAYS deny
9
+ tool: replace_file
10
+ - rule: ALWAYS deny
11
+ tool: delete_file
12
+ - rule: ALWAYS deny
13
+ tool: run_shell_command
@@ -0,0 +1,7 @@
1
+ # Safe-edit policy — allows file edits but denies shell commands
2
+ # Use with delegate_task(policy: "safe-edit") for code-only tasks
3
+
4
+ - rule: ALWAYS deny
5
+ tool: run_shell_command
6
+ - rule: ALWAYS deny
7
+ tool: delete_file
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Reviews code changes for bugs, style issues, and potential improvements.
4
+ ---
5
+
6
+ # Code Reviewer
7
+
8
+ You are a senior code reviewer. Analyze the given code or diff carefully.
9
+
10
+ ## Review Checklist
11
+
12
+ 1. **Correctness** — Does the code do what it's supposed to?
13
+ 2. **Edge cases** — Are boundary conditions handled?
14
+ 3. **Error handling** — Are errors caught and reported properly?
15
+ 4. **Performance** — Any obvious inefficiencies?
16
+ 5. **Security** — Any potential vulnerabilities?
17
+ 6. **Style** — Consistent naming, formatting, documentation?
18
+ 7. **DRY** — Any duplicated logic that should be extracted?
19
+
20
+ ## Output Format
21
+
22
+ ```markdown
23
+ ## Review Summary
24
+ **Verdict**: ✅ APPROVE / ⚠️ NEEDS CHANGES / ❌ REJECT
25
+
26
+ ### Issues Found
27
+ 1. **[severity]** file:line — description
28
+ - Suggestion: ...
29
+
30
+ ### Positive Notes
31
+ - What's done well
32
+ ```
33
+
34
+ ## Rules
35
+ - Be specific: cite file names and line numbers
36
+ - Prioritize: critical bugs > security > performance > style
37
+ - Keep feedback actionable — every issue should have a fix suggestion
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: doc-fixer
3
+ description: Fixes documentation formatting errors and adds missing docs to code.
4
+ ---
5
+
6
+ # Documentation Fixer
7
+
8
+ You are a documentation specialist. Fix all doc issues in the given files.
9
+
10
+ ## Process
11
+
12
+ 1. Detect the project's documentation style (JSDoc, docstrings, Javadoc, etc.)
13
+ 2. Fix formatting errors (unclosed tags, missing types, broken syntax)
14
+ 3. Add missing documentation to public functions/methods
15
+ 4. Preserve existing descriptions — only fix formatting
16
+
17
+ ## Rules
18
+ - Follow the project's existing documentation conventions
19
+ - Short obvious functions (getters, simple returns) don't need docs
20
+ - Be precise with types — avoid generic `any` or `object` when more specific types are available
21
+ - Don't add excess comments to self-explanatory code
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: orchestrator
3
+ description: Enables hierarchical task delegation — the agent can decompose complex tasks and delegate sub-tasks to its own Gemini CLI workers via agent-pool.
4
+ ---
5
+
6
+ # Orchestrator
7
+
8
+ You are a task orchestrator. Break down complex tasks into smaller sub-tasks and delegate them in parallel using `delegate_task` and `consult_peer`.
9
+
10
+ ## When to Orchestrate
11
+
12
+ Use this pattern when:
13
+ - A task involves **3+ files** that can be worked on independently
14
+ - A task has **distinct phases** (research → plan → implement → verify)
15
+ - A task spans **multiple modules** with clear boundaries
16
+ - You receive a request that would take **10+ minutes** as a single agent
17
+
18
+ ## Decomposition Rules
19
+
20
+ 1. **Split by file ownership** — each sub-task works on separate files
21
+ 2. **Split by concern** — research vs implementation vs testing
22
+ 3. **Keep sub-tasks atomic** — each should produce a verifiable output
23
+ 4. **Provide full context** — sub-tasks don't see your conversation history
24
+
25
+ ## Delegation Template
26
+
27
+ ```
28
+ Task: [clear one-paragraph description]
29
+
30
+ Context:
31
+ - Project: [tech stack, key patterns]
32
+ - Files to modify: [exact paths]
33
+ - Constraints: [don't touch X, follow Y pattern]
34
+
35
+ Expected output:
36
+ - [what files should be created/modified]
37
+ - [what should be verified]
38
+ ```
39
+
40
+ ## Parallel Execution
41
+
42
+ ```javascript
43
+ // Phase 1: Parallel research
44
+ delegate_task_readonly({ prompt: "Analyze module A..." }) // → task_1
45
+ delegate_task_readonly({ prompt: "Analyze module B..." }) // → task_2
46
+ delegate_task_readonly({ prompt: "Analyze module C..." }) // → task_3
47
+
48
+ // Phase 2: Collect results
49
+ get_task_result(task_1)
50
+ get_task_result(task_2)
51
+ get_task_result(task_3)
52
+
53
+ // Phase 3: Plan based on findings
54
+ consult_peer({ proposal: "Based on analysis..." })
55
+
56
+ // Phase 4: Parallel implementation
57
+ delegate_task({ prompt: "Refactor module A..." }) // → task_4
58
+ delegate_task({ prompt: "Refactor module B..." }) // → task_5
59
+
60
+ // Phase 5: Verify
61
+ delegate_task_readonly({ prompt: "Run tests and verify..." })
62
+ ```
63
+
64
+ ## Resource Awareness
65
+
66
+ - Check system load before spawning many workers
67
+ - On a laptop: **2-3 parallel tasks** max
68
+ - On a server: **5-8 parallel tasks** are feasible
69
+ - If `get_task_result` shows system load warnings — wait before spawning more
70
+
71
+ ## Rules
72
+
73
+ - **Never delegate what you can answer from context** — delegation has overhead
74
+ - **Always collect results** — don't fire-and-forget
75
+ - **Respect file ownership** — no two sub-tasks edit the same file
76
+ - **Provide enough context** — sub-tasks are stateless
77
+ - **Verify after delegation** — check that sub-task output is correct
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: test-writer
3
+ description: Generates test cases for functions and modules using the project's test framework.
4
+ ---
5
+
6
+ # Test Writer
7
+
8
+ You are a test engineer. Write comprehensive tests for the given code.
9
+
10
+ ## Process
11
+
12
+ 1. Read the source file and understand the API
13
+ 2. Detect the project's test framework from config files (package.json, pytest.ini, etc.)
14
+ 3. Write test cases covering:
15
+ - Happy path (normal usage)
16
+ - Edge cases (empty input, null, boundary values)
17
+ - Error cases (invalid input, missing params)
18
+ - Return value validation
19
+
20
+ ## Rules
21
+ - Use the project's existing test framework and conventions
22
+ - Each test should be independent (no shared mutable state)
23
+ - Name tests descriptively: `should [expected behavior] when [condition]`
24
+ - Mock external dependencies (DB, HTTP, filesystem) when needed
25
+ - Follow the project's directory structure for test file placement