sub-agents-mcp 0.14.0 → 0.14.2
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/README.md +67 -544
- package/dist/agents/AgentManager.d.ts +16 -0
- package/dist/agents/AgentManager.d.ts.map +1 -1
- package/dist/agents/AgentManager.js +68 -43
- package/dist/agents/AgentManager.js.map +1 -1
- package/dist/agents/AgentName.d.ts +15 -0
- package/dist/agents/AgentName.d.ts.map +1 -0
- package/dist/agents/AgentName.js +40 -0
- package/dist/agents/AgentName.js.map +1 -0
- package/dist/config/ServerConfig.d.ts.map +1 -1
- package/dist/config/ServerConfig.js +101 -70
- package/dist/config/ServerConfig.js.map +1 -1
- package/dist/execution/AgentExecutor.d.ts +27 -3
- package/dist/execution/AgentExecutor.d.ts.map +1 -1
- package/dist/execution/AgentExecutor.js +328 -197
- package/dist/execution/AgentExecutor.js.map +1 -1
- package/dist/execution/StreamProcessor.d.ts.map +1 -1
- package/dist/execution/StreamProcessor.js +17 -16
- package/dist/execution/StreamProcessor.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/AgentResources.d.ts.map +1 -1
- package/dist/resources/AgentResources.js +2 -8
- package/dist/resources/AgentResources.js.map +1 -1
- package/dist/server/McpServer.d.ts.map +1 -1
- package/dist/server/McpServer.js +40 -21
- package/dist/server/McpServer.js.map +1 -1
- package/dist/session/SessionManager.d.ts +11 -1
- package/dist/session/SessionManager.d.ts.map +1 -1
- package/dist/session/SessionManager.js +118 -28
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/tools/RunAgentTool.d.ts +32 -9
- package/dist/tools/RunAgentTool.d.ts.map +1 -1
- package/dist/tools/RunAgentTool.js +281 -190
- package/dist/tools/RunAgentTool.js.map +1 -1
- package/dist/types/ExecutionParams.d.ts +0 -1
- package/dist/types/ExecutionParams.d.ts.map +1 -1
- package/dist/types/SessionData.d.ts +6 -1
- package/dist/types/SessionData.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.d.ts +14 -2
- package/dist/utils/ErrorHandler.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.js +40 -9
- package/dist/utils/ErrorHandler.js.map +1 -1
- package/dist/utils/Logger.d.ts.map +1 -1
- package/dist/utils/Logger.js +3 -2
- package/dist/utils/Logger.js.map +1 -1
- package/package.json +10 -14
package/README.md
CHANGED
|
@@ -3,417 +3,47 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/sub-agents-mcp)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Run reusable coding agents from any MCP-compatible client.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Write a reviewer, test writer, or investigator in Markdown, then ask your assistant to use it. The MCP server runs that agent with the coding CLI you choose and returns the result to the same conversation.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## What You Can Do
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Define reusable agents once, use them across multiple tools
|
|
16
|
-
- Share agent definitions within teams regardless of IDE choice
|
|
17
|
-
- Select Cursor CLI, Claude Code, Codex, Command Code, Google Antigravity, Gemini CLI, GLM, Kimi, Grok Build, or OpenCode as the execution backend
|
|
18
|
-
|
|
19
|
-
→ [Read the full story](https://dev.to/shinpr/bringing-claude-codes-sub-agents-to-any-mcp-compatible-tool-1hb9)
|
|
20
|
-
|
|
21
|
-
## Alternative: Agent Skills
|
|
22
|
-
|
|
23
|
-
[sub-agents-skills](https://github.com/shinpr/sub-agents-skills) offers a lightweight alternative.
|
|
24
|
-
|
|
25
|
-
| | sub-agents-mcp | sub-agents-skills |
|
|
26
|
-
|---|---|---|
|
|
27
|
-
| **Setup** | MCP configuration required | Copy skill files to your environment |
|
|
28
|
-
| **Configuration** | One backend/model policy per MCP server | Backend/model/permission per agent frontmatter |
|
|
29
|
-
| **Agent discovery** | Fixed `AGENTS_DIR` | Project-local `.agents` or `SUB_AGENTS_DIR` |
|
|
30
|
-
| **Strengths** | Sessions, MCP resources, structured responses, centralized policy | Lightweight setup and mixed backends in one project |
|
|
31
|
-
|
|
32
|
-
Choose **sub-agents-mcp** when you want a centrally configured execution service. Choose **sub-agents-skills** when each agent should select its own backend and model in a Skill-compatible environment.
|
|
33
|
-
|
|
34
|
-
## Table of Contents
|
|
35
|
-
|
|
36
|
-
- [Prerequisites](#prerequisites)
|
|
37
|
-
- [Quick Start](#quick-start)
|
|
38
|
-
- [Usage Examples](#usage-examples)
|
|
39
|
-
- [Writing Effective Agents](#writing-effective-agents)
|
|
40
|
-
- [Agent Examples](#agent-examples)
|
|
41
|
-
- [Configuration Reference](#configuration-reference)
|
|
42
|
-
- [Session Management](#session-management)
|
|
43
|
-
- [Troubleshooting](#troubleshooting)
|
|
44
|
-
- [Design Philosophy](#design-philosophy)
|
|
45
|
-
- [How It Works](#how-it-works)
|
|
46
|
-
|
|
47
|
-
## Prerequisites
|
|
48
|
-
|
|
49
|
-
- Node.js 22 or higher
|
|
50
|
-
- One of these execution engines (they actually run the sub-agents):
|
|
51
|
-
- `cursor-agent` CLI (from Cursor)
|
|
52
|
-
- `claude` CLI (from Claude Code)
|
|
53
|
-
- `codex` CLI (from Codex)
|
|
54
|
-
- `command-code` CLI (from Command Code)
|
|
55
|
-
- `gemini` CLI (from Gemini CLI; requires `GEMINI_API_KEY`)
|
|
56
|
-
- `glm` backend (uses the Claude Code `claude` CLI with a Z.ai token)
|
|
57
|
-
- `kimi` backend (uses the Claude Code `claude` CLI with a Kimi API key)
|
|
58
|
-
- `grok` CLI (from Grok Build)
|
|
59
|
-
- `agy` CLI 1.1.12 or later (from Google Antigravity)
|
|
60
|
-
- `opencode` CLI (from OpenCode)
|
|
61
|
-
- An MCP-compatible tool (Cursor IDE, Claude Desktop, Windsurf, etc.)
|
|
12
|
+
- Delegate code review, test writing, investigation, and documentation to focused agents
|
|
13
|
+
- Reuse the same agent definitions across MCP clients with one shared backend and model configuration
|
|
14
|
+
- Continue the same agent across multiple calls for longer work
|
|
62
15
|
|
|
63
16
|
## Quick Start
|
|
64
17
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Create a folder for your agents and add `code-reviewer.md`:
|
|
68
|
-
|
|
69
|
-
```markdown
|
|
70
|
-
# Code Reviewer
|
|
71
|
-
|
|
72
|
-
Review code for quality and maintainability issues.
|
|
73
|
-
|
|
74
|
-
## Task
|
|
75
|
-
- Find bugs and potential issues
|
|
76
|
-
- Suggest improvements
|
|
77
|
-
- Check code style consistency
|
|
78
|
-
|
|
79
|
-
## Done When
|
|
80
|
-
- All target files reviewed
|
|
81
|
-
- Issues listed with explanations
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
See [Writing Effective Agents](#writing-effective-agents) for more on agent design.
|
|
85
|
-
|
|
86
|
-
### 2. Install Your Execution Engine
|
|
87
|
-
|
|
88
|
-
Pick one based on which tool you use:
|
|
89
|
-
|
|
90
|
-
**For Cursor users:**
|
|
91
|
-
```bash
|
|
92
|
-
# Install Cursor CLI (includes cursor-agent)
|
|
93
|
-
curl https://cursor.com/install -fsS | bash
|
|
94
|
-
|
|
95
|
-
# Authenticate (required before first use)
|
|
96
|
-
cursor-agent login
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**For Claude Code users:**
|
|
100
|
-
```bash
|
|
101
|
-
# Option 1: Native install (recommended)
|
|
102
|
-
curl -fsSL https://claude.ai/install.sh | bash
|
|
103
|
-
|
|
104
|
-
# Option 2: NPM (requires Node.js 18+)
|
|
105
|
-
npm install -g @anthropic-ai/claude-code
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Note: Claude Code installs the `claude` CLI command.
|
|
109
|
-
|
|
110
|
-
**For Codex users:**
|
|
111
|
-
```bash
|
|
112
|
-
# Install Codex
|
|
113
|
-
npm install -g @openai/codex
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**For Command Code users:**
|
|
117
|
-
```bash
|
|
118
|
-
npm install -g command-code
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**For Gemini CLI users:**
|
|
122
|
-
```bash
|
|
123
|
-
# Install Gemini CLI
|
|
124
|
-
npm install -g @google/gemini-cli
|
|
125
|
-
|
|
126
|
-
# Set a Gemini API key in the MCP server environment
|
|
127
|
-
export GEMINI_API_KEY="your-key"
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Note: Set `GEMINI_API_KEY` for the `gemini` backend. Google is retiring the free OAuth tier on June 18, 2026.
|
|
131
|
-
|
|
132
|
-
**For GLM (Z.ai) users:**
|
|
133
|
-
```bash
|
|
134
|
-
# Install Claude Code; GLM uses the claude binary against Z.ai's endpoint
|
|
135
|
-
curl -fsSL https://claude.ai/install.sh | bash
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Set `AGENT_TYPE` to `glm` and add `CLI_API_KEY` to the MCP server environment in your MCP client configuration. Because MCP servers are long-running processes, restart or reconnect the MCP server after changing `CLI_API_KEY`.
|
|
139
|
-
|
|
140
|
-
**For Kimi users:**
|
|
141
|
-
```bash
|
|
142
|
-
# Install Claude Code; Kimi uses the claude binary against Kimi's coding endpoint
|
|
143
|
-
curl -fsSL https://claude.ai/install.sh | bash
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Set `AGENT_TYPE` to `kimi` and add your Kimi API key as `CLI_API_KEY` in the MCP server environment. The key is passed to the child process through the environment, never through CLI arguments. Restart or reconnect the MCP server after changing it.
|
|
147
|
-
|
|
148
|
-
**For Grok Build users:**
|
|
149
|
-
```bash
|
|
150
|
-
# Install Grok Build
|
|
151
|
-
curl -fsSL https://x.ai/cli/install.sh | bash
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**For Google Antigravity users:**
|
|
155
|
-
```bash
|
|
156
|
-
# Install Antigravity CLI 1.1.12 or later
|
|
157
|
-
curl -fsSL https://antigravity.google/cli/install.sh | bash
|
|
158
|
-
|
|
159
|
-
# Authenticate before starting the MCP server
|
|
160
|
-
agy
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
**For OpenCode users:**
|
|
164
|
-
```bash
|
|
165
|
-
brew install anomalyco/tap/opencode
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Configure providers and credentials in OpenCode normally. Each MCP invocation uses isolated data and state directories to avoid concurrent session database locks while continuing to use your normal configuration and credentials.
|
|
18
|
+
You need Node.js 22 or later, an MCP-compatible client, and one supported coding CLI installed and signed in. This example uses Codex.
|
|
169
19
|
|
|
170
|
-
###
|
|
20
|
+
### 1. Create an Agent
|
|
171
21
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
**Cursor:** `~/.cursor/mcp.json`
|
|
175
|
-
**Claude Desktop:** `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
|
|
176
|
-
|
|
177
|
-
```json
|
|
178
|
-
{
|
|
179
|
-
"mcpServers": {
|
|
180
|
-
"sub-agents": {
|
|
181
|
-
"command": "npx",
|
|
182
|
-
"args": ["-y", "sub-agents-mcp"],
|
|
183
|
-
"env": {
|
|
184
|
-
"AGENTS_DIR": "/absolute/path/to/your/agents-folder",
|
|
185
|
-
"AGENT_TYPE": "cursor" // or "claude", "codex", "command-code", "antigravity", "gemini", "glm", "kimi", "grok", or "opencode"
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
**Important:** Use absolute paths only.
|
|
193
|
-
- ✅ `/Users/john/Documents/my-agents` (Mac/Linux)
|
|
194
|
-
- ✅ `C:\\Users\\john\\Documents\\my-agents` (Windows)
|
|
195
|
-
- ❌ `./agents` or `~/agents` won't work
|
|
196
|
-
|
|
197
|
-
Restart your IDE and you're ready to go.
|
|
198
|
-
|
|
199
|
-
### 4. Fix "Permission Denied" Errors When Running Shell Commands
|
|
200
|
-
|
|
201
|
-
Sub-agents may fail to execute shell commands with permission errors. This happens because sub-agents can't respond to interactive permission prompts.
|
|
202
|
-
|
|
203
|
-
**Recommended approach:**
|
|
204
|
-
|
|
205
|
-
1. Run your CLI tool directly with the task you want sub-agents to handle:
|
|
206
|
-
```bash
|
|
207
|
-
# For Cursor users
|
|
208
|
-
cursor-agent
|
|
209
|
-
|
|
210
|
-
# For Claude Code users
|
|
211
|
-
claude
|
|
212
|
-
|
|
213
|
-
# For Codex CLI users
|
|
214
|
-
codex
|
|
215
|
-
|
|
216
|
-
# For Command Code users
|
|
217
|
-
command-code
|
|
218
|
-
|
|
219
|
-
# For Gemini CLI users
|
|
220
|
-
gemini
|
|
221
|
-
|
|
222
|
-
# For Grok Build users
|
|
223
|
-
grok
|
|
224
|
-
|
|
225
|
-
# For Google Antigravity users
|
|
226
|
-
agy
|
|
227
|
-
|
|
228
|
-
# For OpenCode users
|
|
229
|
-
opencode
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
2. When prompted to allow commands (e.g., "Add Shell(cd), Shell(make) to allowlist?"), approve them
|
|
233
|
-
|
|
234
|
-
3. This automatically updates your configuration file, and those commands will now work when invoked via MCP sub-agents
|
|
235
|
-
|
|
236
|
-
**Manual configuration (alternative):**
|
|
237
|
-
|
|
238
|
-
If you prefer to configure permissions manually, edit:
|
|
239
|
-
- **Cursor**: `<project>/.cursor/cli.json` or `~/.cursor/cli-config.json`
|
|
240
|
-
- **Claude Code**: `.claude/settings.json` or `.claude/settings.local.json`
|
|
241
|
-
|
|
242
|
-
```json
|
|
243
|
-
{
|
|
244
|
-
"permissions": {
|
|
245
|
-
"allow": [
|
|
246
|
-
"Shell(cd)",
|
|
247
|
-
"Shell(make)",
|
|
248
|
-
"Shell(git)"
|
|
249
|
-
]
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Note: Agents often run commands as one-liners like `cd /path && make build`, so you need to allow all parts of the command.
|
|
255
|
-
|
|
256
|
-
## Usage Examples
|
|
257
|
-
|
|
258
|
-
Ask your AI tool to use an agent:
|
|
259
|
-
|
|
260
|
-
```
|
|
261
|
-
"Use the code-reviewer agent to check my UserService class"
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
```
|
|
265
|
-
"Use the test-writer agent to create unit tests for the auth module"
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
```
|
|
269
|
-
"Use the doc-writer agent to add JSDoc comments to all public methods"
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
The AI tool calls the MCP server, which runs the selected agent and returns its result.
|
|
273
|
-
|
|
274
|
-
**Tip:** Include *what you want done* in the request, not only the agent name. For example:
|
|
275
|
-
|
|
276
|
-
- **Specific:** "Use the code-reviewer agent **to check my UserService class**"
|
|
277
|
-
- **Incomplete:** "Use the code-reviewer agent" (the review target is missing)
|
|
278
|
-
|
|
279
|
-
The more specific your task, the better the results.
|
|
280
|
-
|
|
281
|
-
## Writing Effective Agents
|
|
282
|
-
|
|
283
|
-
### The Single Responsibility Principle
|
|
284
|
-
|
|
285
|
-
Each agent should do **one thing well**. Avoid "swiss army knife" agents.
|
|
286
|
-
|
|
287
|
-
| ✅ Good | ❌ Bad |
|
|
288
|
-
|---------|--------|
|
|
289
|
-
| Reviews code for security issues | Reviews code, writes tests, and refactors |
|
|
290
|
-
| Writes unit tests for a module | Writes tests and fixes bugs it finds |
|
|
291
|
-
|
|
292
|
-
### Essential Structure
|
|
22
|
+
Create an agents folder anywhere on your machine, then add `code-reviewer.md`:
|
|
293
23
|
|
|
294
24
|
```markdown
|
|
295
|
-
#
|
|
296
|
-
|
|
297
|
-
One-sentence purpose.
|
|
298
|
-
|
|
299
|
-
## Task
|
|
300
|
-
- Action 1
|
|
301
|
-
- Action 2
|
|
302
|
-
|
|
303
|
-
## Done When
|
|
304
|
-
- Criterion 1
|
|
305
|
-
- Criterion 2
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
### Keep Agents Self-Contained
|
|
309
|
-
|
|
310
|
-
Agents run in isolation with fresh context. Avoid:
|
|
311
|
-
|
|
312
|
-
- References to other agents ("then use X agent...")
|
|
313
|
-
- Assumptions about prior context ("continuing from before...")
|
|
314
|
-
- Scope creep beyond the stated purpose
|
|
315
|
-
|
|
316
|
-
### Optional Agent Sections
|
|
317
|
-
|
|
318
|
-
For complex agents, consider adding:
|
|
319
|
-
|
|
320
|
-
- **Scope boundaries**: Explicitly state what's *out of scope*
|
|
321
|
-
- **Prohibited actions**: List common mistakes the agent should avoid
|
|
322
|
-
- **Output format**: Define structured output when needed
|
|
323
|
-
|
|
324
|
-
## Agent Examples
|
|
325
|
-
|
|
326
|
-
Each `.md` or `.txt` file in your agents folder becomes an agent. The filename becomes the agent name (e.g., `bug-investigator.md` → "bug-investigator").
|
|
327
|
-
|
|
328
|
-
**`bug-investigator.md`**
|
|
329
|
-
```markdown
|
|
330
|
-
# Bug Investigator
|
|
25
|
+
# Code Reviewer
|
|
331
26
|
|
|
332
|
-
|
|
27
|
+
Review code for bugs and maintainability issues.
|
|
333
28
|
|
|
334
29
|
## Task
|
|
335
|
-
- Collect evidence from error logs, code, and git history
|
|
336
|
-
- Generate multiple hypotheses for the cause
|
|
337
|
-
- Trace each hypothesis to its root cause
|
|
338
|
-
- Report findings with supporting evidence
|
|
339
30
|
|
|
340
|
-
|
|
341
|
-
-
|
|
342
|
-
-
|
|
31
|
+
- Find concrete problems in the requested changes
|
|
32
|
+
- Explain why each problem matters
|
|
33
|
+
- Point to the affected code
|
|
343
34
|
|
|
344
35
|
## Done When
|
|
345
|
-
- At least 2 hypotheses documented with evidence
|
|
346
|
-
- Most likely cause identified with confidence level
|
|
347
|
-
- Affected code locations listed
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
For examples with completion checklists, prohibited actions, and structured output, see [claude-code-workflows/agents](https://github.com/shinpr/claude-code-workflows/tree/main/agents). These examples target Claude Code, but the same structure applies to any execution engine.
|
|
351
|
-
|
|
352
|
-
## Configuration Reference
|
|
353
|
-
|
|
354
|
-
### Required Environment Variables
|
|
355
|
-
|
|
356
|
-
**`AGENTS_DIR`**
|
|
357
|
-
Path to your agents folder. Must be absolute.
|
|
358
|
-
|
|
359
|
-
**`AGENT_TYPE`**
|
|
360
|
-
Which execution engine to use:
|
|
361
|
-
- `"cursor"` - uses `cursor-agent` CLI
|
|
362
|
-
- `"claude"` - uses `claude` CLI
|
|
363
|
-
- `"gemini"` - uses `gemini` CLI
|
|
364
|
-
- `"codex"` - uses `codex` CLI (OpenAI Codex)
|
|
365
|
-
- `"command-code"` - uses `command-code` CLI
|
|
366
|
-
- `"glm"` - uses the Claude Code `claude` CLI against GLM's Z.ai endpoint
|
|
367
|
-
- `"kimi"` - uses the Claude Code `claude` CLI against Kimi's coding endpoint
|
|
368
|
-
- `"grok"` - uses `grok` CLI (Grok Build)
|
|
369
|
-
- `"antigravity"` - uses `agy` CLI (Google Antigravity; requires version 1.1.12 or later)
|
|
370
|
-
- `"opencode"` - uses `opencode` CLI and its configured provider
|
|
371
|
-
|
|
372
|
-
`AGENT_TYPE` has no default. The MCP server returns a corrective startup error when it is missing or blank.
|
|
373
|
-
|
|
374
|
-
### Optional Settings
|
|
375
36
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
- `"read-only"`: investigation/review only, no edits or shell writes (codex `-s read-only` / claude+glm+kimi `--permission-mode plan` / Command Code `--permission-mode plan` / gemini `--approval-mode plan` / cursor `--mode plan --sandbox enabled` / grok `--sandbox read-only` / antigravity `--mode plan --sandbox` / OpenCode deny rules)
|
|
380
|
-
- `"safe-edit"`: auto-approve edits and suppress prompts (codex `-s workspace-write` + `approval_policy=never` / claude+glm+kimi `--permission-mode acceptEdits` / Command Code `--yolo --permission-mode auto-accept` / gemini `--approval-mode auto_edit` / cursor `--trust --sandbox enabled` / grok `--sandbox workspace` / antigravity `--mode accept-edits --sandbox` / OpenCode permission rules)
|
|
381
|
-
- `"yolo"`: bypass all approvals and sandboxing. Use with care.
|
|
382
|
-
|
|
383
|
-
Sub-agents have no stdin, so any approval prompt would deadlock the run. The default `safe-edit` removes prompts, but sandboxing depends on the CLI. Codex, Cursor, Grok, and Antigravity enforce a workspace-level sandbox for `safe-edit`, while Claude, GLM, Kimi, Gemini, and Command Code only apply approval policies and do not provide an OS-level workspace sandbox. OpenCode's permission configuration is also not an OS-level sandbox and cannot confine every side effect of programs launched through bash. Cursor combines `--mode plan` with its shell sandbox for `read-only`; the mode prevents edits while the sandbox confines supported shell commands. Grok fixes `--permission-mode bypassPermissions` and uses the kernel-enforced `--sandbox` profile to confine writes per `AGENT_PERMISSION`. Antigravity uses `--sandbox` for `read-only` and `safe-edit`, and omits it only for `yolo`. If you need strict containment, use a sandbox-backed backend.
|
|
384
|
-
|
|
385
|
-
OpenCode custom and MCP tools follow your OpenCode permissions even in `read-only`; explicitly deny any added tool that can cause side effects.
|
|
386
|
-
|
|
387
|
-
**`AGENT_MODEL`**
|
|
388
|
-
Optional model override applied to every execution by this MCP server. The value is passed to the selected backend as `--model`. When omitted, the backend uses its configured default.
|
|
389
|
-
|
|
390
|
-
```json
|
|
391
|
-
"AGENT_MODEL": "gpt-5.6-luna"
|
|
37
|
+
- All requested files have been reviewed
|
|
38
|
+
- Findings include evidence and suggested next steps
|
|
392
39
|
```
|
|
393
40
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
**`AGENT_EFFORT`**
|
|
397
|
-
Optional backend/model-specific reasoning level or model variant. It is passed to Codex as `model_reasoning_effort`, Claude/GLM/Kimi/Antigravity/Command Code as `--effort`, Grok as `--reasoning-effort`, and OpenCode as `--variant`. Cursor and Gemini do not support this setting; the MCP server rejects that configuration at startup.
|
|
398
|
-
|
|
399
|
-
Accepted values depend on the selected backend and model. The MCP server forwards the value unchanged.
|
|
400
|
-
|
|
401
|
-
**`CLI_API_KEY`**
|
|
402
|
-
Provider API key for `AGENT_TYPE=glm` or `kimi`. For GLM it is forwarded to the Claude Code binary as `ANTHROPIC_AUTH_TOKEN`; for Kimi it is forwarded as `ANTHROPIC_API_KEY`. It is never passed as a CLI argument. If you add or change it in your MCP client configuration, restart or reconnect the MCP server so the running process receives the new environment.
|
|
403
|
-
|
|
404
|
-
**`EXECUTION_TIMEOUT_MS`**
|
|
405
|
-
How long agents can run before timing out (default: 5 minutes, max: 10 minutes)
|
|
406
|
-
|
|
407
|
-
**`AGENTS_SETTINGS_PATH`**
|
|
408
|
-
Path to custom CLI settings directory for sub-agents.
|
|
41
|
+
The filename becomes the agent name: `code-reviewer.md` becomes `code-reviewer`.
|
|
409
42
|
|
|
410
|
-
|
|
43
|
+
### 2. Add the MCP Server
|
|
411
44
|
|
|
412
|
-
|
|
45
|
+
Add the server to your client's MCP configuration. Replace `AGENTS_DIR` with the absolute path to the folder you created.
|
|
413
46
|
|
|
414
|
-
Note: Gemini CLI, Grok Build, Google Antigravity, OpenCode, and Command Code do not use this option, so it has no effect when `AGENT_TYPE` is `gemini`, `grok`, `antigravity`, `opencode`, or `command-code`. OpenCode continues its normal XDG/project configuration discovery. The `glm` and `kimi` backends also ignore this setting to avoid mixing Claude settings and credentials into redirected subprocesses.
|
|
415
|
-
|
|
416
|
-
Example with custom settings:
|
|
417
47
|
```json
|
|
418
48
|
{
|
|
419
49
|
"mcpServers": {
|
|
@@ -422,199 +52,92 @@ Example with custom settings:
|
|
|
422
52
|
"args": ["-y", "sub-agents-mcp"],
|
|
423
53
|
"env": {
|
|
424
54
|
"AGENTS_DIR": "/absolute/path/to/agents",
|
|
425
|
-
"AGENT_TYPE": "
|
|
426
|
-
"EXECUTION_TIMEOUT_MS": "600000",
|
|
427
|
-
"AGENTS_SETTINGS_PATH": "/absolute/path/to/custom-cli-settings"
|
|
55
|
+
"AGENT_TYPE": "codex"
|
|
428
56
|
}
|
|
429
57
|
}
|
|
430
58
|
}
|
|
431
59
|
}
|
|
432
60
|
```
|
|
433
61
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
Agents have access to your project directory. Only use agent definitions from trusted sources.
|
|
437
|
-
|
|
438
|
-
## Session Management
|
|
439
|
-
|
|
440
|
-
Session management allows sub-agents to remember previous executions, which helps when you want agents to build on earlier work or maintain context across multiple calls.
|
|
441
|
-
|
|
442
|
-
### Why Sessions Matter
|
|
443
|
-
|
|
444
|
-
By default, each sub-agent execution starts with no context. With sessions enabled:
|
|
445
|
-
- Agents can reference their earlier work
|
|
446
|
-
- You get execution history for debugging
|
|
447
|
-
- Related tasks share context
|
|
62
|
+
Restart or reconnect your MCP client after saving the configuration.
|
|
448
63
|
|
|
449
|
-
###
|
|
64
|
+
### 3. Run the Agent
|
|
450
65
|
|
|
451
|
-
|
|
66
|
+
Ask your assistant:
|
|
452
67
|
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
"mcpServers": {
|
|
456
|
-
"sub-agents": {
|
|
457
|
-
"command": "npx",
|
|
458
|
-
"args": ["-y", "sub-agents-mcp"],
|
|
459
|
-
"env": {
|
|
460
|
-
"AGENTS_DIR": "/absolute/path/to/agents",
|
|
461
|
-
"AGENT_TYPE": "cursor",
|
|
462
|
-
"SESSION_ENABLED": "true",
|
|
463
|
-
"SESSION_DIR": "/absolute/path/to/session-storage",
|
|
464
|
-
"SESSION_RETENTION_DAYS": "1"
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
68
|
+
```text
|
|
69
|
+
Use the code-reviewer agent to review the authentication changes.
|
|
469
70
|
```
|
|
470
71
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
- `SESSION_ENABLED` - Set to `"true"` to enable session management (default: `false`)
|
|
474
|
-
- `SESSION_DIR` - Where to store session files (default: `.mcp-sessions` in the current working directory)
|
|
475
|
-
- `SESSION_RETENTION_DAYS` - How long to keep session files based on last modification time in days (default: 1)
|
|
476
|
-
|
|
477
|
-
**Security consideration:** Session files contain execution history and may include sensitive information. Use absolute paths for `SESSION_DIR`.
|
|
478
|
-
|
|
479
|
-
### When to Use Sessions
|
|
480
|
-
|
|
481
|
-
Sessions work well for:
|
|
482
|
-
- **Iterative development**: "Based on your earlier findings, now fix the issues"
|
|
483
|
-
- **Multi-step workflows**: Breaking complex tasks into smaller sub-agent calls
|
|
484
|
-
- **Debugging**: Reviewing exactly what was executed and what results were returned
|
|
485
|
-
|
|
486
|
-
Note that sessions require additional storage and processing overhead.
|
|
487
|
-
|
|
488
|
-
### How Session Continuity Works
|
|
72
|
+
Your assistant runs the agent with Codex and returns the review to the conversation.
|
|
489
73
|
|
|
490
|
-
|
|
74
|
+
## Examples
|
|
491
75
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
**Example prompt instruction:**
|
|
495
|
-
```markdown
|
|
496
|
-
When using sub-agents with sessions enabled, always include the session_id
|
|
497
|
-
from the previous response in your next request to maintain context.
|
|
76
|
+
```text
|
|
77
|
+
Use the test-writer agent to add unit tests for the auth module.
|
|
498
78
|
```
|
|
499
79
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
# Sub-Agent Session Guidelines
|
|
503
|
-
|
|
504
|
-
When calling the same sub-agent multiple times:
|
|
505
|
-
1. Extract the session_id from the MCP response
|
|
506
|
-
2. Pass it as a parameter in subsequent calls
|
|
507
|
-
3. This preserves context between executions
|
|
80
|
+
```text
|
|
81
|
+
Use the bug-investigator agent to find the cause of the failed checkout requests.
|
|
508
82
|
```
|
|
509
83
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
### Timeout errors or authentication failures
|
|
513
|
-
|
|
514
|
-
**If using Cursor CLI:**
|
|
515
|
-
Run `cursor-agent login` to authenticate. If the session expires, run the command again.
|
|
516
|
-
|
|
517
|
-
Verify installation:
|
|
518
|
-
```bash
|
|
519
|
-
which cursor-agent
|
|
84
|
+
```text
|
|
85
|
+
Use the doc-writer agent to document the public API changes.
|
|
520
86
|
```
|
|
521
87
|
|
|
522
|
-
|
|
523
|
-
Make sure the CLI is properly installed and accessible.
|
|
524
|
-
|
|
525
|
-
**If using GLM (Z.ai):**
|
|
526
|
-
Make sure the Claude Code `claude` CLI is installed, then set `CLI_API_KEY` to your Z.ai token in the MCP server environment. Restart or reconnect the MCP server after changing MCP environment variables.
|
|
527
|
-
|
|
528
|
-
**If using Kimi:**
|
|
529
|
-
Make sure the Claude Code `claude` CLI is installed, then set `CLI_API_KEY` to your Kimi API key in the MCP server environment. Restart or reconnect the MCP server after changing MCP environment variables.
|
|
530
|
-
|
|
531
|
-
**If using Grok Build:**
|
|
532
|
-
Make sure the `grok` CLI is installed and accessible.
|
|
533
|
-
|
|
534
|
-
**If using Google Antigravity:**
|
|
535
|
-
Make sure Antigravity CLI 1.1.12 or later is installed, then run `agy` once to authenticate before starting the MCP server.
|
|
536
|
-
|
|
537
|
-
**If using OpenCode:**
|
|
538
|
-
Make sure the `opencode` CLI is installed and that its provider credentials are configured. The MCP server gives every invocation an isolated OpenCode data/state directory to prevent concurrent SQLite session locks.
|
|
88
|
+
Name both the agent and the work you want it to do.
|
|
539
89
|
|
|
540
|
-
|
|
90
|
+
## When the MCP Server Fits
|
|
541
91
|
|
|
542
|
-
|
|
543
|
-
- `AGENTS_DIR` points to the correct directory (use absolute path)
|
|
544
|
-
- Your agent file has `.md` or `.txt` extension
|
|
545
|
-
- The filename uses hyphens or underscores (no spaces)
|
|
92
|
+
Use the MCP server when you want to share the same agents across MCP clients while keeping backend and model configuration in one place.
|
|
546
93
|
|
|
547
|
-
|
|
94
|
+
If you prefer a lighter installation or want each agent to choose its own backend and model, see [Sub-Agents Skills](https://github.com/shinpr/sub-agents-skills).
|
|
548
95
|
|
|
549
|
-
|
|
550
|
-
2. Confirm that your chosen CLI tool is installed and accessible
|
|
551
|
-
3. Double-check that all environment variables are set in the MCP config
|
|
96
|
+
## Supported Backends
|
|
552
97
|
|
|
553
|
-
|
|
98
|
+
Set `AGENT_TYPE` to the backend you already use:
|
|
554
99
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
/your-project
|
|
568
|
-
├── .codex-main/AGENTS.md # Main agent instructions
|
|
569
|
-
├── .codex-sub/AGENTS.md # Sub-agent instructions (no delegation)
|
|
570
|
-
└── (no AGENTS.md at root)
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
- Run main Codex with `CODEX_HOME=/your-project/.codex-main`
|
|
574
|
-
- Set `AGENTS_SETTINGS_PATH=/your-project/.codex-sub` in sub-agents-mcp config
|
|
100
|
+
| `AGENT_TYPE` | Backend | Command |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `codex` | Codex | `codex` |
|
|
103
|
+
| `claude` | Claude Code | `claude` |
|
|
104
|
+
| `cursor` | Cursor CLI | `cursor-agent` |
|
|
105
|
+
| `command-code` | Command Code | `command-code` |
|
|
106
|
+
| `glm` | GLM (Z.ai) | `claude` |
|
|
107
|
+
| `kimi` | Kimi | `claude` |
|
|
108
|
+
| `grok` | Grok Build | `grok` |
|
|
109
|
+
| `antigravity` | Google Antigravity | `agy` 1.1.12+ |
|
|
110
|
+
| `gemini` | Gemini CLI (compatibility) | `gemini` |
|
|
111
|
+
| `opencode` | OpenCode | `opencode` |
|
|
575
112
|
|
|
576
|
-
|
|
113
|
+
The selected CLI must be installed and configured before the MCP server starts.
|
|
577
114
|
|
|
578
|
-
|
|
115
|
+
GLM and Kimi require `CLI_API_KEY` in the MCP server environment. Other backends use the CLI's existing authentication.
|
|
579
116
|
|
|
580
|
-
|
|
117
|
+
For Google models, prefer Antigravity. Gemini CLI remains available for existing enterprise, API key, or Vertex AI configurations.
|
|
581
118
|
|
|
582
|
-
|
|
583
|
-
- Each agent only receives the information relevant to its task
|
|
584
|
-
- No context leakage between runs
|
|
585
|
-
- The main agent stays focused and lightweight
|
|
119
|
+
## Shared Agent Settings
|
|
586
120
|
|
|
587
|
-
|
|
588
|
-
- Sub-agents can specialize in a single goal without interference
|
|
589
|
-
- Less risk of confusion from unrelated context
|
|
590
|
-
- More consistent results in complex, multi-step workflows
|
|
121
|
+
Set `AGENT_MODEL` to use one model for every agent. Omit it to use the backend's default.
|
|
591
122
|
|
|
592
|
-
|
|
593
|
-
- Large tasks can be safely split into smaller sub-tasks
|
|
594
|
-
- Each sub-agent operates within its own token limit
|
|
595
|
-
- The main agent coordinates without hitting global context limits
|
|
123
|
+
`AGENT_PERMISSION` controls what agents may do:
|
|
596
124
|
|
|
597
|
-
|
|
125
|
+
- `read-only` — review and investigation
|
|
126
|
+
- `safe-edit` — edits allowed without approval (default)
|
|
127
|
+
- `yolo` — unrestricted execution
|
|
598
128
|
|
|
599
|
-
|
|
129
|
+
If an agent reports that an action was blocked, choose a less restrictive mode.
|
|
600
130
|
|
|
601
|
-
|
|
131
|
+
## Continue Work Across Calls
|
|
602
132
|
|
|
603
|
-
|
|
133
|
+
Set `SESSION_ENABLED` to `"true"` when you want an agent to remember earlier calls and continue a longer task. Your assistant must reuse the returned `session_id` on the next call to continue that session.
|
|
604
134
|
|
|
605
|
-
|
|
606
|
-
2. The client automatically launches `sub-agents-mcp` as a background process when it starts
|
|
607
|
-
3. When your main AI assistant needs a sub-agent, it makes an MCP tool call
|
|
608
|
-
4. The MCP server reads the agent definition (markdown file) and invokes the globally configured CLI (`cursor-agent`, `claude`, `agy`, `gemini`, `codex`, `command-code`, `glm`/`kimi` via the `claude` binary, `grok`, or `opencode`)
|
|
609
|
-
5. The execution engine runs the agent and streams results back through the MCP server
|
|
610
|
-
6. Your main assistant receives the results and continues working
|
|
135
|
+
## If It Does Not Start
|
|
611
136
|
|
|
612
|
-
|
|
137
|
+
- Run the selected backend command directly and confirm that it is installed and signed in
|
|
138
|
+
- Make sure `AGENTS_DIR` is an absolute path and contains at least one `.md` or `.txt` file
|
|
139
|
+
- Restart or reconnect the MCP client after changing its configuration
|
|
613
140
|
|
|
614
141
|
## License
|
|
615
142
|
|
|
616
143
|
MIT
|
|
617
|
-
|
|
618
|
-
---
|
|
619
|
-
|
|
620
|
-
*AI-to-AI collaboration through Model Context Protocol*
|