@leo000001/claude-code-mcp 2.5.0 → 2.8.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/CHANGELOG.md +11 -1
- package/NOTICE.md +1 -1
- package/README.md +86 -22
- package/dist/index.js +107 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
- Upgrade `@anthropic-ai/claude-agent-sdk` to `^0.2.81` and align exposed option passthrough with current SDK fields (`toolConfig`, `agentProgressSummaries`, `settings`).
|
|
8
|
+
- Expand SDK stream/event mapping for `rate_limit_event`, `system/api_retry`, `system/local_command_output`, `system/elicitation_complete`, `system/compact_boundary`, and partial `stream_event` output.
|
|
9
|
+
- Preserve newer SDK metadata in session/results, including `fastModeState` and richer permission prompt labels (`title`, `displayName`).
|
|
10
|
+
- Prefer SDK permission `suggestions` for `allow_for_session` responses and sync session metadata from `system/init` (for example actual model / permission mode).
|
|
11
|
+
|
|
12
|
+
### Documentation
|
|
13
|
+
|
|
14
|
+
- Add OpenCode-specific setup and usage guidance, including local MCP config examples and async polling recommendations.
|
|
15
|
+
- Sync README and DESIGN option/message matrices with the current SDK 0.2.81 surface.
|
|
6
16
|
|
|
7
17
|
## 2.5.0 (2026-02-27)
|
|
8
18
|
|
package/NOTICE.md
CHANGED
|
@@ -9,7 +9,7 @@ requirements on redistribution and use.
|
|
|
9
9
|
|
|
10
10
|
### Direct dependencies (from `package.json`)
|
|
11
11
|
|
|
12
|
-
- `@anthropic-ai/claude-agent-sdk@0.2.
|
|
12
|
+
- `@anthropic-ai/claude-agent-sdk@0.2.81` — license is declared as “SEE LICENSE IN README.md” in the package metadata. This package bundles a Claude Code CLI; please review Anthropic's documentation and legal terms referenced by that project before redistributing or deploying.
|
|
13
13
|
- `@modelcontextprotocol/sdk@1.27.1` — MIT License
|
|
14
14
|
- `zod@4.3.6` — MIT License
|
|
15
15
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://github.com/xihuai18/claude-code-mcp/blob/HEAD/LICENSE)
|
|
5
5
|
[](https://nodejs.org)
|
|
6
6
|
|
|
7
|
-
MCP server that wraps [Claude Code (Claude Agent SDK)](https://docs.anthropic.com/en/docs/claude-code/overview) as tools, enabling any MCP client to invoke Claude Code for autonomous coding tasks. Designed for local use — the MCP server and client are expected to run on the same machine.
|
|
7
|
+
MCP server that wraps [Claude Code (Claude Agent SDK)](https://docs.anthropic.com/en/docs/claude-code/overview) as tools, enabling any MCP client to invoke Claude Code for autonomous coding tasks. Designed for local use — the MCP server and client are expected to run on the same machine. It works especially well with OpenCode/Codex-style clients that prefer async polling and explicit permission decisions.
|
|
8
8
|
|
|
9
9
|
Inspired by the [Codex MCP](https://developers.openai.com/codex/guides/agents-sdk/) design philosophy — minimum tools, maximum capability.
|
|
10
10
|
|
|
@@ -70,6 +70,26 @@ Add to your MCP client configuration (Claude Desktop, Cursor, etc.):
|
|
|
70
70
|
claude mcp add --transport stdio claude-code -- npx -y @leo000001/claude-code-mcp
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
### OpenCode
|
|
74
|
+
|
|
75
|
+
Add a local MCP entry in `opencode.json` / `opencode.jsonc` (project) or the global OpenCode config under `~/.config/opencode/`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcp": {
|
|
80
|
+
"claude-code": {
|
|
81
|
+
"type": "local",
|
|
82
|
+
"command": ["npx", "-y", "@leo000001/claude-code-mcp"],
|
|
83
|
+
"enabled": true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
OpenCode tip: start with `claude_code`, keep the returned `sessionId`, then background-poll with `claude_code_check`. When approvals appear, `decision: "allow_for_session"` is usually the best UX because it reduces repeated prompts for the same tool in a session.
|
|
90
|
+
|
|
91
|
+
> OpenCode project configs can launch local commands. Only enable repository-level MCP configs in repos you trust.
|
|
92
|
+
|
|
73
93
|
### OpenAI Codex CLI
|
|
74
94
|
|
|
75
95
|
```bash
|
|
@@ -117,7 +137,7 @@ Start a new Claude Code session. The agent autonomously performs coding tasks: r
|
|
|
117
137
|
| `advanced` | object | No | Advanced/low-frequency parameters (see below) |
|
|
118
138
|
|
|
119
139
|
<details>
|
|
120
|
-
<summary><code>advanced</code> object parameters (
|
|
140
|
+
<summary><code>advanced</code> object parameters (24 low-frequency parameters)</summary>
|
|
121
141
|
|
|
122
142
|
| Parameter | Type | Description |
|
|
123
143
|
| ------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -135,9 +155,12 @@ Start a new Claude Code session. The agent autonomously performs coding tasks: r
|
|
|
135
155
|
| `advanced.sandbox` | object | Sandbox configuration for isolating shell command execution (e.g., Docker container settings). Default: SDK/Claude Code default |
|
|
136
156
|
| `advanced.fallbackModel` | string | Fallback model if the primary model fails or is unavailable. Default: none |
|
|
137
157
|
| `advanced.enableFileCheckpointing` | boolean | Enable file checkpointing to track file changes during the session. Default: `false` |
|
|
158
|
+
| `advanced.toolConfig` | object | Per-tool built-in configuration. Example: `{ askUserQuestion: { previewFormat: "html" } }`. Default: none |
|
|
138
159
|
| `advanced.includePartialMessages` | boolean | When true, includes intermediate streaming messages in the response. Useful for real-time progress monitoring. Default: false |
|
|
139
160
|
| `advanced.promptSuggestions` | boolean | When true, emits post-turn prompt suggestion events (`prompt_suggestion`). Default: `false` |
|
|
161
|
+
| `advanced.agentProgressSummaries` | boolean | When true, emits AI-generated summaries on `system/task_progress` events for running subagents. Default: `false` |
|
|
140
162
|
| `advanced.strictMcpConfig` | boolean | Enforce strict validation of MCP server configurations. Default: `false` |
|
|
163
|
+
| `advanced.settings` | string \| object | Extra Claude Code flag settings. Pass either a path to a settings JSON file or an inline settings object. Default: none |
|
|
141
164
|
| `advanced.settingSources` | string[] | Which filesystem settings to load. Defaults to `["user", "project", "local"]` (loads all settings and CLAUDE.md). Pass `[]` for SDK isolation mode |
|
|
142
165
|
| `advanced.debug` | boolean | Enable debug mode for verbose logging. Default: `false` |
|
|
143
166
|
| `advanced.debugFile` | string | Write debug logs to a specific file path (implicitly enables debug mode). Default: omitted |
|
|
@@ -178,7 +201,7 @@ Continue an existing session by sending a follow-up message. The agent retains f
|
|
|
178
201
|
| `diskResumeConfig` | object | No | Disk resume parameters (see below). Used when `CLAUDE_CODE_MCP_ALLOW_DISK_RESUME=1` and in-memory session is missing |
|
|
179
202
|
|
|
180
203
|
<details>
|
|
181
|
-
<summary><code>diskResumeConfig</code> object parameters (
|
|
204
|
+
<summary><code>diskResumeConfig</code> object parameters (34 disk-resume-only parameters)</summary>
|
|
182
205
|
|
|
183
206
|
| Parameter | Type | Description |
|
|
184
207
|
| --------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------- |
|
|
@@ -206,9 +229,12 @@ Continue an existing session by sending a follow-up message. The agent retains f
|
|
|
206
229
|
| `diskResumeConfig.sandbox` | object | Sandbox config for command isolation. Default: SDK/Claude Code default |
|
|
207
230
|
| `diskResumeConfig.fallbackModel` | string | Fallback model. Default: none |
|
|
208
231
|
| `diskResumeConfig.enableFileCheckpointing` | boolean | Enable file checkpointing. Default: `false` |
|
|
232
|
+
| `diskResumeConfig.toolConfig` | object | Per-tool built-in configuration. Default: none |
|
|
209
233
|
| `diskResumeConfig.includePartialMessages` | boolean | Include intermediate streaming messages. Default: `false` |
|
|
210
234
|
| `diskResumeConfig.promptSuggestions` | boolean | Emit post-turn prompt suggestion events (`prompt_suggestion`). Default: `false` |
|
|
235
|
+
| `diskResumeConfig.agentProgressSummaries` | boolean | Emit AI-generated subagent progress summaries. Default: `false` |
|
|
211
236
|
| `diskResumeConfig.strictMcpConfig` | boolean | Strict MCP config validation. Default: `false` |
|
|
237
|
+
| `diskResumeConfig.settings` | string \| object | Extra Claude Code flag settings (path or inline object). Default: none |
|
|
212
238
|
| `diskResumeConfig.settingSources` | string[] | Which filesystem settings to load. Default: `["user", "project", "local"]` |
|
|
213
239
|
| `diskResumeConfig.debug` | boolean | Debug mode. Default: `false` |
|
|
214
240
|
| `diskResumeConfig.debugFile` | string | Debug log file path. Default: omitted |
|
|
@@ -260,15 +286,15 @@ Resource templates:
|
|
|
260
286
|
|
|
261
287
|
List, inspect, cancel, or interrupt sessions.
|
|
262
288
|
|
|
263
|
-
| Parameter | Type | Required | Description
|
|
264
|
-
| ------------------ | ------- | ------------------------ |
|
|
265
|
-
| `action` | string | Yes | `"list"`, `"get"`, `"cancel"`, or `"interrupt"`
|
|
266
|
-
| `sessionId` | string | For get/cancel/interrupt | Target session ID
|
|
267
|
-
| `includeSensitive` | boolean | No | Include `cwd`/`systemPrompt`/`agents`/`additionalDirectories` (default: false) |
|
|
289
|
+
| Parameter | Type | Required | Description |
|
|
290
|
+
| ------------------ | ------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------- |
|
|
291
|
+
| `action` | string | Yes | `"list"`, `"get"`, `"cancel"`, or `"interrupt"` |
|
|
292
|
+
| `sessionId` | string | For get/cancel/interrupt | Target session ID |
|
|
293
|
+
| `includeSensitive` | boolean | No | Include `cwd`/`systemPrompt`/`agents`/`additionalDirectories`/`toolConfig` (default: false; `settings` stays hidden) |
|
|
268
294
|
|
|
269
295
|
**Returns:** `{ sessions, message?, isError? }`
|
|
270
296
|
|
|
271
|
-
`sessions[]` now includes lightweight diagnostics fields: `pendingPermissionCount`, `eventCount`, `currentCursor`, `lastEventId`, `ttlMs`, `lastError?`, `lastErrorAt?`, and `redactions[]`.
|
|
297
|
+
`sessions[]` now includes lightweight diagnostics fields: `pendingPermissionCount`, `eventCount`, `currentCursor`, `lastEventId`, `ttlMs`, `lastError?`, `lastErrorAt?`, `fastModeState?`, and `redactions[]`.
|
|
272
298
|
|
|
273
299
|
### `claude_code_check` — Poll events and respond to permission requests
|
|
274
300
|
|
|
@@ -291,18 +317,18 @@ Poll session events/results and approve/deny pending permission requests.
|
|
|
291
317
|
<details>
|
|
292
318
|
<summary><code>pollOptions</code> object parameters (10 fine-grained poll controls)</summary>
|
|
293
319
|
|
|
294
|
-
| Parameter | Type | Description
|
|
295
|
-
| ------------------------------------- | ------- |
|
|
296
|
-
| `pollOptions.includeTools` | boolean | When true, includes `availableTools` (`poll` only). Default: `false` (omitted until session init is received). Derived from SDK `system/init.tools` (internal features may not appear).
|
|
297
|
-
| `pollOptions.includeEvents` | boolean | When false, omits `events` (but `nextCursor` still advances). Default: `true`
|
|
298
|
-
| `pollOptions.includeActions` | boolean | When false, omits `actions[]` even if `waiting_permission`. Default: `true`
|
|
299
|
-
| `pollOptions.includeResult` | boolean | When false, omits top-level `result` even when `idle`/`error`. Default: `true`
|
|
300
|
-
| `pollOptions.includeUsage` | boolean | Include `result.usage` (default: `true` in `"full"`, `false` in `"minimal"`/`"delta_compact"`)
|
|
301
|
-
| `pollOptions.includeModelUsage` | boolean | Include `result.modelUsage` (default: `true` in `"full"`, `false` in `"minimal"`/`"delta_compact"`)
|
|
302
|
-
| `pollOptions.includeStructuredOutput` | boolean | Include `result.structuredOutput` (default: `true` in `"full"`, `false` in `"minimal"`/`"delta_compact"`)
|
|
303
|
-
| `pollOptions.includeTerminalEvents` | boolean | When true, keeps terminal `result`/`error` events in `events` even if top-level `result` is included. Default: `false` in `"minimal"`/`"delta_compact"`, `true` in `"full"`
|
|
304
|
-
| `pollOptions.includeProgressEvents` | boolean | When true, includes noisy SDK progress subtypes (e.g. `tool_progress`, `auth_status`, `system/task_progress`, `system/hook_progress`) as MCP `progress` events. Default: `false` in `"minimal"`/`"delta_compact"`, `true` in `"full"` |
|
|
305
|
-
| `pollOptions.maxBytes` | number | Approximate max JSON bytes for `events` in this response. When exceeded, events are truncated and `truncatedFields` includes `"events_bytes"`. Default: unlimited
|
|
320
|
+
| Parameter | Type | Description |
|
|
321
|
+
| ------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
322
|
+
| `pollOptions.includeTools` | boolean | When true, includes `availableTools` (`poll` only). Default: `false` (omitted until session init is received). Derived from SDK `system/init.tools` (internal features may not appear). |
|
|
323
|
+
| `pollOptions.includeEvents` | boolean | When false, omits `events` (but `nextCursor` still advances). Default: `true` |
|
|
324
|
+
| `pollOptions.includeActions` | boolean | When false, omits `actions[]` even if `waiting_permission`. Default: `true` |
|
|
325
|
+
| `pollOptions.includeResult` | boolean | When false, omits top-level `result` even when `idle`/`error`. Default: `true` |
|
|
326
|
+
| `pollOptions.includeUsage` | boolean | Include `result.usage` (default: `true` in `"full"`, `false` in `"minimal"`/`"delta_compact"`) |
|
|
327
|
+
| `pollOptions.includeModelUsage` | boolean | Include `result.modelUsage` (default: `true` in `"full"`, `false` in `"minimal"`/`"delta_compact"`) |
|
|
328
|
+
| `pollOptions.includeStructuredOutput` | boolean | Include `result.structuredOutput` (default: `true` in `"full"`, `false` in `"minimal"`/`"delta_compact"`) |
|
|
329
|
+
| `pollOptions.includeTerminalEvents` | boolean | When true, keeps terminal `result`/`error` events in `events` even if top-level `result` is included. Default: `false` in `"minimal"`/`"delta_compact"`, `true` in `"full"` |
|
|
330
|
+
| `pollOptions.includeProgressEvents` | boolean | When true, includes noisy SDK progress subtypes (e.g. `tool_progress`, `auth_status`, `system/api_retry`, `system/task_progress`, `system/hook_progress`) as MCP `progress` events. Default: `false` in `"minimal"`/`"delta_compact"`, `true` in `"full"` |
|
|
331
|
+
| `pollOptions.maxBytes` | number | Approximate max JSON bytes for `events` in this response. When exceeded, events are truncated and `truncatedFields` includes `"events_bytes"`. Default: unlimited |
|
|
306
332
|
|
|
307
333
|
</details>
|
|
308
334
|
|
|
@@ -330,8 +356,11 @@ Notes:
|
|
|
330
356
|
- `toolValidation` reports whether configured `allowedTools`/`disallowedTools` match runtime-discovered tool names.
|
|
331
357
|
- `compatWarnings` surfaces compatibility hints (for example, unresolved tool names or path/platform mismatch signals) and is **non-blocking**; treat it as advisory unless the session actually fails.
|
|
332
358
|
- Permission `actions[]` include `timeoutMs`, `expiresAt`, and best-effort `remainingMs` to help callers avoid auto-deny timeouts.
|
|
359
|
+
- Permission `actions[]` may also include SDK-provided `title` / `displayName` metadata; clients should prefer those strings when rendering approval UI.
|
|
360
|
+
- For `decision="allow_for_session"`, the server now prefers SDK-provided `suggestions` (for example `addDirectories`) when present, then falls back to a generic per-session tool allow rule.
|
|
333
361
|
- `permission_result` event data is `{ requestId, toolName, behavior, source, message?, interrupt? }` (denial details only present for `deny`).
|
|
334
|
-
-
|
|
362
|
+
- `result.fastModeState` may be present when the SDK reports fast-mode state, and `claude_code_session` surfaces the latest known `fastModeState` for each session.
|
|
363
|
+
- In `"minimal"` mode (default): assistant message events are slimmed (strips `usage`, `model`, `id`, `cache_control` from content blocks); noisy SDK progress subtypes (`tool_progress`, `auth_status`, `system/api_retry`, `system/task_progress`, `system/hook_progress`) are filtered out; `lastEventId`/`lastToolUseId` are omitted; `AgentResult` omits `durationApiMs`/`sessionTotalTurns`/`sessionTotalCostUsd`. Use `responseMode: "full"` or individual `include*` flags to restore any of these.
|
|
335
364
|
- In `"delta_compact"` mode: defaults are optimized for high-frequency polling (`events` and top-level `result` omitted unless explicitly enabled via `pollOptions`), while still returning session status/actions/cursors.
|
|
336
365
|
|
|
337
366
|
## Usage Example
|
|
@@ -410,6 +439,23 @@ For JSON-based MCP clients (Claude Desktop, Cursor, etc.):
|
|
|
410
439
|
}
|
|
411
440
|
```
|
|
412
441
|
|
|
442
|
+
For OpenCode (`opencode.json` / `opencode.jsonc`):
|
|
443
|
+
|
|
444
|
+
```json
|
|
445
|
+
{
|
|
446
|
+
"mcp": {
|
|
447
|
+
"claude-code": {
|
|
448
|
+
"type": "local",
|
|
449
|
+
"command": ["npx", "-y", "@leo000001/claude-code-mcp"],
|
|
450
|
+
"enabled": true,
|
|
451
|
+
"environment": {
|
|
452
|
+
"CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
413
459
|
For OpenAI Codex CLI (`~/.codex/config.toml`):
|
|
414
460
|
|
|
415
461
|
```toml
|
|
@@ -493,6 +539,24 @@ CLAUDE_CODE_MCP_ALLOW_DISK_RESUME = "1"
|
|
|
493
539
|
CLAUDE_CODE_MCP_RESUME_SECRET = "change-me"
|
|
494
540
|
```
|
|
495
541
|
|
|
542
|
+
**OpenCode** — add an `environment` block under the local MCP entry:
|
|
543
|
+
|
|
544
|
+
```json
|
|
545
|
+
{
|
|
546
|
+
"mcp": {
|
|
547
|
+
"claude-code": {
|
|
548
|
+
"type": "local",
|
|
549
|
+
"command": ["npx", "-y", "@leo000001/claude-code-mcp"],
|
|
550
|
+
"enabled": true,
|
|
551
|
+
"environment": {
|
|
552
|
+
"CLAUDE_CODE_MCP_ALLOW_DISK_RESUME": "1",
|
|
553
|
+
"CLAUDE_CODE_MCP_RESUME_SECRET": "change-me"
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
```
|
|
559
|
+
|
|
496
560
|
**System-wide** — set via your shell profile or OS settings so all processes inherit them:
|
|
497
561
|
|
|
498
562
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -231,12 +231,16 @@ var SessionManager = class _SessionManager {
|
|
|
231
231
|
sandbox: params.sandbox,
|
|
232
232
|
fallbackModel: params.fallbackModel,
|
|
233
233
|
enableFileCheckpointing: params.enableFileCheckpointing,
|
|
234
|
+
toolConfig: params.toolConfig,
|
|
234
235
|
includePartialMessages: params.includePartialMessages,
|
|
235
236
|
promptSuggestions: params.promptSuggestions,
|
|
237
|
+
agentProgressSummaries: params.agentProgressSummaries,
|
|
236
238
|
strictMcpConfig: params.strictMcpConfig,
|
|
239
|
+
settings: params.settings,
|
|
237
240
|
settingSources: params.settingSources,
|
|
238
241
|
debug: params.debug,
|
|
239
242
|
debugFile: params.debugFile,
|
|
243
|
+
fastModeState: params.fastModeState,
|
|
240
244
|
env: params.env,
|
|
241
245
|
abortController: params.abortController,
|
|
242
246
|
queryInterrupt: params.queryInterrupt
|
|
@@ -753,7 +757,8 @@ var SessionManager = class _SessionManager {
|
|
|
753
757
|
cwd: info.cwd,
|
|
754
758
|
systemPrompt: info.systemPrompt,
|
|
755
759
|
agents: info.agents,
|
|
756
|
-
additionalDirectories: info.additionalDirectories
|
|
760
|
+
additionalDirectories: info.additionalDirectories,
|
|
761
|
+
toolConfig: info.toolConfig
|
|
757
762
|
};
|
|
758
763
|
}
|
|
759
764
|
/** Serialize session info for listing/inspection (redacts sensitive fields) */
|
|
@@ -766,8 +771,10 @@ var SessionManager = class _SessionManager {
|
|
|
766
771
|
agents: _agents,
|
|
767
772
|
additionalDirectories: _additionalDirectories,
|
|
768
773
|
pathToClaudeCodeExecutable: _pathToClaudeCodeExecutable,
|
|
774
|
+
toolConfig: _toolConfig,
|
|
769
775
|
mcpServers: _mcpServers,
|
|
770
776
|
sandbox: _sandbox,
|
|
777
|
+
settings: _settings,
|
|
771
778
|
settingSources: _settingSources,
|
|
772
779
|
debugFile: _debugFile,
|
|
773
780
|
env: _env,
|
|
@@ -844,7 +851,7 @@ var SessionManager = class _SessionManager {
|
|
|
844
851
|
const isNoisyProgressEvent = (event) => {
|
|
845
852
|
if (event.type !== "progress") return false;
|
|
846
853
|
const t = event.data?.type;
|
|
847
|
-
return t === "tool_progress" || t === "auth_status" || t === "task_progress" || t === "hook_progress";
|
|
854
|
+
return t === "tool_progress" || t === "auth_status" || t === "api_retry" || t === "task_progress" || t === "hook_progress";
|
|
848
855
|
};
|
|
849
856
|
let toDropForSoftLimit = remaining - buffer.maxSize;
|
|
850
857
|
if (toDropForSoftLimit > 0) {
|
|
@@ -911,7 +918,6 @@ import { existsSync as existsSync2, statSync } from "fs";
|
|
|
911
918
|
|
|
912
919
|
// src/types.ts
|
|
913
920
|
var EFFORT_LEVELS = ["low", "medium", "high", "max"];
|
|
914
|
-
var AGENT_MODELS = ["sonnet", "opus", "haiku", "inherit"];
|
|
915
921
|
var SESSION_ACTIONS = ["list", "get", "cancel", "interrupt"];
|
|
916
922
|
var DEFAULT_SETTING_SOURCES = ["user", "project", "local"];
|
|
917
923
|
var CHECK_ACTIONS = ["poll", "respond_permission"];
|
|
@@ -1161,6 +1167,7 @@ function sdkResultToAgentResult(result) {
|
|
|
1161
1167
|
sessionTotalTurns: typeof sessionTotalTurns === "number" ? sessionTotalTurns : void 0,
|
|
1162
1168
|
sessionTotalCostUsd: typeof sessionTotalCostUsd === "number" ? sessionTotalCostUsd : void 0,
|
|
1163
1169
|
stopReason: result.stop_reason,
|
|
1170
|
+
fastModeState: result.fast_mode_state,
|
|
1164
1171
|
usage: result.usage,
|
|
1165
1172
|
modelUsage: result.modelUsage,
|
|
1166
1173
|
permissionDenials: result.permission_denials
|
|
@@ -1204,9 +1211,28 @@ function messageToEvent(msg) {
|
|
|
1204
1211
|
}
|
|
1205
1212
|
};
|
|
1206
1213
|
}
|
|
1214
|
+
if (msg.type === "stream_event") {
|
|
1215
|
+
return {
|
|
1216
|
+
type: "output",
|
|
1217
|
+
data: {
|
|
1218
|
+
type: "stream_event",
|
|
1219
|
+
event: msg.event,
|
|
1220
|
+
parent_tool_use_id: msg.parent_tool_use_id
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1207
1224
|
if (msg.type === "tool_use_summary") {
|
|
1208
1225
|
return { type: "progress", data: { type: "tool_use_summary", summary: msg.summary } };
|
|
1209
1226
|
}
|
|
1227
|
+
if (msg.type === "system" && msg.subtype === "local_command_output") {
|
|
1228
|
+
return {
|
|
1229
|
+
type: "output",
|
|
1230
|
+
data: {
|
|
1231
|
+
type: "local_command_output",
|
|
1232
|
+
content: msg.content
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1210
1236
|
if (msg.type === "tool_progress") {
|
|
1211
1237
|
return {
|
|
1212
1238
|
type: "progress",
|
|
@@ -1237,6 +1263,15 @@ function messageToEvent(msg) {
|
|
|
1237
1263
|
data: { type: "status", status: msg.status, permissionMode: msg.permissionMode }
|
|
1238
1264
|
};
|
|
1239
1265
|
}
|
|
1266
|
+
if (msg.type === "system" && msg.subtype === "compact_boundary") {
|
|
1267
|
+
return {
|
|
1268
|
+
type: "progress",
|
|
1269
|
+
data: {
|
|
1270
|
+
type: "compact_boundary",
|
|
1271
|
+
compact_metadata: msg.compact_metadata
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1240
1275
|
if (msg.type === "system" && msg.subtype === "hook_started") {
|
|
1241
1276
|
return {
|
|
1242
1277
|
type: "progress",
|
|
@@ -1289,6 +1324,19 @@ function messageToEvent(msg) {
|
|
|
1289
1324
|
}
|
|
1290
1325
|
};
|
|
1291
1326
|
}
|
|
1327
|
+
if (msg.type === "system" && msg.subtype === "api_retry") {
|
|
1328
|
+
return {
|
|
1329
|
+
type: "progress",
|
|
1330
|
+
data: {
|
|
1331
|
+
type: "api_retry",
|
|
1332
|
+
attempt: msg.attempt,
|
|
1333
|
+
max_retries: msg.max_retries,
|
|
1334
|
+
retry_delay_ms: msg.retry_delay_ms,
|
|
1335
|
+
error_status: msg.error_status,
|
|
1336
|
+
error: msg.error
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1292
1340
|
if (msg.type === "system" && msg.subtype === "task_started") {
|
|
1293
1341
|
return {
|
|
1294
1342
|
type: "progress",
|
|
@@ -1297,7 +1345,8 @@ function messageToEvent(msg) {
|
|
|
1297
1345
|
task_id: msg.task_id,
|
|
1298
1346
|
tool_use_id: msg.tool_use_id,
|
|
1299
1347
|
description: msg.description,
|
|
1300
|
-
task_type: msg.task_type
|
|
1348
|
+
task_type: msg.task_type,
|
|
1349
|
+
prompt: msg.prompt
|
|
1301
1350
|
}
|
|
1302
1351
|
};
|
|
1303
1352
|
}
|
|
@@ -1310,7 +1359,8 @@ function messageToEvent(msg) {
|
|
|
1310
1359
|
tool_use_id: msg.tool_use_id,
|
|
1311
1360
|
description: msg.description,
|
|
1312
1361
|
usage: msg.usage,
|
|
1313
|
-
last_tool_name: msg.last_tool_name
|
|
1362
|
+
last_tool_name: msg.last_tool_name,
|
|
1363
|
+
summary: msg.summary
|
|
1314
1364
|
}
|
|
1315
1365
|
};
|
|
1316
1366
|
}
|
|
@@ -1328,7 +1378,17 @@ function messageToEvent(msg) {
|
|
|
1328
1378
|
}
|
|
1329
1379
|
};
|
|
1330
1380
|
}
|
|
1331
|
-
if (msg.type === "
|
|
1381
|
+
if (msg.type === "system" && msg.subtype === "elicitation_complete") {
|
|
1382
|
+
return {
|
|
1383
|
+
type: "progress",
|
|
1384
|
+
data: {
|
|
1385
|
+
type: "elicitation_complete",
|
|
1386
|
+
mcp_server_name: msg.mcp_server_name,
|
|
1387
|
+
elicitation_id: msg.elicitation_id
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
if (msg.type === "rate_limit_event" || msg.type === "prompt_suggestion") {
|
|
1332
1392
|
const rest = { ...msg };
|
|
1333
1393
|
delete rest.type;
|
|
1334
1394
|
delete rest.uuid;
|
|
@@ -1416,8 +1476,10 @@ function consumeQuery(params) {
|
|
|
1416
1476
|
requestId,
|
|
1417
1477
|
toolName,
|
|
1418
1478
|
input: normalizedInput,
|
|
1419
|
-
summary: summarizePermission(toolName, normalizedInput),
|
|
1420
|
-
|
|
1479
|
+
summary: options2.title ?? summarizePermission(toolName, normalizedInput),
|
|
1480
|
+
title: options2.title,
|
|
1481
|
+
displayName: options2.displayName,
|
|
1482
|
+
description: options2.description ?? describeTool(toolName, params.toolCache),
|
|
1421
1483
|
decisionReason: options2.decisionReason,
|
|
1422
1484
|
blockedPath: options2.blockedPath,
|
|
1423
1485
|
toolUseID: options2.toolUseID,
|
|
@@ -1514,6 +1576,11 @@ function consumeQuery(params) {
|
|
|
1514
1576
|
params.toolCache?.updateFromInit(message.tools);
|
|
1515
1577
|
params.onInit?.(message);
|
|
1516
1578
|
params.sessionManager.setInitTools(message.session_id, message.tools);
|
|
1579
|
+
params.sessionManager.update(message.session_id, {
|
|
1580
|
+
model: message.model,
|
|
1581
|
+
permissionMode: message.permissionMode,
|
|
1582
|
+
fastModeState: message.fast_mode_state
|
|
1583
|
+
});
|
|
1517
1584
|
activeSessionId = message.session_id;
|
|
1518
1585
|
if (!sessionIdResolved && shouldWaitForInit) {
|
|
1519
1586
|
sessionIdResolved = true;
|
|
@@ -1580,6 +1647,7 @@ function consumeQuery(params) {
|
|
|
1580
1647
|
status: agentResult.isError ? "error" : "idle",
|
|
1581
1648
|
totalTurns: sessionTotalTurns,
|
|
1582
1649
|
totalCostUsd: sessionTotalCostUsd,
|
|
1650
|
+
fastModeState: agentResult.fastModeState,
|
|
1583
1651
|
abortController: void 0,
|
|
1584
1652
|
queryInterrupt: void 0
|
|
1585
1653
|
});
|
|
@@ -1587,6 +1655,7 @@ function consumeQuery(params) {
|
|
|
1587
1655
|
params.sessionManager.update(sessionId2, {
|
|
1588
1656
|
totalTurns: sessionTotalTurns,
|
|
1589
1657
|
totalCostUsd: sessionTotalCostUsd,
|
|
1658
|
+
fastModeState: agentResult.fastModeState,
|
|
1590
1659
|
abortController: void 0,
|
|
1591
1660
|
queryInterrupt: void 0
|
|
1592
1661
|
});
|
|
@@ -1821,10 +1890,14 @@ function buildOptions(src) {
|
|
|
1821
1890
|
if (src.fallbackModel !== void 0) opts.fallbackModel = src.fallbackModel;
|
|
1822
1891
|
if (src.enableFileCheckpointing !== void 0)
|
|
1823
1892
|
opts.enableFileCheckpointing = src.enableFileCheckpointing;
|
|
1893
|
+
if (src.toolConfig !== void 0) opts.toolConfig = src.toolConfig;
|
|
1824
1894
|
if (src.includePartialMessages !== void 0)
|
|
1825
1895
|
opts.includePartialMessages = src.includePartialMessages;
|
|
1826
1896
|
if (src.promptSuggestions !== void 0) opts.promptSuggestions = src.promptSuggestions;
|
|
1897
|
+
if (src.agentProgressSummaries !== void 0)
|
|
1898
|
+
opts.agentProgressSummaries = src.agentProgressSummaries;
|
|
1827
1899
|
if (src.strictMcpConfig !== void 0) opts.strictMcpConfig = src.strictMcpConfig;
|
|
1900
|
+
if (src.settings !== void 0) opts.settings = src.settings;
|
|
1828
1901
|
if (src.settingSources !== void 0) opts.settingSources = src.settingSources;
|
|
1829
1902
|
else opts.settingSources = DEFAULT_SETTING_SOURCES;
|
|
1830
1903
|
if (src.debug !== void 0) opts.debug = src.debug;
|
|
@@ -1861,9 +1934,12 @@ function toSessionCreateParams(input) {
|
|
|
1861
1934
|
sandbox: src.sandbox,
|
|
1862
1935
|
fallbackModel: src.fallbackModel,
|
|
1863
1936
|
enableFileCheckpointing: src.enableFileCheckpointing,
|
|
1937
|
+
toolConfig: src.toolConfig,
|
|
1864
1938
|
includePartialMessages: src.includePartialMessages,
|
|
1865
1939
|
promptSuggestions: src.promptSuggestions,
|
|
1940
|
+
agentProgressSummaries: src.agentProgressSummaries,
|
|
1866
1941
|
strictMcpConfig: src.strictMcpConfig,
|
|
1942
|
+
settings: src.settings,
|
|
1867
1943
|
settingSources: src.settingSources ?? DEFAULT_SETTING_SOURCES,
|
|
1868
1944
|
debug: src.debug,
|
|
1869
1945
|
debugFile: src.debugFile,
|
|
@@ -2512,11 +2588,15 @@ function toPermissionResult(params) {
|
|
|
2512
2588
|
interrupt: params.interrupt
|
|
2513
2589
|
};
|
|
2514
2590
|
}
|
|
2515
|
-
function appendAllowForSessionUpdate(updates, toolName) {
|
|
2591
|
+
function appendAllowForSessionUpdate(updates, suggestions, toolName) {
|
|
2592
|
+
const merged = [...updates ?? []];
|
|
2593
|
+
if (Array.isArray(suggestions) && suggestions.length > 0) {
|
|
2594
|
+
return [...merged, ...suggestions];
|
|
2595
|
+
}
|
|
2516
2596
|
const normalizedToolName = toolName?.trim();
|
|
2517
|
-
if (!normalizedToolName) return
|
|
2597
|
+
if (!normalizedToolName) return merged.length > 0 ? merged : void 0;
|
|
2518
2598
|
return [
|
|
2519
|
-
...
|
|
2599
|
+
...merged,
|
|
2520
2600
|
{
|
|
2521
2601
|
type: "addRules",
|
|
2522
2602
|
behavior: "allow",
|
|
@@ -2754,7 +2834,7 @@ function buildResult(sessionManager, toolCache, input) {
|
|
|
2754
2834
|
if (e.type !== "progress") return true;
|
|
2755
2835
|
const d = e.data;
|
|
2756
2836
|
const progressType = d?.type;
|
|
2757
|
-
return progressType !== "tool_progress" && progressType !== "auth_status" && progressType !== "task_progress" && progressType !== "hook_progress";
|
|
2837
|
+
return progressType !== "tool_progress" && progressType !== "auth_status" && progressType !== "api_retry" && progressType !== "task_progress" && progressType !== "hook_progress";
|
|
2758
2838
|
});
|
|
2759
2839
|
}
|
|
2760
2840
|
return filtered;
|
|
@@ -2804,6 +2884,8 @@ function buildResult(sessionManager, toolCache, input) {
|
|
|
2804
2884
|
toolName: req.toolName,
|
|
2805
2885
|
input: req.input,
|
|
2806
2886
|
summary: req.summary,
|
|
2887
|
+
title: req.title,
|
|
2888
|
+
displayName: req.displayName,
|
|
2807
2889
|
decisionReason: req.decisionReason,
|
|
2808
2890
|
blockedPath: req.blockedPath,
|
|
2809
2891
|
toolUseID: req.toolUseID,
|
|
@@ -2897,6 +2979,7 @@ function executeClaudeCodeCheck(input, sessionManager, toolCache, requestSignal)
|
|
|
2897
2979
|
const pendingRequest = input.decision === "allow_for_session" ? sessionManager.getPendingPermission(input.sessionId, input.requestId) : void 0;
|
|
2898
2980
|
const updatedPermissions = input.decision === "allow_for_session" ? appendAllowForSessionUpdate(
|
|
2899
2981
|
input.permissionOptions?.updatedPermissions,
|
|
2982
|
+
pendingRequest?.suggestions,
|
|
2900
2983
|
pendingRequest?.toolName
|
|
2901
2984
|
) : input.permissionOptions?.updatedPermissions;
|
|
2902
2985
|
const ok = sessionManager.finishRequest(
|
|
@@ -2929,6 +3012,7 @@ var ALWAYS_REDACTED_FIELDS = [
|
|
|
2929
3012
|
"env",
|
|
2930
3013
|
"mcpServers",
|
|
2931
3014
|
"sandbox",
|
|
3015
|
+
"settings",
|
|
2932
3016
|
"debugFile",
|
|
2933
3017
|
"pathToClaudeCodeExecutable"
|
|
2934
3018
|
];
|
|
@@ -2936,7 +3020,8 @@ var CONDITIONAL_REDACTED_FIELDS = [
|
|
|
2936
3020
|
"cwd",
|
|
2937
3021
|
"systemPrompt",
|
|
2938
3022
|
"agents",
|
|
2939
|
-
"additionalDirectories"
|
|
3023
|
+
"additionalDirectories",
|
|
3024
|
+
"toolConfig"
|
|
2940
3025
|
];
|
|
2941
3026
|
function buildRedactions(includeSensitive) {
|
|
2942
3027
|
const redactions = [];
|
|
@@ -3121,6 +3206,7 @@ function buildSessionRedactions(includeSensitive) {
|
|
|
3121
3206
|
{ field: "env", reason: "secret_or_internal" },
|
|
3122
3207
|
{ field: "mcpServers", reason: "secret_or_internal" },
|
|
3123
3208
|
{ field: "sandbox", reason: "secret_or_internal" },
|
|
3209
|
+
{ field: "settings", reason: "secret_or_internal" },
|
|
3124
3210
|
{ field: "debugFile", reason: "secret_or_internal" },
|
|
3125
3211
|
{ field: "pathToClaudeCodeExecutable", reason: "secret_or_internal" }
|
|
3126
3212
|
];
|
|
@@ -3129,7 +3215,8 @@ function buildSessionRedactions(includeSensitive) {
|
|
|
3129
3215
|
{ field: "cwd", reason: "sensitive_by_default" },
|
|
3130
3216
|
{ field: "systemPrompt", reason: "sensitive_by_default" },
|
|
3131
3217
|
{ field: "agents", reason: "sensitive_by_default" },
|
|
3132
|
-
{ field: "additionalDirectories", reason: "sensitive_by_default" }
|
|
3218
|
+
{ field: "additionalDirectories", reason: "sensitive_by_default" },
|
|
3219
|
+
{ field: "toolConfig", reason: "sensitive_by_default" }
|
|
3133
3220
|
);
|
|
3134
3221
|
}
|
|
3135
3222
|
return redactions;
|
|
@@ -3353,6 +3440,7 @@ function registerResources(server, deps) {
|
|
|
3353
3440
|
"Notes:",
|
|
3354
3441
|
"- `respond_user_input` is not supported on this backend.",
|
|
3355
3442
|
"- `allowedTools` is pre-approval by default; set `strictAllowedTools=true` for strict allowlist behavior.",
|
|
3443
|
+
"- OpenCode/Codex-style clients usually work best when they store `sessionId` + `nextCursor` and answer approvals with `decision=allow_for_session`.",
|
|
3356
3444
|
"- Prefer `responseMode='delta_compact'` for high-frequency polling."
|
|
3357
3445
|
].join("\n"),
|
|
3358
3446
|
"text/markdown"
|
|
@@ -3695,7 +3783,7 @@ function registerResources(server, deps) {
|
|
|
3695
3783
|
}
|
|
3696
3784
|
|
|
3697
3785
|
// src/server.ts
|
|
3698
|
-
var SERVER_VERSION = true ? "2.
|
|
3786
|
+
var SERVER_VERSION = true ? "2.8.0" : "0.0.0-dev";
|
|
3699
3787
|
function createServerContext(serverCwd) {
|
|
3700
3788
|
const sessionManager = new SessionManager();
|
|
3701
3789
|
const server = new McpServer(
|
|
@@ -3735,7 +3823,7 @@ function createServerContext(serverCwd) {
|
|
|
3735
3823
|
prompt: z.string(),
|
|
3736
3824
|
tools: z.array(z.string()).optional().describe("Default: inherit"),
|
|
3737
3825
|
disallowedTools: z.array(z.string()).optional().describe("Default: none"),
|
|
3738
|
-
model: z.
|
|
3826
|
+
model: z.string().optional().describe("Default: inherit"),
|
|
3739
3827
|
maxTurns: z.number().int().positive().optional().describe("Default: none"),
|
|
3740
3828
|
mcpServers: z.array(z.union([z.string(), z.record(z.string(), z.unknown())])).optional().describe("Default: inherit"),
|
|
3741
3829
|
skills: z.array(z.string()).optional().describe("Default: none"),
|
|
@@ -3784,9 +3872,12 @@ function createServerContext(serverCwd) {
|
|
|
3784
3872
|
sandbox: z.record(z.string(), z.unknown()).optional().describe("Default: none"),
|
|
3785
3873
|
fallbackModel: z.string().optional().describe("Default: none"),
|
|
3786
3874
|
enableFileCheckpointing: z.boolean().optional().describe("Default: false"),
|
|
3875
|
+
toolConfig: z.record(z.string(), z.unknown()).optional().describe("Default: none"),
|
|
3787
3876
|
includePartialMessages: z.boolean().optional().describe("Default: false"),
|
|
3788
3877
|
promptSuggestions: z.boolean().optional().describe("Default: false"),
|
|
3878
|
+
agentProgressSummaries: z.boolean().optional().describe("Default: false"),
|
|
3789
3879
|
strictMcpConfig: z.boolean().optional().describe("Default: false"),
|
|
3880
|
+
settings: z.union([z.string(), z.record(z.string(), z.unknown())]).optional().describe("Default: none"),
|
|
3790
3881
|
settingSources: z.array(z.enum(["user", "project", "local"])).optional().describe("Default: ['user','project','local']. []=isolation"),
|
|
3791
3882
|
debug: z.boolean().optional().describe("Default: false"),
|
|
3792
3883
|
debugFile: z.string().optional().describe("Default: none"),
|