@leo000001/claude-code-mcp 2.0.3 → 2.2.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 +53 -3
- package/CONTRIBUTING.md +10 -1
- package/NOTICE.md +27 -0
- package/README.md +68 -17
- package/SECURITY.md +4 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1204 -376
- package/dist/index.js.map +1 -1
- package/package.json +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
- Add `CLAUDE_CODE_MCP_MAX_SESSIONS` (default: `128`) to cap in-memory session count and reduce risk of memory exhaustion.
|
|
8
|
+
- Add `CLAUDE_CODE_MCP_MAX_PENDING_PERMISSIONS` (default: `64`) to cap outstanding permission requests per session.
|
|
9
|
+
- Promote `effort` and `thinking` to top-level parameters on `claude_code` and `claude_code_reply` (deprecated aliases: `advanced.effort`, `advanced.thinking`).
|
|
10
|
+
- Tool responses now include `structuredContent` (in addition to JSON text) for easier MCP client consumption.
|
|
11
|
+
- Emit `tools/list_changed` and `resources/list_changed` once after connect; update `claude_code` tool description dynamically when runtime tool discovery changes.
|
|
12
|
+
- Align declared MCP capabilities with implemented primitives (`logging`, `tools`, `resources`) and remove prompt primitive exposure.
|
|
13
|
+
- Add unit tests for `build-options.ts` and `race-with-abort.ts`.
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- Fork resume: restore original session state before creating the forked session record to avoid a brief `AbortController` sharing window.
|
|
18
|
+
- Session totals: prevent `totalTurns`/`totalCostUsd` from being overwritten when SDK-provided session totals look incremental.
|
|
19
|
+
- Permission audit: include allow-side `updatedInput`/`updatedPermissions` in `permission_result` events.
|
|
20
|
+
|
|
21
|
+
### Refactors
|
|
22
|
+
|
|
23
|
+
- Extract shared Zod schema fields for `advanced` and `diskResumeConfig` in `src/server.ts`.
|
|
24
|
+
- Deduplicate `SessionManager.create()` call payloads via a shared helper.
|
|
25
|
+
- Remove `server.close` monkey-patch; perform `sessionManager.destroy()` in the shutdown flow.
|
|
26
|
+
|
|
27
|
+
### Documentation
|
|
28
|
+
|
|
29
|
+
- Changelog: move released 2.x items out of `Unreleased` and add missing 2.0.0–2.0.3 entries.
|
|
30
|
+
- SECURITY: update supported versions table for 2.x.
|
|
31
|
+
- Docs: clarify same-platform assumption (MCP server and client run on the same machine) across README, AGENTS, SECURITY, and mcp_demo.
|
|
32
|
+
|
|
33
|
+
## 2.0.3 (2026-02-15)
|
|
34
|
+
|
|
35
|
+
### Improvements
|
|
36
|
+
|
|
37
|
+
- Version bump only.
|
|
38
|
+
|
|
39
|
+
## 2.0.2 (2026-02-15)
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
- MCP resources: `server-info`, `internal-tools`, and `gotchas`
|
|
44
|
+
- Permission workflow: include timeout/expiration metadata in permission actions; support `updatedInput` normalization
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
- Windows: normalize MSYS-style paths for `NotebookEdit` where possible
|
|
49
|
+
|
|
50
|
+
## 2.0.1 (2026-02-15)
|
|
51
|
+
|
|
52
|
+
### Improvements
|
|
53
|
+
|
|
54
|
+
- Refined server schema descriptions/default annotations to reduce token overhead for calling models
|
|
55
|
+
|
|
56
|
+
## 2.0.0 (2026-02-15)
|
|
57
|
+
|
|
5
58
|
### Breaking Changes
|
|
6
59
|
|
|
7
60
|
- `claude_code` and `claude_code_reply` now start asynchronously and return `{ sessionId, status: "running", pollInterval }`. Use `claude_code_check` to poll events and fetch the final `result`.
|
|
@@ -11,7 +64,6 @@
|
|
|
11
64
|
- `claude_code`: 22 low-frequency params moved into `advanced` object (e.g. `effort` → `advanced.effort`, `tools` → `advanced.tools`, `agents` → `advanced.agents`, `env` → `advanced.env`)
|
|
12
65
|
- `claude_code_reply`: 28 disk-resume params moved into `diskResumeConfig` object (e.g. `resumeToken` → `diskResumeConfig.resumeToken`, `cwd` → `diskResumeConfig.cwd`)
|
|
13
66
|
- `claude_code_check`: 9 poll control params moved into `pollOptions` object (e.g. `includeTools` → `pollOptions.includeTools`); 2 permission response params moved into `permissionOptions` object (e.g. `updatedInput` → `permissionOptions.updatedInput`)
|
|
14
|
-
- Schema descriptions for nested object fields have been compacted (self-explanatory fields no longer carry `.describe()` text; object-level descriptions enhanced as summaries) to reduce token overhead for calling models
|
|
15
67
|
|
|
16
68
|
### Features
|
|
17
69
|
|
|
@@ -28,10 +80,8 @@
|
|
|
28
80
|
- `claude_code_check`: minimal mode filters out noisy progress events (`tool_progress`, `auth_status`); use `includeProgressEvents: true` to restore
|
|
29
81
|
- `claude_code_check`: minimal mode omits `lastEventId`/`lastToolUseId` from top-level response and `durationApiMs`/`sessionTotalTurns`/`sessionTotalCostUsd` from AgentResult
|
|
30
82
|
- `claude_code_check`: includes lightweight session diagnostics (`cancelledAt`/`cancelledReason`/`cancelledSource`, `lastEventId`, `lastToolUseId`)
|
|
31
|
-
- `claude_code_check`: permission actions now include `timeoutMs`, `expiresAt`, and best-effort `remainingMs`
|
|
32
83
|
- Permission result events now include `toolName`, and denial details (`message`, `interrupt`) when applicable
|
|
33
84
|
- Disk resume security: disk resume fallback requires `CLAUDE_CODE_MCP_RESUME_SECRET` + `resumeToken`
|
|
34
|
-
- MCP resources: server info, internal tool catalog, and gotchas
|
|
35
85
|
|
|
36
86
|
## 1.6.0 (2026-02-12)
|
|
37
87
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -35,7 +35,7 @@ npm install
|
|
|
35
35
|
|
|
36
36
|
- Keep PRs focused on a single change
|
|
37
37
|
- Include tests for new functionality
|
|
38
|
-
- Update documentation (README, DESIGN.md) if the public API changes
|
|
38
|
+
- Update documentation (README, docs/DESIGN.md) if the public API changes
|
|
39
39
|
- Ensure CI passes before requesting review
|
|
40
40
|
|
|
41
41
|
## Reporting Issues
|
|
@@ -43,3 +43,12 @@ npm install
|
|
|
43
43
|
- Use GitHub Issues for bug reports and feature requests
|
|
44
44
|
- Include reproduction steps for bugs
|
|
45
45
|
- For security vulnerabilities, see [SECURITY.md](SECURITY.md)
|
|
46
|
+
|
|
47
|
+
## Release Checklist
|
|
48
|
+
|
|
49
|
+
1. Update `CHANGELOG.md` with the upcoming version and confirm `package.json` reflects that version.
|
|
50
|
+
2. Run `npm run format:check`, `npm run lint`, `npm run typecheck` (now covers `src` + `tests`), and `npm test` to prove the working tree is clean.
|
|
51
|
+
3. Build the bundle (`npm run build`) and verify `dist/` contains the expected entry points.
|
|
52
|
+
4. Refresh any documentation (README/CONTRIBUTING/docs) that describe public behavior or APIs touched by the release.
|
|
53
|
+
5. Ensure `NOTICE.md` lists the third-party components bundled in the release and contains links or pointers to their licenses.
|
|
54
|
+
6. Double-check `files`, `bin`, and other package metadata so the published package only ships the intended assets.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# NOTICE
|
|
2
|
+
|
|
3
|
+
This project (`@leo000001/claude-code-mcp`) is licensed under the MIT License (see `LICENSE`).
|
|
4
|
+
|
|
5
|
+
## Third-party components
|
|
6
|
+
|
|
7
|
+
This project depends on third-party packages. Their licenses and terms may impose additional
|
|
8
|
+
requirements on redistribution and use.
|
|
9
|
+
|
|
10
|
+
### Direct dependencies (from `package.json`)
|
|
11
|
+
|
|
12
|
+
- `@anthropic-ai/claude-agent-sdk@0.2.38` — 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
|
+
- `@modelcontextprotocol/sdk@1.26.0` — MIT License
|
|
14
|
+
- `zod@4.3.6` — MIT License
|
|
15
|
+
|
|
16
|
+
For a complete dependency graph, see `package-lock.json`. When installed, each dependency’s
|
|
17
|
+
license information is included with the package itself (typically under its `LICENSE` file or
|
|
18
|
+
`package.json` fields).
|
|
19
|
+
|
|
20
|
+
### Optional native dependencies
|
|
21
|
+
|
|
22
|
+
Some optional dependencies pulled in by the Claude Agent SDK (or its transitive dependencies)
|
|
23
|
+
may include prebuilt native binaries with licenses such as LGPL. These packages are platform-
|
|
24
|
+
specific (e.g., `@img/sharp-*` and related `libvips` packages).
|
|
25
|
+
|
|
26
|
+
If you redistribute this project (or produce bundled artifacts), you are responsible for ensuring
|
|
27
|
+
you comply with any applicable third-party license obligations and include required notices.
|
package/README.md
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
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.
|
|
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.
|
|
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
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
13
|
- **4 tools** covering the full agent lifecycle: start, continue, check/poll, manage
|
|
14
|
+
- **Read-only MCP resources** for server info, internal tool catalog, and compatibility diagnostics
|
|
14
15
|
- **Session management** with resume and fork support
|
|
15
16
|
- **Local settings loaded by default** — automatically reads `~/.claude/settings.json`, `.claude/settings.json`, `.claude/settings.local.json`, and `CLAUDE.md` so the agent behaves like your local Claude Code CLI
|
|
16
17
|
- **Async permissions** — allow/deny lists + explicit approvals via `claude_code_check`
|
|
@@ -20,9 +21,12 @@ Inspired by the [Codex MCP](https://developers.openai.com/codex/guides/agents-sd
|
|
|
20
21
|
- **Auto-cleanup** — 30-minute idle timeout for expired sessions
|
|
21
22
|
- **Security** — callers control tool permissions via allow/deny lists + explicit permission decisions
|
|
22
23
|
|
|
24
|
+
See `CHANGELOG.md` for release history.
|
|
25
|
+
|
|
23
26
|
## Prerequisites
|
|
24
27
|
|
|
25
28
|
- **Node.js >= 18** is required.
|
|
29
|
+
- **Same-platform deployment** — this MCP server is designed to run on the same machine as the MCP client. It communicates via stdio (child process), reads local Claude configuration files from `~/.claude/`, and accesses the local file system directly. Remote deployment is not supported.
|
|
26
30
|
|
|
27
31
|
This MCP server uses the [`@anthropic-ai/claude-agent-sdk`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) package, which **bundles its own Claude Code CLI** (`cli.js`). It does not use the `claude` binary from your system PATH.
|
|
28
32
|
|
|
@@ -56,6 +60,14 @@ Add to your MCP client configuration (Claude Desktop, Cursor, etc.):
|
|
|
56
60
|
}
|
|
57
61
|
```
|
|
58
62
|
|
|
63
|
+
> Some clients cache tool definitions at connect-time. This server emits `notifications/tools/list_changed` after runtime tool discovery so clients can refresh the `claude_code` tool description.
|
|
64
|
+
|
|
65
|
+
### Anthropic Claude Code CLI (as an MCP client)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
claude mcp add --transport stdio claude-code -- npx -y @leo000001/claude-code-mcp
|
|
69
|
+
```
|
|
70
|
+
|
|
59
71
|
### OpenAI Codex CLI
|
|
60
72
|
|
|
61
73
|
```bash
|
|
@@ -96,26 +108,27 @@ Start a new Claude Code session. The agent autonomously performs coding tasks: r
|
|
|
96
108
|
| `disallowedTools` | string[] | No | Forbidden tool names. Default: `[]` (none). SDK behavior: disallowed tools are removed from the model's context. Takes precedence over `allowedTools` and will be denied even if later approved interactively |
|
|
97
109
|
| `maxTurns` | number | No | Maximum number of agent reasoning steps. Each step may involve one or more tool calls. Default: SDK/Claude Code default |
|
|
98
110
|
| `model` | string | No | Model to use (e.g. `"claude-sonnet-4-5-20250929"`). Default: SDK/Claude Code default |
|
|
111
|
+
| `effort` | string | No | Effort level: `"low"`, `"medium"`, `"high"`, `"max"`. Default: SDK/Claude Code default |
|
|
112
|
+
| `thinking` | object | No | Thinking mode: `{ type: "adaptive" }`, `{ type: "enabled", budgetTokens: N }`, or `{ type: "disabled" }`. Default: SDK/Claude Code default |
|
|
99
113
|
| `systemPrompt` | string \| object | No | Override the agent's system prompt. Default: SDK/Claude Code default. Pass a string for full replacement, or `{ type: "preset", preset: "claude_code", append?: "..." }` to extend the default prompt |
|
|
100
|
-
| `permissionRequestTimeoutMs` | number | No | Timeout in milliseconds waiting for permission decisions. Default: `60000`
|
|
114
|
+
| `permissionRequestTimeoutMs` | number | No | Timeout in milliseconds waiting for permission decisions, auto-deny on expiry. Default: `60000` (server-clamped to 5min) |
|
|
115
|
+
| `sessionInitTimeoutMs` | number | No | **Compatibility alias** for `advanced.sessionInitTimeoutMs` (deprecated for `claude_code`). Default: `10000`. If both are provided, `advanced.sessionInitTimeoutMs` wins |
|
|
101
116
|
| `advanced` | object | No | Advanced/low-frequency parameters (see below) |
|
|
102
117
|
|
|
103
118
|
<details>
|
|
104
|
-
<summary><code>advanced</code> object parameters (
|
|
119
|
+
<summary><code>advanced</code> object parameters (20 low-frequency parameters)</summary>
|
|
105
120
|
|
|
106
121
|
| Parameter | Type | Description |
|
|
107
122
|
| ------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
108
123
|
| `advanced.tools` | string[] \| object | Define the base tool set. Default: SDK/Claude Code default toolset. Array of tool name strings, or `{ type: "preset", preset: "claude_code" }` for the default toolset. `allowedTools`/`disallowedTools` further filter on top of this |
|
|
109
124
|
| `advanced.persistSession` | boolean | Persist session history to disk (`~/.claude/projects/`). Default: `true`. Set `false` to disable. |
|
|
110
|
-
| `advanced.sessionInitTimeoutMs` | number |
|
|
125
|
+
| `advanced.sessionInitTimeoutMs` | number | Session init timeout in milliseconds waiting for `system/init`. Default: `10000`. **Recommended location for `claude_code` callers.** |
|
|
111
126
|
| `advanced.agents` | object | Define custom sub-agents the main agent can delegate tasks to. Default: none. SDK default: if a sub-agent omits `tools`, it inherits all tools from the parent. |
|
|
112
127
|
| `advanced.agent` | string | Name of a custom agent (defined in `agents`) to use as the primary agent. Default: omitted |
|
|
113
128
|
| `advanced.maxBudgetUsd` | number | Maximum budget in USD. Default: SDK/Claude Code default |
|
|
114
|
-
| `advanced.effort` | string | Effort level: `"low"`, `"medium"`, `"high"`, `"max"`. Default: SDK/Claude Code default |
|
|
115
129
|
| `advanced.betas` | string[] | Beta features (e.g. `["context-1m-2025-08-07"]`). Default: none |
|
|
116
130
|
| `advanced.additionalDirectories` | string[] | Additional directories the agent can access beyond cwd. Default: none |
|
|
117
131
|
| `advanced.outputFormat` | object | Structured output: `{ type: "json_schema", schema: {...} }`. Default: omitted (plain text) |
|
|
118
|
-
| `advanced.thinking` | object | Thinking mode: `{ type: "adaptive" }`, `{ type: "enabled", budgetTokens: N }`, or `{ type: "disabled" }`. Default: SDK/Claude Code default |
|
|
119
132
|
| `advanced.pathToClaudeCodeExecutable` | string | Path to the Claude Code executable. Default: SDK-bundled Claude Code (cli.js) |
|
|
120
133
|
| `advanced.mcpServers` | object | MCP server configurations (key: server name, value: server config). Default: none |
|
|
121
134
|
| `advanced.sandbox` | object | Sandbox configuration for isolating shell command execution (e.g., Docker container settings). Default: SDK/Claude Code default |
|
|
@@ -128,6 +141,8 @@ Start a new Claude Code session. The agent autonomously performs coding tasks: r
|
|
|
128
141
|
| `advanced.debugFile` | string | Write debug logs to a specific file path (implicitly enables debug mode). Default: omitted |
|
|
129
142
|
| `advanced.env` | object | Environment variables to merge with process.env and pass to the Claude Code process (user values take precedence). Default: inherit process.env |
|
|
130
143
|
|
|
144
|
+
Deprecated aliases: `advanced.effort` and `advanced.thinking` are still accepted for compatibility, but prefer top-level `effort` / `thinking` (top-level wins if both are set).
|
|
145
|
+
|
|
131
146
|
</details>
|
|
132
147
|
|
|
133
148
|
**Returns:** `{ sessionId, status: "running", pollInterval, resumeToken? }`
|
|
@@ -136,6 +151,7 @@ Notes:
|
|
|
136
151
|
|
|
137
152
|
- `resumeToken` is omitted by default, and is only returned when `CLAUDE_CODE_MCP_RESUME_SECRET` is set on the server.
|
|
138
153
|
- On error: `{ sessionId: "", status: "error", error }`
|
|
154
|
+
- If `sessionInitTimeoutMs` (top-level alias) is used, `claude_code` may return `compatWarnings` to guide migration to `advanced.sessionInitTimeoutMs`.
|
|
139
155
|
|
|
140
156
|
Use `claude_code_check` to poll events and obtain the final `result`.
|
|
141
157
|
|
|
@@ -156,8 +172,10 @@ Continue an existing session by sending a follow-up message. The agent retains f
|
|
|
156
172
|
| `sessionId` | string | Yes | Session ID from a previous `claude_code` call |
|
|
157
173
|
| `prompt` | string | Yes | Follow-up prompt |
|
|
158
174
|
| `forkSession` | boolean | No | Create a branched copy of this session. Default: `false` |
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
175
|
+
| `effort` | string | No | Effort level override for this run (and for future replies when not forking). Default: SDK/Claude Code default |
|
|
176
|
+
| `thinking` | object | No | Thinking mode override for this run (and for future replies when not forking). Default: SDK/Claude Code default |
|
|
177
|
+
| `permissionRequestTimeoutMs` | number | No | Timeout in milliseconds waiting for permission decisions, auto-deny on expiry. Default: `60000` |
|
|
178
|
+
| `sessionInitTimeoutMs` | number | No | Fork init timeout in milliseconds (only when `forkSession=true`). Default: `10000` |
|
|
161
179
|
| `diskResumeConfig` | object | No | Disk resume parameters (see below). Used when `CLAUDE_CODE_MCP_ALLOW_DISK_RESUME=1` and in-memory session is missing |
|
|
162
180
|
|
|
163
181
|
<details>
|
|
@@ -211,7 +229,8 @@ Gotchas:
|
|
|
211
229
|
- Permission approvals have a timeout (default 60s via `permissionRequestTimeoutMs`) and will auto-deny; watch `actions[].expiresAt` / `actions[].remainingMs`.
|
|
212
230
|
- `Read` has a per-call size cap in practice (often ~256KB); for large files use `offset`/`limit` or chunk with `Grep`.
|
|
213
231
|
- `Edit` with `replace_all=true` is substring replacement; if no match is found the tool returns a clear error.
|
|
214
|
-
-
|
|
232
|
+
- On Windows, this server normalizes common MSYS-style paths (e.g. `/d/...`, `/mnt/c/...`, `/cygdrive/c/...`, `//server/share/...`) for `cwd`, `additionalDirectories`, and tool inputs that include `file_path`.
|
|
233
|
+
- On Windows, POSIX home paths like `/home/user/...` are **not** rewritten to drive paths; prefer absolute Windows paths under your current `cwd` to avoid out-of-bounds permission prompts.
|
|
215
234
|
- `TeamDelete` may require members to reach `shutdown_approved` (otherwise you may see "active member" errors); cleanup can be asynchronous during shutdown.
|
|
216
235
|
- Skills may become available later in the same session (early calls may show "Unknown", later succeed after skills are loaded/registered).
|
|
217
236
|
- Some internal features (e.g. ToolSearch) may not appear in `availableTools` (derived from SDK `system/init.tools`).
|
|
@@ -220,9 +239,10 @@ Gotchas:
|
|
|
220
239
|
|
|
221
240
|
If your MCP client supports resources, this server exposes a couple of **read-only** MCP resources:
|
|
222
241
|
|
|
223
|
-
- `claude-code-mcp:///server-info` (JSON):
|
|
224
|
-
- `claude-code-mcp:///internal-tools` (JSON): internal tool catalog (
|
|
242
|
+
- `claude-code-mcp:///server-info` (JSON): server metadata (version/platform/runtime)
|
|
243
|
+
- `claude-code-mcp:///internal-tools` (JSON): internal tool catalog (runtime-aware)
|
|
225
244
|
- `claude-code-mcp:///gotchas` (Markdown): practical limits/gotchas
|
|
245
|
+
- `claude-code-mcp:///compat-report` (JSON): compatibility report (transport/platform assumptions, runtime warnings, guidance)
|
|
226
246
|
|
|
227
247
|
**Disk resume (optional):** By default, `claude_code_reply` requires the session to exist in the MCP server's in-memory Session Manager. If you set `CLAUDE_CODE_MCP_ALLOW_DISK_RESUME=1`, it can attempt to resume using the Claude Code CLI's on-disk transcript even when the in-memory session is missing (e.g. after a restart / TTL cleanup). For safety, disk resume fallback requires `CLAUDE_CODE_MCP_RESUME_SECRET` to be set on the server and requires callers to pass `diskResumeConfig.resumeToken` (returned by `claude_code` / `claude_code_reply` when `CLAUDE_CODE_MCP_RESUME_SECRET` is set).
|
|
228
248
|
|
|
@@ -257,7 +277,7 @@ Poll session events/results and approve/deny pending permission requests.
|
|
|
257
277
|
| `permissionOptions` | object | No | Advanced permission response options (see below) |
|
|
258
278
|
|
|
259
279
|
<details>
|
|
260
|
-
<summary><code>pollOptions</code> object parameters (
|
|
280
|
+
<summary><code>pollOptions</code> object parameters (10 fine-grained poll controls)</summary>
|
|
261
281
|
|
|
262
282
|
| Parameter | Type | Description |
|
|
263
283
|
| ------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -270,6 +290,7 @@ Poll session events/results and approve/deny pending permission requests.
|
|
|
270
290
|
| `pollOptions.includeStructuredOutput` | boolean | Include `result.structuredOutput` (default: true in full mode, false in minimal mode) |
|
|
271
291
|
| `pollOptions.includeTerminalEvents` | boolean | When true, keeps terminal `result`/`error` events in `events` even if top-level `result` is included. Default: `false` in `"minimal"`, `true` in `"full"` |
|
|
272
292
|
| `pollOptions.includeProgressEvents` | boolean | When true, includes progress events (`tool_progress`, `auth_status`) in the events stream. Default: `false` in `"minimal"`, `true` in `"full"` |
|
|
293
|
+
| `pollOptions.maxBytes` | number | Approximate max JSON bytes for `events` in this response. When exceeded, events are truncated and `truncatedFields` includes `"events_bytes"`. Default: unlimited |
|
|
273
294
|
|
|
274
295
|
</details>
|
|
275
296
|
|
|
@@ -283,7 +304,7 @@ Poll session events/results and approve/deny pending permission requests.
|
|
|
283
304
|
|
|
284
305
|
</details>
|
|
285
306
|
|
|
286
|
-
**Returns (poll and respond_permission):** `{ sessionId, status, pollInterval?, cursorResetTo?, truncated?, truncatedFields?, events, nextCursor?, availableTools?, actions?, result?, cancelledAt?, cancelledReason?, cancelledSource?, lastEventId?, lastToolUseId? }`
|
|
307
|
+
**Returns (poll and respond_permission):** `{ sessionId, status, pollInterval?, cursorResetTo?, truncated?, truncatedFields?, events, nextCursor?, availableTools?, toolValidation?, compatWarnings?, actions?, result?, cancelledAt?, cancelledReason?, cancelledSource?, lastEventId?, lastToolUseId? }`
|
|
287
308
|
|
|
288
309
|
Notes:
|
|
289
310
|
|
|
@@ -292,6 +313,9 @@ Notes:
|
|
|
292
313
|
- If `cursorResetTo` is present, your `cursor` was too old (events were evicted); reset your cursor to `cursorResetTo`.
|
|
293
314
|
- For safety, de-duplicate events by `event.id` on the client side.
|
|
294
315
|
- If `truncated=true`, the server intentionally limited the payload (e.g. `maxEvents`) — continue polling with `nextCursor`.
|
|
316
|
+
- `nextCursor` can remain unchanged with `events=[]` during quiet intervals; this is normal transient behavior. Retry a few times (for example up to 3) before treating it as abnormal.
|
|
317
|
+
- `toolValidation` reports whether configured `allowedTools`/`disallowedTools` match runtime-discovered tool names.
|
|
318
|
+
- `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.
|
|
295
319
|
- Permission `actions[]` include `timeoutMs`, `expiresAt`, and best-effort `remainingMs` to help callers avoid auto-deny timeouts.
|
|
296
320
|
- `permission_result` event data is `{ requestId, toolName, behavior, source, message?, interrupt? }` (denial details only present for `deny`).
|
|
297
321
|
- In `"minimal"` mode (default): assistant message events are slimmed (strips `usage`, `model`, `id`, `cache_control` from content blocks); noisy progress events (`tool_progress`, `auth_status`) are filtered out; `lastEventId`/`lastToolUseId` are omitted; `AgentResult` omits `durationApiMs`/`sessionTotalTurns`/`sessionTotalCostUsd`. Use `responseMode: "full"` or individual `include*` flags to restore any of these.
|
|
@@ -304,13 +328,13 @@ start = await mcp.call_tool("claude_code", {
|
|
|
304
328
|
"prompt": "Fix the authentication bug in src/auth.ts",
|
|
305
329
|
"cwd": "/path/to/project",
|
|
306
330
|
"allowedTools": ["Read", "Edit", "Bash", "Glob", "Grep"],
|
|
331
|
+
"effort": "high",
|
|
307
332
|
"advanced": {
|
|
308
|
-
"effort": "high",
|
|
309
333
|
"maxBudgetUsd": 5.0
|
|
310
334
|
}
|
|
311
335
|
})
|
|
312
336
|
session_id = json.loads(start)["sessionId"]
|
|
313
|
-
cursor =
|
|
337
|
+
cursor = 0
|
|
314
338
|
|
|
315
339
|
# 2) Poll until idle/error/cancelled
|
|
316
340
|
while True:
|
|
@@ -354,7 +378,7 @@ Claude Code on Windows requires git-bash (https://git-scm.com/downloads/win).
|
|
|
354
378
|
|
|
355
379
|
This means the spawned CLI process cannot locate `bash.exe`. Your locally installed `claude` command may work fine — the issue is that the MCP server's child process may not inherit your shell environment.
|
|
356
380
|
|
|
357
|
-
|
|
381
|
+
`claude-code-mcp` will try to auto-detect Git Bash from common install locations and set `CLAUDE_CODE_GIT_BASH_PATH` for child processes. If you still see this error, set `CLAUDE_CODE_GIT_BASH_PATH` explicitly in your MCP server config:
|
|
358
382
|
|
|
359
383
|
For JSON-based MCP clients (Claude Desktop, Cursor, etc.):
|
|
360
384
|
|
|
@@ -407,6 +431,7 @@ setx CLAUDE_CODE_GIT_BASH_PATH "C:\Program Files\Git\bin\bash.exe"
|
|
|
407
431
|
- Use `disallowedTools` to hard-block tools; they are denied even if later approved via `claude_code_check`.
|
|
408
432
|
- `maxTurns` and `advanced.maxBudgetUsd` prevent runaway execution.
|
|
409
433
|
- Sessions auto-expire after 30 minutes of inactivity.
|
|
434
|
+
- Vulnerability reporting: see `SECURITY.md`.
|
|
410
435
|
|
|
411
436
|
## Environment Variables
|
|
412
437
|
|
|
@@ -417,6 +442,8 @@ All environment variables are optional. They are set on the MCP server process (
|
|
|
417
442
|
| `CLAUDE_CODE_GIT_BASH_PATH` | Path to `bash.exe` on Windows (see [Windows Support](#windows-support)) | Auto-detected |
|
|
418
443
|
| `CLAUDE_CODE_MCP_ALLOW_DISK_RESUME` | Set to `1` to allow `claude_code_reply` to resume from on-disk transcripts when the in-memory session is missing | `0` (disabled) |
|
|
419
444
|
| `CLAUDE_CODE_MCP_RESUME_SECRET` | HMAC secret used to validate `resumeToken` for disk resume fallback (recommended if disk resume is enabled) | _(unset)_ |
|
|
445
|
+
| `CLAUDE_CODE_MCP_MAX_SESSIONS` | Maximum number of in-memory sessions (set `0` to disable the limit) | `128` |
|
|
446
|
+
| `CLAUDE_CODE_MCP_MAX_PENDING_PERMISSIONS` | Maximum number of outstanding permission requests per session (set `0` to disable the limit) | `64` |
|
|
420
447
|
|
|
421
448
|
### How to configure
|
|
422
449
|
|
|
@@ -471,10 +498,32 @@ npm test # Run tests with vitest
|
|
|
471
498
|
npm run dev # Watch mode build
|
|
472
499
|
```
|
|
473
500
|
|
|
501
|
+
### E2E regression commands
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
# Run cancel->poll regression loop (single mode)
|
|
505
|
+
npm run e2e:stdio:cancel
|
|
506
|
+
|
|
507
|
+
# Run waiting_permission + cancel regression loop
|
|
508
|
+
npm run e2e:stdio:cancel:wp
|
|
509
|
+
|
|
510
|
+
# Run both modes and output one summary report
|
|
511
|
+
npm run e2e:stdio:runner
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### E2E notes (Codex and other clients)
|
|
515
|
+
|
|
516
|
+
- Some clients do not expose `tools/list` directly in the chat loop. In those clients, treat "tool is callable" as the primary discovery signal, and use `tools/list` only when available.
|
|
517
|
+
- `allowedTools: ["Read", "Write"]` does not guarantee the model will never attempt `Bash`. For deterministic smoke tests, add `disallowedTools: ["Bash"]` and state "do not use Bash" in the prompt.
|
|
518
|
+
- For `claude_code_session(action="get", includeSensitive=true)`, only assert fields that were actually configured. Optional fields that were never set may be omitted.
|
|
519
|
+
- If a client reports `Transport closed` during E2E cleanup, reconnect the MCP server first, then run `claude_code_session(action="list")` and cancel any remaining `running` / `waiting_permission` sessions.
|
|
520
|
+
|
|
521
|
+
For an end-to-end local test plan (third-party CLI/client integration + real coding tasks), see `docs/E2E_LOCAL_TEST_PLAN.md`.
|
|
522
|
+
|
|
474
523
|
## Architecture
|
|
475
524
|
|
|
476
525
|
```
|
|
477
|
-
MCP Client ←→ (stdio/JSON-RPC) ←→ MCP Server
|
|
526
|
+
MCP Client ←→ (stdio/JSON-RPC) ←→ MCP Server [same machine]
|
|
478
527
|
├── Session Manager (Map<id, state>)
|
|
479
528
|
└── Claude Agent SDK (query())
|
|
480
529
|
```
|
|
@@ -494,6 +543,7 @@ MCP server validation/policy errors are returned as `Error [CODE]: message` wher
|
|
|
494
543
|
- `SESSION_BUSY` — session currently running
|
|
495
544
|
- `PERMISSION_DENIED` — operation not allowed by server policy
|
|
496
545
|
- `PERMISSION_REQUEST_NOT_FOUND` — permission request ID not found (already finished or expired)
|
|
546
|
+
- `RESOURCE_EXHAUSTED` — resource limit reached (e.g. max sessions or max pending permissions)
|
|
497
547
|
- `TIMEOUT` — operation timed out
|
|
498
548
|
- `CANCELLED` — session was cancelled
|
|
499
549
|
- `INTERNAL` — unexpected error or protocol mismatch
|
|
@@ -510,3 +560,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
|
510
560
|
|
|
511
561
|
- [Security Policy](SECURITY.md)
|
|
512
562
|
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
563
|
+
- [Third-party Notices](NOTICE.md)
|
package/SECURITY.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
| Version | Supported |
|
|
6
6
|
| ------- | --------- |
|
|
7
|
-
|
|
|
7
|
+
| 2.x | Yes |
|
|
8
|
+
| 1.x | No |
|
|
8
9
|
|
|
9
10
|
## Reporting a Vulnerability
|
|
10
11
|
|
|
@@ -18,9 +19,11 @@ We aim to acknowledge reports within 48 hours and provide a fix or mitigation pl
|
|
|
18
19
|
|
|
19
20
|
## Security Considerations
|
|
20
21
|
|
|
22
|
+
- This MCP server is designed for local use only — the server and client must run on the same machine. It communicates via stdio (child process), reads local configuration from `~/.claude/`, and accesses the local file system directly. Remote deployment is not supported.
|
|
21
23
|
- This server uses an async permission flow: when a tool call needs approval, the session pauses (`waiting_permission`) and surfaces requests via `claude_code_check` (`actions[]`). Callers must explicitly approve/deny via `respond_permission`.
|
|
22
24
|
- The MCP server uses the Claude Agent SDK's bundled CLI (`cli.js`), not the system-installed `claude` binary
|
|
23
25
|
- Session metadata is held in-memory only and is not persisted to disk by the MCP server (the SDK's CLI persists conversation history separately)
|
|
26
|
+
- To reduce memory exhaustion risk, the server caps in-memory session count via `CLAUDE_CODE_MCP_MAX_SESSIONS` (default: `128`).
|
|
24
27
|
- Disk resume is disabled by default (`CLAUDE_CODE_MCP_ALLOW_DISK_RESUME=0`). If you set `CLAUDE_CODE_MCP_ALLOW_DISK_RESUME=1`, disk resume fallback also requires `CLAUDE_CODE_MCP_RESUME_SECRET` (default: unset) and a valid `resumeToken` from `claude_code`/`claude_code_reply`.
|
|
25
28
|
- `claude_code_session` redacts sensitive fields (cwd, systemPrompt, agents, additionalDirectories) by default; use `includeSensitive=true` to include them
|
|
26
29
|
- Sessions auto-expire after 30 minutes of inactivity
|
package/dist/index.d.ts
ADDED