sub-agents-mcp 0.11.0 → 0.12.1

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 CHANGED
@@ -5,16 +5,16 @@
5
5
 
6
6
  Bring Claude Code–style sub-agents to any MCP-compatible tool.
7
7
 
8
- This MCP server lets you define task-specific AI agents (like "test-writer" or "code-reviewer") in markdown files, and execute them via Cursor CLI, Claude Code, Codex, Gemini CLI, GLM, Grok Build, or OpenCode backends.
8
+ Define task-specific AI agents such as "test-writer" or "code-reviewer" in Markdown files. The server runs them through Cursor CLI, Claude Code, Codex, Gemini CLI, GLM, Kimi, Grok Build, or OpenCode.
9
9
 
10
10
  ## Why?
11
11
 
12
- Claude Code offers powerful sub-agent workflows—but they're limited to its own environment. This MCP server makes that workflow portable, so any MCP-compatible tool (Cursor, Claude Desktop, Windsurf, etc.) can use the same agents.
12
+ Claude Code supports sub-agents within its own environment. This server exposes the same type of workflow through MCP, allowing clients such as Cursor, Claude Desktop, and Windsurf to use the agent definitions.
13
13
 
14
- **Concrete benefits:**
14
+ **What it provides:**
15
15
  - Define reusable agents once, use them across multiple tools
16
16
  - Share agent definitions within teams regardless of IDE choice
17
- - Leverage Cursor CLI, Claude Code, Codex, Gemini CLI, GLM, Grok Build, or OpenCode capabilities from any MCP client
17
+ - Select Cursor CLI, Claude Code, Codex, Gemini CLI, GLM, Kimi, Grok Build, or OpenCode as the execution backend
18
18
 
19
19
  → [Read the full story](https://dev.to/shinpr/bringing-claude-codes-sub-agents-to-any-mcp-compatible-tool-1hb9)
20
20
 
@@ -51,8 +51,9 @@ Choose **sub-agents-mcp** when you want a centrally configured execution service
51
51
  - `cursor-agent` CLI (from Cursor)
52
52
  - `claude` CLI (from Claude Code)
53
53
  - `codex` CLI (from Codex)
54
- - `gemini` CLI (from Gemini CLI requires `GEMINI_API_KEY`)
54
+ - `gemini` CLI (from Gemini CLI; requires `GEMINI_API_KEY`)
55
55
  - `glm` backend (uses the Claude Code `claude` CLI with a Z.ai token)
56
+ - `kimi` backend (uses the Claude Code `claude` CLI with a Kimi API key)
56
57
  - `grok` CLI (from Grok Build)
57
58
  - `opencode` CLI (from OpenCode)
58
59
  - An MCP-compatible tool (Cursor IDE, Claude Desktop, Windsurf, etc.)
@@ -119,7 +120,7 @@ npm install -g @google/gemini-cli
119
120
  export GEMINI_API_KEY="your-key"
120
121
  ```
121
122
 
122
- Note: Set `GEMINI_API_KEY` without it the `gemini` backend won't run (Google is retiring the free OAuth tier on June 18, 2026).
123
+ Note: Set `GEMINI_API_KEY` for the `gemini` backend. Google is retiring the free OAuth tier on June 18, 2026.
123
124
 
124
125
  **For GLM (Z.ai) users:**
125
126
  ```bash
@@ -129,6 +130,14 @@ curl -fsSL https://claude.ai/install.sh | bash
129
130
 
130
131
  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`.
131
132
 
133
+ **For Kimi users:**
134
+ ```bash
135
+ # Install Claude Code; Kimi uses the claude binary against Kimi's coding endpoint
136
+ curl -fsSL https://claude.ai/install.sh | bash
137
+ ```
138
+
139
+ 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.
140
+
132
141
  **For Grok Build users:**
133
142
  ```bash
134
143
  # Install Grok Build
@@ -157,7 +166,7 @@ Add this to your MCP configuration file:
157
166
  "args": ["-y", "sub-agents-mcp"],
158
167
  "env": {
159
168
  "AGENTS_DIR": "/absolute/path/to/your/agents-folder",
160
- "AGENT_TYPE": "cursor" // or "claude", "codex", "gemini", "glm", "grok", or "opencode"
169
+ "AGENT_TYPE": "cursor" // or "claude", "codex", "gemini", "glm", "kimi", "grok", or "opencode"
161
170
  }
162
171
  }
163
172
  }
