@leo000001/claude-code-mcp 2.4.6 → 2.4.8

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 CHANGED
@@ -22,6 +22,8 @@
22
22
 
23
23
  ### Documentation
24
24
 
25
+ - Restructure documentation architecture: `AGENTS.md` is now execution-first, while `docs/DESIGN.md` is the single detailed source for interface/mapping semantics.
26
+ - Add explicit doc-governance rules, upgrade submission template, and document DoD to reduce AGENTS/DESIGN duplication regression.
25
27
  - Align README/DESIGN/AGENTS with current defaults and behavior (timeout clamp, advanced parameter count, lifecycle semantics).
26
28
  - Clarify package positioning as CLI-first and remove stale guidance that implied a public programmatic API surface.
27
29
  - Update CONTRIBUTING with local environment requirements (Node/npm and Windows Git Bash notes).
package/dist/index.js CHANGED
@@ -329,7 +329,9 @@ var SessionManager = class _SessionManager {
329
329
  if (info.status === "waiting_permission") {
330
330
  this.finishAllPending(
331
331
  sessionId,
332
- { behavior: "deny", message: opts?.reason ?? "Session interrupted", interrupt: true },
332
+ // Similar to cancel(), avoid emitting interrupt=true while the query stream is
333
+ // being torn down to reduce SDK-level write/teardown races on stdio clients.
334
+ { behavior: "deny", message: opts?.reason ?? "Session interrupted", interrupt: false },
333
335
  "interrupt"
334
336
  );
335
337
  }
@@ -2494,11 +2496,14 @@ function detectPathCompatibilityWarnings(session) {
2494
2496
  }
2495
2497
  return warnings;
2496
2498
  }
2497
- function isPosixHomePath(value) {
2498
- return /^\/home\/[^/\s]+(?:\/|$)/.test(value);
2499
+ function isSuspiciousPosixAbsolutePathOnWindows(value) {
2500
+ if (!value.startsWith("/") || value.startsWith("//")) return false;
2501
+ return /^\/home\/[^/\s]+(?:\/|$)/.test(value) || /^\/(?:mnt\/)?[a-zA-Z](?:\/|$)/.test(value) || /^\/(tmp|var|etc|opt|usr|bin|sbin)(?:\/|$)/.test(value);
2499
2502
  }
2500
- function extractPosixHomePath(value) {
2501
- const match = value.match(/\/home\/[^/\s"'`]+(?:\/[^\s"'`]*)?/);
2503
+ function extractSuspiciousPosixAbsolutePath(value) {
2504
+ const match = value.match(
2505
+ /\/(?:home\/[^/\s"'`]+(?:\/[^\s"'`]*)?|(?:mnt\/)?[a-zA-Z](?:\/[^\s"'`]*)?|(?:tmp|var|etc|opt|usr|bin|sbin)(?:\/[^\s"'`]*)?)/
2506
+ );
2502
2507
  return match?.[0];
2503
2508
  }
2504
2509
  function detectPendingPermissionPathWarnings(pending, session) {
@@ -2527,13 +2532,13 @@ function detectPendingPermissionPathWarnings(pending, session) {
2527
2532
  }
2528
2533
  const command = req.input.command;
2529
2534
  if (typeof command === "string") {
2530
- const embeddedPath = extractPosixHomePath(command);
2535
+ const embeddedPath = extractSuspiciousPosixAbsolutePath(command);
2531
2536
  if (embeddedPath) candidates.push(embeddedPath);
2532
2537
  }
2533
- const badPath = candidates.find((p) => isPosixHomePath(p));
2538
+ const badPath = candidates.find((p) => isSuspiciousPosixAbsolutePathOnWindows(p));
2534
2539
  if (!badPath) continue;
2535
2540
  warnings.push(
2536
- `Permission request '${req.requestId}' uses POSIX home path '${badPath}' on Windows. Prefer an absolute Windows path${cwdHint} to avoid out-of-bounds permission prompts.`
2541
+ `Permission request '${req.requestId}' uses POSIX absolute path '${badPath}' on Windows. Prefer an absolute Windows path${cwdHint} to avoid out-of-bounds permission prompts.`
2537
2542
  );
2538
2543
  }
2539
2544
  return warnings;
@@ -3590,7 +3595,7 @@ function registerResources(server, deps) {
3590
3595
  }
3591
3596
 
3592
3597
  // src/server.ts
3593
- var SERVER_VERSION = true ? "2.4.6" : "0.0.0-dev";
3598
+ var SERVER_VERSION = true ? "2.4.8" : "0.0.0-dev";
3594
3599
  function createServerContext(serverCwd) {
3595
3600
  const sessionManager = new SessionManager();
3596
3601
  const server = new McpServer(
@@ -4029,7 +4034,8 @@ var BENIGN_MESSAGE_PATTERNS = [
4029
4034
  "write after end",
4030
4035
  "stream was destroyed",
4031
4036
  "cannot call write after a stream was destroyed",
4032
- "the pipe is being closed"
4037
+ "the pipe is being closed",
4038
+ "query closed before response received"
4033
4039
  ];
4034
4040
  function isBenignRuntimeError(error) {
4035
4041
  if (!(error instanceof Error)) return false;
@@ -4041,6 +4047,15 @@ function isBenignRuntimeError(error) {
4041
4047
  return BENIGN_MESSAGE_PATTERNS.some((pattern) => message.includes(pattern));
4042
4048
  }
4043
4049
 
4050
+ // src/utils/stdin-shutdown.ts
4051
+ function decideStdinShutdown(params) {
4052
+ if (!params.stdinUnavailable) return "clear";
4053
+ if (params.isConnected) return "reschedule";
4054
+ if (!params.hasActiveSessions) return "shutdown_now";
4055
+ if (params.elapsedMs >= params.maxWaitMs) return "shutdown_timeout";
4056
+ return "reschedule";
4057
+ }
4058
+
4044
4059
  // src/index.ts
4045
4060
  var STDIN_SHUTDOWN_CHECK_MS = 750;
4046
4061
  var STDIN_SHUTDOWN_MAX_WAIT_MS = process.platform === "win32" ? 15e3 : 1e4;
@@ -4117,19 +4132,26 @@ async function main() {
4117
4132
  const evaluateStdinTermination = () => {
4118
4133
  if (closing || stdinClosedAt === void 0) return;
4119
4134
  const stdinUnavailable = process.stdin.destroyed || process.stdin.readableEnded || !process.stdin.readable;
4120
- if (!stdinUnavailable) {
4135
+ const elapsedMs = Date.now() - stdinClosedAt;
4136
+ const active = hasActiveSessions();
4137
+ const connected = server.isConnected();
4138
+ const decision = decideStdinShutdown({
4139
+ stdinUnavailable,
4140
+ elapsedMs,
4141
+ maxWaitMs: STDIN_SHUTDOWN_MAX_WAIT_MS,
4142
+ hasActiveSessions: active,
4143
+ isConnected: connected
4144
+ });
4145
+ if (decision === "clear") {
4121
4146
  stdinClosedAt = void 0;
4122
4147
  stdinClosedReason = void 0;
4123
4148
  return;
4124
4149
  }
4125
- const elapsedMs = Date.now() - stdinClosedAt;
4126
- const active = hasActiveSessions();
4127
- const connected = server.isConnected();
4128
- if (!active && !connected) {
4150
+ if (decision === "shutdown_now") {
4129
4151
  void shutdown(`stdin_${stdinClosedReason ?? "closed"}`);
4130
4152
  return;
4131
4153
  }
4132
- if (elapsedMs >= STDIN_SHUTDOWN_MAX_WAIT_MS) {
4154
+ if (decision === "shutdown_timeout") {
4133
4155
  void shutdown(`stdin_${stdinClosedReason ?? "closed"}_timeout`);
4134
4156
  return;
4135
4157
  }
@@ -4166,7 +4188,9 @@ async function main() {
4166
4188
  void shutdown("SIGHUP");
4167
4189
  });
4168
4190
  process.on("beforeExit", () => {
4169
- void shutdown("beforeExit");
4191
+ if (!server.isConnected()) {
4192
+ void shutdown("beforeExit");
4193
+ }
4170
4194
  });
4171
4195
  process.on("uncaughtException", handleUnexpectedError);
4172
4196
  process.on("unhandledRejection", handleUnexpectedError);