@@ -224,7 +233,7 @@ Note: Agents often run commands as one-liners like `cd /path && make build`, so
224
233
 
225
234
  ## Usage Examples
226
235
 
227
- Just tell your AI to use an agent:
236
+ Ask your AI tool to use an agent:
228
237
 
229
238
  ```
230
239
  "Use the code-reviewer agent to check my UserService class"
@@ -238,12 +247,12 @@ Just tell your AI to use an agent:
238
247
  "Use the doc-writer agent to add JSDoc comments to all public methods"
239
248
  ```
240
249
 
241
- Your AI automatically invokes the specialized agent and returns results.
250
+ The AI tool calls the MCP server, which runs the selected agent and returns its result.
242
251
 
243
- **Tip:** Always include *what you want done* in your requestnot just which agent to use. For example:
252
+ **Tip:** Include *what you want done* in the request, not only the agent name. For example:
244
253
 
245
- - "Use the code-reviewer agent **to check my UserService class**"
246
- - "Use the code-reviewer agent" (too vague—the agent won't know what to review)
254
+ - **Specific:** "Use the code-reviewer agent **to check my UserService class**"
255
+ - **Incomplete:** "Use the code-reviewer agent" (the review target is missing)
247
256
 
248
257
  The more specific your task, the better the results.
249
258
 
@@ -282,7 +291,7 @@ Agents run in isolation with fresh context. Avoid:
282
291
  - Assumptions about prior context ("continuing from before...")
283
292
  - Scope creep beyond the stated purpose
284
293
 
285
- ### Advanced Patterns
294
+ ### Optional Agent Sections
286
295
 
287
296
  For complex agents, consider adding:
288
297
 
@@ -316,7 +325,7 @@ Investigate bug reports and identify root causes.
316
325
  - Affected code locations listed
317
326
  ```
318
327
 
319
- For more advanced patterns (completion checklists, prohibited actions, structured output), see [claude-code-workflows/agents](https://github.com/shinpr/claude-code-workflows/tree/main/agents). These are written for Claude Code, but the design patterns apply to any execution engine.
328
+ 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.
320
329
 
321
330
  ## Configuration Reference
322
331
 
@@ -332,6 +341,7 @@ Which execution engine to use:
332
341
  - `"gemini"` - uses `gemini` CLI
333
342
  - `"codex"` - uses `codex` CLI (OpenAI Codex)
334
343
  - `"glm"` - uses the Claude Code `claude` CLI against GLM's Z.ai endpoint
344
+ - `"kimi"` - uses the Claude Code `claude` CLI against Kimi's coding endpoint
335
345
  - `"grok"` - uses `grok` CLI (Grok Build)
336
346
  - `"opencode"` - uses `opencode` CLI and its configured provider
337
347
 
@@ -340,11 +350,11 @@ Which execution engine to use:
340
350
  **`AGENT_PERMISSION`**
341
351
  Approval/sandbox level the sub-agent runs with. Default: `"safe-edit"`.
342
352
 
343
- - `"read-only"` investigation/review only, no edits or shell writes (codex `-s read-only` / claude+glm `--permission-mode plan` / gemini `--approval-mode plan` / cursor `--mode plan` / grok `--sandbox read-only` / OpenCode deny rules)
344
- - `"safe-edit"` auto-approve edits and suppress prompts (codex `-s workspace-write` + `approval_policy=never` / claude+glm `--permission-mode acceptEdits` / gemini `--approval-mode auto_edit` / cursor `--trust` / grok `--sandbox workspace` / OpenCode permission rules)
345
- - `"yolo"` bypass all approvals and sandboxing. Use with care.
353
+ - `"read-only"`: investigation/review only, no edits or shell writes (codex `-s read-only` / claude+glm+kimi `--permission-mode plan` / gemini `--approval-mode plan` / cursor `--mode plan` / grok `--sandbox read-only` / OpenCode deny rules)
354
+ - `"safe-edit"`: auto-approve edits and suppress prompts (codex `-s workspace-write` + `approval_policy=never` / claude+glm+kimi `--permission-mode acceptEdits` / gemini `--approval-mode auto_edit` / cursor `--trust` / grok `--sandbox workspace` / OpenCode permission rules)
355
+ - `"yolo"`: bypass all approvals and sandboxing. Use with care.
346
356
 
347
- Sub-agents have no stdin, so any approval prompt would deadlock the run. The default `safe-edit` removes prompts; the depth of sandboxing depends on the CLI codex and grok enforce a workspace-level sandbox (codex `workspace-write`, grok `--sandbox workspace`), while claude / glm / gemini / cursor only auto-approve and do not jail edits to the workspace. OpenCode's permission configuration is also not an OS-level sandbox and cannot confine every side effect of programs launched through bash. Grok fixes `--permission-mode bypassPermissions` and uses the kernel-enforced `--sandbox` profile to confine writes per `AGENT_PERMISSION`. If you need strict containment, use a sandbox-backed backend.
357
+ 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 and Grok enforce a workspace-level sandbox (codex `workspace-write`, grok `--sandbox workspace`), while Claude, GLM, Kimi, Gemini, and Cursor only auto-approve and do not confine edits to the workspace. OpenCode's permission configuration is also not an OS-level sandbox and cannot confine every side effect of programs launched through bash. Grok fixes `--permission-mode bypassPermissions` and uses the kernel-enforced `--sandbox` profile to confine writes per `AGENT_PERMISSION`. If you need strict containment, use a sandbox-backed backend.
348
358
 
349
359
  OpenCode custom and MCP tools follow your OpenCode permissions even in `read-only`; explicitly deny any added tool that can cause side effects.
350
360
 
@@ -358,12 +368,12 @@ Optional model override applied to every execution by this MCP server. The value
358
368
  OpenCode model names normally use `provider/model` syntax.
359
369
 
360
370
  **`AGENT_EFFORT`**
361
- Optional backend/model-specific reasoning level or model variant. It is passed to Codex as `model_reasoning_effort`, Claude/GLM 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.
371
+ Optional backend/model-specific reasoning level or model variant. It is passed to Codex as `model_reasoning_effort`, Claude/GLM/Kimi 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.
362
372
 
363
373
  Accepted values depend on the selected backend and model. The MCP server forwards the value unchanged.
364
374
 
365
375
  **`CLI_API_KEY`**
366
- Z.ai API token for `AGENT_TYPE=glm`. It is forwarded to the Claude Code binary as `ANTHROPIC_AUTH_TOKEN` and 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.
376
+ 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.
367
377
 
368
378
  **`EXECUTION_TIMEOUT_MS`**
369
379
  How long agents can run before timing out (default: 5 minutes, max: 10 minutes)
@@ -375,7 +385,7 @@ Each CLI normally reads settings from project-level directories (`.claude/`, `.c
375
385
 
376
386
  Applied to: `claude`, `cursor`, `codex`.
377
387
 
378
- Note: Gemini CLI, Grok Build, and OpenCode do not use this option, so it has no effect when `AGENT_TYPE` is `gemini`, `grok`, or `opencode`. OpenCode continues its normal XDG/project configuration discovery. The `glm` backend also ignores this setting to avoid mixing Claude settings into the Z.ai-backed subprocess.
388
+ Note: Gemini CLI, Grok Build, and OpenCode do not use this option, so it has no effect when `AGENT_TYPE` is `gemini`, `grok`, or `opencode`. 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.
379
389
 
380
390
  Example with custom settings:
381
391
  ```json
@@ -476,7 +486,7 @@ When calling the same sub-agent multiple times:
476
486
  ### Timeout errors or authentication failures
477
487
 
478
488
  **If using Cursor CLI:**
479
- Run `cursor-agent login` to authenticate. Sessions can expire, so just run this command again if you see auth errors.
489
+ Run `cursor-agent login` to authenticate. If the session expires, run the command again.
480
490
 
481
491
  Verify installation:
482
492
  ```bash
@@ -489,6 +499,9 @@ Make sure the CLI is properly installed and accessible.
489
499
  **If using GLM (Z.ai):**
490
500
  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.
491
501
 
502
+ **If using Kimi:**
503
+ 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.
504
+
492
505
  **If using Grok Build:**
493
506
  Make sure the `grok` CLI is installed and accessible.
494
507
 
@@ -504,8 +517,8 @@ Check that:
504
517
 
505
518
  ### Other execution errors
506
519
 
507
- 1. Verify `AGENT_TYPE` is set correctly (`cursor`, `claude`, `gemini`, `codex`, `glm`, `grok`, or `opencode`)
508
- 2. Ensure your chosen CLI tool is installed and accessible
520
+ 1. Verify `AGENT_TYPE` is set correctly (`cursor`, `claude`, `gemini`, `codex`, `glm`, `kimi`, `grok`, or `opencode`)
521
+ 2. Confirm that your chosen CLI tool is installed and accessible
509
522
  3. Double-check that all environment variables are set in the MCP config
510
523
 
511
524
  ### Recursive sub-agent calls (infinite loop)
@@ -535,7 +548,7 @@ Solution: Don't place AGENTS.md at the project root. Use separate directories:
535
548
 
536
549
  ### Why Independent Contexts Matter
537
550
 
538
- Every sub-agent starts with a fresh context. This adds some startup overhead for each call, but it ensures that every task runs independently and without leftover state from previous runs.
551
+ Every sub-agent starts with a fresh context. Each call has some startup overhead, and tasks run without state left over from previous runs.
539
552
 
540
553
  **Context Isolation**
541
554
  - Each agent only receives the information relevant to its task
@@ -556,14 +569,14 @@ The startup overhead is an intentional trade-off: the system favors clarity and
556
569
 
557
570
  ## How It Works
558
571
 
559
- This MCP server acts as a bridge between your AI tool and a supported execution engine (Cursor CLI, Claude Code, Gemini CLI, Codex, GLM via Z.ai, Grok Build, or OpenCode).
572
+ This MCP server acts as a bridge between your AI tool and a supported execution engine (Cursor CLI, Claude Code, Gemini CLI, Codex, GLM via Z.ai, Kimi, Grok Build, or OpenCode).
560
573
 
561
574
  **The flow:**
562
575
 
563
576
  1. You configure the MCP server in your client (Cursor, Claude Desktop, etc.)
564
577
  2. The client automatically launches `sub-agents-mcp` as a background process when it starts
565
578
  3. When your main AI assistant needs a sub-agent, it makes an MCP tool call
566
- 4. The MCP server reads the agent definition (markdown file) and invokes the globally configured CLI (`cursor-agent`, `claude`, `gemini`, `codex`, `glm` via the `claude` binary, `grok`, or `opencode`)
579
+ 4. The MCP server reads the agent definition (markdown file) and invokes the globally configured CLI (`cursor-agent`, `claude`, `gemini`, `codex`, `glm`/`kimi` via the `claude` binary, `grok`, or `opencode`)
567
580
  5. The execution engine runs the agent and streams results back through the MCP server
568
581
  6. Your main assistant receives the results and continues working
569
582
 
@@ -51,6 +51,8 @@ export declare class ServerConfig {
51
51
  readonly cursorApiKey: string | undefined;
52
52
  /** API key for GLM/Z.ai authentication (from CLI_API_KEY env var) */
53
53
  readonly glmApiKey: string | undefined;
54
+ /** API key for Kimi authentication (from CLI_API_KEY env var) */
55
+ readonly kimiApiKey: string | undefined;
54
56
  /**
55
57
  * Creates a new ServerConfig instance by loading values from environment variables
56
58
  * or using default values.
@@ -1 +1 @@
1
- {"version":3,"file":"ServerConfig.d.ts","sourceRoot":"","sources":["../../src/config/ServerConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,SAAS,EAKf,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,YAAY;IACvB,uDAAuD;IACvD,SAAgB,UAAU,EAAE,MAAM,CAAA;IAElC,6CAA6C;IAC7C,SAAgB,aAAa,EAAE,MAAM,CAAA;IAErC,gEAAgE;IAChE,SAAgB,SAAS,EAAE,MAAM,CAAA;IAEjC,yCAAyC;IACzC,SAAgB,SAAS,EAAE,SAAS,CAAA;IAEpC,qDAAqD;IACrD,SAAgB,eAAe,EAAE,eAAe,CAAA;IAEhD,yDAAyD;IACzD,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAE9C,kEAAkE;IAClE,SAAgB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAE/C,sCAAsC;IACtC,SAAgB,QAAQ,EAAE,QAAQ,CAAA;IAElC,oEAAoE;IACpE,SAAgB,kBAAkB,EAAE,MAAM,CAAA;IAE1C,8CAA8C;IAC9C,SAAgB,cAAc,EAAE,OAAO,CAAA;IAEvC,0CAA0C;IAC1C,SAAgB,UAAU,EAAE,MAAM,CAAA;IAElC,4DAA4D;IAC5D,SAAgB,oBAAoB,EAAE,MAAM,CAAA;IAE5C,8DAA8D;IAC9D,SAAgB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAA;IAEtD,2FAA2F;IAC3F,SAAgB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S,EAAE,MAAM,GAAG,SAAS,CAAA;IAE7C,iEAAiE;IACjE,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAE9C;;;;OAIG;;CA4GJ"}
@@ -1,4 +1,4 @@
1
- import { AGENT_PERMISSIONS, AGENT_TYPES, DEFAULT_AGENT_PERMISSION, isAgentPermission, isAgentType, supportsAgentEffort, } from '../execution/AgentExecutor.js';
1
+ import { AGENT_EFFORT_SUPPORTED_TYPES, AGENT_PERMISSIONS, AGENT_TYPES, DEFAULT_AGENT_PERMISSION, isAgentPermission, isAgentType, supportsAgentEffort, } from '../execution/AgentExecutor.js';
2
2
  import { isLogLevel, LOG_LEVELS } from '../utils/Logger.js';
3
3
  /**
4
4
  * Server configuration management class.
@@ -51,6 +51,8 @@ export class ServerConfig {
51
51
  cursorApiKey;
52
52
  /** API key for GLM/Z.ai authentication (from CLI_API_KEY env var) */
53
53
  glmApiKey;
54
+ /** API key for Kimi authentication (from CLI_API_KEY env var) */
55
+ kimiApiKey;
54
56
  /**
55
57
  * Creates a new ServerConfig instance by loading values from environment variables
56
58
  * or using default values.
@@ -100,7 +102,7 @@ export class ServerConfig {
100
102
  this.agentEffort = agentEffortEnv || undefined;
101
103
  if (this.agentEffort && !supportsAgentEffort(this.agentType)) {
102
104
  throw new Error(`AGENT_EFFORT is not supported for AGENT_TYPE="${this.agentType}". ` +
103
- 'Supported types: codex, claude, glm, grok, opencode.');
105
+ `Supported types: ${AGENT_EFFORT_SUPPORTED_TYPES.join(', ')}.`);
104
106
  }
105
107
  const logLevelEnv = process.env['LOG_LEVEL']?.trim();
106
108
  if (!logLevelEnv) {
@@ -144,8 +146,10 @@ export class ServerConfig {
144
146
  // Cursor API key: prefer CURSOR_API_KEY, fall back to CLI_API_KEY for backward compatibility
145
147
  const cursorApiKeyEnv = process.env['CURSOR_API_KEY'] || process.env['CLI_API_KEY'];
146
148
  this.cursorApiKey = cursorApiKeyEnv?.trim() ? cursorApiKeyEnv : undefined;
147
- const glmApiKeyEnv = process.env['CLI_API_KEY'];
148
- this.glmApiKey = glmApiKeyEnv?.trim() ? glmApiKeyEnv : undefined;
149
+ const cliApiKeyEnv = process.env['CLI_API_KEY'];
150
+ const cliApiKey = cliApiKeyEnv?.trim() ? cliApiKeyEnv : undefined;
151
+ this.glmApiKey = cliApiKey;
152
+ this.kimiApiKey = cliApiKey;
149
153
  }
150
154
  }
151
155
  //# sourceMappingURL=ServerConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServerConfig.js","sourceRoot":"","sources":["../../src/config/ServerConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EAGX,wBAAwB,EACxB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,GACpB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,YAAY;IACvB,uDAAuD;IACvC,UAAU,CAAQ;IAElC,6CAA6C;IAC7B,aAAa,CAAQ;IAErC,gEAAgE;IAChD,SAAS,CAAQ;IAEjC,yCAAyC;IACzB,SAAS,CAAW;IAEpC,qDAAqD;IACrC,eAAe,CAAiB;IAEhD,yDAAyD;IACzC,UAAU,CAAoB;IAE9C,kEAAkE;IAClD,WAAW,CAAoB;IAE/C,sCAAsC;IACtB,QAAQ,CAAU;IAElC,oEAAoE;IACpD,kBAAkB,CAAQ;IAE1C,8CAA8C;IAC9B,cAAc,CAAS;IAEvC,0CAA0C;IAC1B,UAAU,CAAQ;IAElC,4DAA4D;IAC5C,oBAAoB,CAAQ;IAE5C,8DAA8D;IAC9C,kBAAkB,CAAoB;IAEtD,2FAA2F;IAC3E,YAAY,CAAoB;IAEhD,qEAAqE;IACrD,SAAS,CAAoB;IAE7C;;;;OAIG;IACH;QACE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,g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EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAA;QACjE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;IAC7B,CAAC;CACF"}
@@ -49,7 +49,7 @@ export interface ExecutionConfig {
49
49
  maxOutputBytes: number;
50
50
  /**
51
51
  * Type of agent to use for execution.
52
- * 'cursor', 'claude', 'gemini', 'codex', 'glm', 'grok', or 'opencode'
52
+ * 'cursor', 'claude', 'gemini', 'codex', 'glm', 'kimi', 'grok', or 'opencode'
53
53
  */
54
54
  agentType: AgentType;
55
55
  /**
@@ -80,6 +80,11 @@ export interface ExecutionConfig {
80
80
  * Passed to the claude binary via ANTHROPIC_AUTH_TOKEN environment variable.
81
81
  */
82
82
  glmApiKey?: string;
83
+ /**
84
+ * API key for Kimi authentication.
85
+ * Passed to the claude binary via ANTHROPIC_API_KEY environment variable.
86
+ */
87
+ kimiApiKey?: string;
83
88
  /** Optional model override applied to every execution by this MCP server. */
84
89
  model?: string;
85
90
  /** Optional backend-specific reasoning effort or model variant. */
@@ -90,10 +95,10 @@ export declare const DEFAULT_EXECUTION_TIMEOUT = 300000;
90
95
  * Supported agent runtimes. Single source of truth for both runtime validation
91
96
  * (ServerConfig) and static typing.
92
97
  */
93
- export declare const AGENT_TYPES: readonly ["cursor", "claude", "gemini", "codex", "glm", "grok", "opencode"];
98
+ export declare const AGENT_TYPES: readonly ["cursor", "claude", "gemini", "codex", "glm", "kimi", "grok", "opencode"];
94
99
  export type AgentType = (typeof AGENT_TYPES)[number];
95
100
  export declare function isAgentType(value: unknown): value is AgentType;
96
- export declare const AGENT_EFFORT_SUPPORTED_TYPES: readonly ["codex", "claude", "glm", "grok", "opencode"];
101
+ export declare const AGENT_EFFORT_SUPPORTED_TYPES: readonly ["codex", "claude", "glm", "kimi", "grok", "opencode"];
97
102
  export declare function supportsAgentEffort(agentType: AgentType): agentType is (typeof AGENT_EFFORT_SUPPORTED_TYPES)[number];
98
103
  /**
99
104
  * Supported permission levels. Single source of truth for both runtime
@@ -175,6 +180,8 @@ export declare class AgentExecutor {
175
180
  private buildCodexArgs;
176
181
  private buildClaudeArgs;
177
182
  private buildGlmArgs;
183
+ private buildKimiArgs;
184
+ private buildRedirectedClaudeArgs;
178
185
  private buildGeminiArgs;
179
186
  private buildCursorArgs;
180
187
  private buildGrokArgs;
@@ -1 +1 @@
1
- {"version":3,"file":"AgentExecutor.d.ts","sourceRoot":"","sources":["../../src/execution/AgentExecutor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,MAAM,EAAiB,MAAM,oBAAoB,CAAA;AAG1D;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB,+DAA+D;IAC/D,cAAc,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;;;;;;OAOG;IACH,UAAU,EAAE,eAAe,CAAA;IAE3B;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,mEAAmE;IACnE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CAAC,MAAM,CAAQ;IAE/B;;;;;OAKG;gBACS,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM;IAMpD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA+E1E;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IA2BxB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,eAAe;IAqCvB,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,yBAAyB;IAoCjC,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,aAAa;YAYP,uBAAuB;IAiDrC,OAAO,CAAC,SAAS;IAOjB;;;;;;OAMG;YACW,gBAAgB;IAqM9B,OAAO,CAAC,YAAY;IAMpB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAG1B"}
@@ -9,10 +9,15 @@ export const DEFAULT_EXECUTION_TIMEOUT = 300000; // 5 minutes
9
9
  const MAX_CAPTURED_OUTPUT_BYTES = 16 * 1024 * 1024;
10
10
  const TERMINATION_GRACE_MS = 1000;
11
11
  const GLM_BASE_URL = 'https://api.z.ai/api/anthropic';
12
+ const KIMI_BASE_URL = 'https://api.kimi.com/coding/';
12
13
  const GLM_MISSING_API_KEY_ERROR = 'GLM backend needs a Z.ai API token in the CLI_API_KEY environment variable. ' +
13
14
  'Add CLI_API_KEY to this MCP server environment in your MCP client configuration, ' +
14
15
  'then restart or reconnect the MCP server so the running process receives it. ' +
15
16
  'This run will keep failing until the MCP process is restarted with CLI_API_KEY set.';
17
+ const KIMI_MISSING_API_KEY_ERROR = 'Kimi backend needs an API key in the CLI_API_KEY environment variable. ' +
18
+ 'Add CLI_API_KEY to this MCP server environment in your MCP client configuration, ' +
19
+ 'then restart or reconnect the MCP server so the running process receives it. ' +
20
+ 'This run will keep failing until the MCP process is restarted with CLI_API_KEY set.';
16
21
  /**
17
22
  * Supported agent runtimes. Single source of truth for both runtime validation
18
23
  * (ServerConfig) and static typing.
@@ -23,13 +28,21 @@ export const AGENT_TYPES = [
23
28
  'gemini',
24
29
  'codex',
25
30
  'glm',
31
+ 'kimi',
26
32
  'grok',
27
33
  'opencode',
28
34
  ];
29
35
  export function isAgentType(value) {
30
36
  return typeof value === 'string' && AGENT_TYPES.includes(value);
31
37
  }
32
- export const AGENT_EFFORT_SUPPORTED_TYPES = ['codex', 'claude', 'glm', 'grok', 'opencode'];
38
+ export const AGENT_EFFORT_SUPPORTED_TYPES = [
39
+ 'codex',
40
+ 'claude',
41
+ 'glm',
42
+ 'kimi',
43
+ 'grok',
44
+ 'opencode',
45
+ ];
33
46
  export function supportsAgentEffort(agentType) {
34
47
  return AGENT_EFFORT_SUPPORTED_TYPES.includes(agentType);
35
48
  }
@@ -73,6 +86,11 @@ const PERMISSION_FLAGS = {
73
86
  'safe-edit': ['--permission-mode', 'acceptEdits'],
74
87
  yolo: ['--dangerously-skip-permissions'],
75
88
  },
89
+ kimi: {
90
+ 'read-only': ['--permission-mode', 'plan'],
91
+ 'safe-edit': ['--permission-mode', 'acceptEdits'],
92
+ yolo: ['--dangerously-skip-permissions'],
93
+ },
76
94
  gemini: {
77
95
  'read-only': ['--approval-mode', 'plan'],
78
96
  'safe-edit': ['--approval-mode', 'auto_edit'],
@@ -255,6 +273,8 @@ export class AgentExecutor {
255
273
  return this.buildClaudeArgs(params, envOverrides);
256
274
  case 'glm':
257
275
  return this.buildGlmArgs(params, envOverrides);
276
+ case 'kimi':
277
+ return this.buildKimiArgs(params, envOverrides);
258
278
  case 'gemini':
259
279
  return this.buildGeminiArgs(params, envOverrides);
260
280
  case 'cursor':
@@ -284,7 +304,7 @@ export class AgentExecutor {
284
304
  env['CODEX_HOME'] = this.config.agentsSettingsPath;
285
305
  break;
286
306
  // claude: handled via --settings argv below
287
- // glm: uses the claude binary, but intentionally avoids Claude settings.
307
+ // glm/kimi: use the claude binary, but intentionally avoid Claude settings.
288
308
  // grok: not supported (upstream limitation)
289
309
  // opencode: uses its normal XDG/project configuration discovery.
290
310
  // gemini: not supported (upstream limitation)
@@ -308,6 +328,7 @@ export class AgentExecutor {
308
328
  break;
309
329
  case 'claude':
310
330
  case 'glm':
331
+ case 'kimi':
311
332
  flags.push('--effort', this.config.effort);
312
333
  break;
313
334
  case 'grok':
@@ -361,6 +382,16 @@ export class AgentExecutor {
361
382
  if (!apiKey?.trim()) {
362
383
  throw new Error(GLM_MISSING_API_KEY_ERROR);
363
384
  }
385
+ return this.buildRedirectedClaudeArgs(params, envOverrides, GLM_BASE_URL, apiKey, 'ANTHROPIC_AUTH_TOKEN');
386
+ }
387
+ buildKimiArgs(params, envOverrides) {
388
+ const apiKey = this.config.kimiApiKey;
389
+ if (!apiKey?.trim()) {
390
+ throw new Error(KIMI_MISSING_API_KEY_ERROR);
391
+ }
392
+ return this.buildRedirectedClaudeArgs(params, envOverrides, KIMI_BASE_URL, apiKey, 'ANTHROPIC_API_KEY');
393
+ }
394
+ buildRedirectedClaudeArgs(params, envOverrides, baseUrl, apiKey, credentialEnv) {
364
395
  const flags = this.invocationFlags();
365
396
  const cwd = params.cwd || process.cwd();
366
397
  const systemPrompt = `cwd: ${cwd}\n\n${params.agent}`;
@@ -374,15 +405,17 @@ export class AgentExecutor {
374
405
  '-p',
375
406
  params.prompt,
376
407
  ];
408
+ const redirectedEnv = {
409
+ ...envOverrides,
410
+ ANTHROPIC_BASE_URL: baseUrl,
411
+ ANTHROPIC_API_KEY: null,
412
+ ANTHROPIC_AUTH_TOKEN: null,
413
+ };
414
+ redirectedEnv[credentialEnv] = apiKey;
377
415
  return {
378
416
  command: 'claude',
379
417
  args,
380
- envOverrides: {
381
- ...envOverrides,
382
- ANTHROPIC_BASE_URL: GLM_BASE_URL,
383
- ANTHROPIC_AUTH_TOKEN: apiKey,
384
- ANTHROPIC_API_KEY: null,
385
- },
418
+ envOverrides: redirectedEnv,
386
419
  };
387
420
  }
388
421
  buildGeminiArgs(params, envOverrides) {
@@ -536,10 +569,10 @@ export class AgentExecutor {
536
569
  });
537
570
  return;
538
571
  }
539
- const streamProcessor = new StreamProcessor();
540
- let stdout = '';
541
- let stderr = '';
542
- let stdoutBuffer = '';
572
+ const streamProcessor = new StreamProcessor(this.config.agentType);
573
+ const stdoutParts = [];
574
+ const stderrParts = [];
575
+ let stdoutLineParts = [];
543
576
  const stdoutDecoder = new StringDecoder('utf8');
544
577
  const stderrDecoder = new StringDecoder('utf8');
545
578
  let stdoutTruncated = false;
@@ -569,16 +602,19 @@ export class AgentExecutor {
569
602
  clearTimers();
570
603
  if (!stdoutTruncated) {
571
604
  const tail = stdoutDecoder.end();
572
- stdout += tail;
573
- stdoutBuffer += tail;
605
+ stdoutParts.push(tail);
606
+ stdoutLineParts.push(tail);
574
607
  }
575
608
  if (!stderrTruncated) {
576
- stderr += stderrDecoder.end();
609
+ stderrParts.push(stderrDecoder.end());
577
610
  }
578
- if (stdoutBuffer.trim()) {
579
- streamProcessor.processLine(stdoutBuffer);
580
- stdoutBuffer = '';
611
+ const trailingLine = stdoutLineParts.join('');
612
+ if (trailingLine.trim()) {
613
+ streamProcessor.processLine(trailingLine);
581
614
  }
615
+ stdoutLineParts = [];
616
+ const stdout = stdoutParts.join('');
617
+ const stderr = stderrParts.join('');
582
618
  let result = streamProcessor.getResult();
583
619
  if (result === null) {
584
620
  streamProcessor.processCompleteOutput(stdout);
@@ -644,11 +680,18 @@ export class AgentExecutor {
644
680
  const chunk = captureChunk(data, stdoutDecoder, () => {
645
681
  stdoutTruncated = true;
646
682
  });
647
- stdout += chunk;
648
- stdoutBuffer += chunk;
649
- const lines = stdoutBuffer.split('\n');
650
- stdoutBuffer = lines.pop() || '';
651
- for (const line of lines) {
683
+ stdoutParts.push(chunk);
684
+ let chunkOffset = 0;
685
+ while (chunkOffset < chunk.length) {
686
+ const newlineIndex = chunk.indexOf('\n', chunkOffset);
687
+ if (newlineIndex < 0) {
688
+ stdoutLineParts.push(chunk.slice(chunkOffset));
689
+ break;
690
+ }
691
+ stdoutLineParts.push(chunk.slice(chunkOffset, newlineIndex));
692
+ const line = stdoutLineParts.join('');
693
+ stdoutLineParts = [];
694
+ chunkOffset = newlineIndex + 1;
652
695
  if (streamProcessor.processLine(line)) {
653
696
  requestTermination();
654
697
  break;
@@ -656,9 +699,9 @@ export class AgentExecutor {
656
699
  }
657
700
  });
658
701
  childProcess.stderr?.on('data', (data) => {
659
- stderr += captureChunk(data, stderrDecoder, () => {
702
+ stderrParts.push(captureChunk(data, stderrDecoder, () => {
660
703
  stderrTruncated = true;
661
- });
704
+ }));
662
705
  });
663
706
  childProcess.on('close', (code, signal) => {
664
707
  void finish(code, signal);