@leo000001/claude-code-mcp 2.4.8 → 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/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,
@@ -841,7 +848,15 @@ var SessionManager = class _SessionManager {
841
848
  if (typeof requestId !== "string") return true;
842
849
  return isActivePermissionRequest ? !isActivePermissionRequest(requestId) : true;
843
850
  };
851
+ const isNoisyProgressEvent = (event) => {
852
+ if (event.type !== "progress") return false;
853
+ const t = event.data?.type;
854
+ return t === "tool_progress" || t === "auth_status" || t === "api_retry" || t === "task_progress" || t === "hook_progress";
855
+ };
844
856
  let toDropForSoftLimit = remaining - buffer.maxSize;
857
+ if (toDropForSoftLimit > 0) {
858
+ toDropForSoftLimit -= dropOldestMatching(toDropForSoftLimit, isNoisyProgressEvent);
859
+ }
845
860
  if (toDropForSoftLimit > 0) {
846
861
  toDropForSoftLimit -= dropOldestMatching(toDropForSoftLimit, (event) => !event.pinned);
847
862
  }
@@ -903,7 +918,6 @@ import { existsSync as existsSync2, statSync } from "fs";
903
918
 
904
919
  // src/types.ts
905
920
  var EFFORT_LEVELS = ["low", "medium", "high", "max"];
906
- var AGENT_MODELS = ["sonnet", "opus", "haiku", "inherit"];
907
921
  var SESSION_ACTIONS = ["list", "get", "cancel", "interrupt"];
908
922
  var DEFAULT_SETTING_SOURCES = ["user", "project", "local"];
909
923
  var CHECK_ACTIONS = ["poll", "respond_permission"];
@@ -1153,6 +1167,7 @@ function sdkResultToAgentResult(result) {
1153
1167
  sessionTotalTurns: typeof sessionTotalTurns === "number" ? sessionTotalTurns : void 0,
1154
1168
  sessionTotalCostUsd: typeof sessionTotalCostUsd === "number" ? sessionTotalCostUsd : void 0,
1155
1169
  stopReason: result.stop_reason,
1170
+ fastModeState: result.fast_mode_state,
1156
1171
  usage: result.usage,
1157
1172
  modelUsage: result.modelUsage,
1158
1173
  permissionDenials: result.permission_denials
@@ -1196,9 +1211,28 @@ function messageToEvent(msg) {
1196
1211
  }
1197
1212
  };
1198
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
+ }
1199
1224
  if (msg.type === "tool_use_summary") {
1200
1225
  return { type: "progress", data: { type: "tool_use_summary", summary: msg.summary } };
1201
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
+ }
1202
1236
  if (msg.type === "tool_progress") {
1203
1237
  return {
1204
1238
  type: "progress",
@@ -1206,7 +1240,9 @@ function messageToEvent(msg) {
1206
1240
  type: "tool_progress",
1207
1241
  tool_use_id: msg.tool_use_id,
1208
1242
  tool_name: msg.tool_name,
1209
- elapsed_time_seconds: msg.elapsed_time_seconds
1243
+ parent_tool_use_id: msg.parent_tool_use_id,
1244
+ elapsed_time_seconds: msg.elapsed_time_seconds,
1245
+ task_id: msg.task_id
1210
1246
  }
1211
1247
  };
1212
1248
  }
@@ -1227,15 +1263,77 @@ function messageToEvent(msg) {
1227
1263
  data: { type: "status", status: msg.status, permissionMode: msg.permissionMode }
1228
1264
  };
1229
1265
  }
1230
- if (msg.type === "system" && msg.subtype === "task_notification") {
1266
+ if (msg.type === "system" && msg.subtype === "compact_boundary") {
1231
1267
  return {
1232
1268
  type: "progress",
1233
1269
  data: {
1234
- type: "task_notification",
1235
- task_id: msg.task_id,
1236
- status: msg.status,
1237
- summary: msg.summary,
1238
- output_file: msg.output_file
1270
+ type: "compact_boundary",
1271
+ compact_metadata: msg.compact_metadata
1272
+ }
1273
+ };
1274
+ }
1275
+ if (msg.type === "system" && msg.subtype === "hook_started") {
1276
+ return {
1277
+ type: "progress",
1278
+ data: {
1279
+ type: "hook_started",
1280
+ hook_id: msg.hook_id,
1281
+ hook_name: msg.hook_name,
1282
+ hook_event: msg.hook_event
1283
+ }
1284
+ };
1285
+ }
1286
+ if (msg.type === "system" && msg.subtype === "hook_progress") {
1287
+ return {
1288
+ type: "progress",
1289
+ data: {
1290
+ type: "hook_progress",
1291
+ hook_id: msg.hook_id,
1292
+ hook_name: msg.hook_name,
1293
+ hook_event: msg.hook_event,
1294
+ stdout: msg.stdout,
1295
+ stderr: msg.stderr,
1296
+ output: msg.output
1297
+ }
1298
+ };
1299
+ }
1300
+ if (msg.type === "system" && msg.subtype === "hook_response") {
1301
+ return {
1302
+ type: "progress",
1303
+ data: {
1304
+ type: "hook_response",
1305
+ hook_id: msg.hook_id,
1306
+ hook_name: msg.hook_name,
1307
+ hook_event: msg.hook_event,
1308
+ output: msg.output,
1309
+ stdout: msg.stdout,
1310
+ stderr: msg.stderr,
1311
+ exit_code: msg.exit_code,
1312
+ outcome: msg.outcome
1313
+ }
1314
+ };
1315
+ }
1316
+ if (msg.type === "system" && msg.subtype === "files_persisted") {
1317
+ return {
1318
+ type: "progress",
1319
+ data: {
1320
+ type: "files_persisted",
1321
+ files: msg.files,
1322
+ failed: msg.failed,
1323
+ processed_at: msg.processed_at
1324
+ }
1325
+ };
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
1239
1337
  }
1240
1338
  };
1241
1339
  }
@@ -1247,13 +1345,54 @@ function messageToEvent(msg) {
1247
1345
  task_id: msg.task_id,
1248
1346
  tool_use_id: msg.tool_use_id,
1249
1347
  description: msg.description,
1250
- task_type: msg.task_type
1348
+ task_type: msg.task_type,
1349
+ prompt: msg.prompt
1251
1350
  }
1252
1351
  };
1253
1352
  }
1254
- if (msg.type === "rate_limit" || msg.type === "prompt_suggestion") {
1353
+ if (msg.type === "system" && msg.subtype === "task_progress") {
1354
+ return {
1355
+ type: "progress",
1356
+ data: {
1357
+ type: "task_progress",
1358
+ task_id: msg.task_id,
1359
+ tool_use_id: msg.tool_use_id,
1360
+ description: msg.description,
1361
+ usage: msg.usage,
1362
+ last_tool_name: msg.last_tool_name,
1363
+ summary: msg.summary
1364
+ }
1365
+ };
1366
+ }
1367
+ if (msg.type === "system" && msg.subtype === "task_notification") {
1368
+ return {
1369
+ type: "progress",
1370
+ data: {
1371
+ type: "task_notification",
1372
+ task_id: msg.task_id,
1373
+ tool_use_id: msg.tool_use_id,
1374
+ status: msg.status,
1375
+ summary: msg.summary,
1376
+ output_file: msg.output_file,
1377
+ usage: msg.usage
1378
+ }
1379
+ };
1380
+ }
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") {
1255
1392
  const rest = { ...msg };
1256
1393
  delete rest.type;
1394
+ delete rest.uuid;
1395
+ delete rest.session_id;
1257
1396
  return {
1258
1397
  type: "progress",
1259
1398
  data: { type: msg.type, ...rest }
@@ -1337,8 +1476,10 @@ function consumeQuery(params) {
1337
1476
  requestId,
1338
1477
  toolName,
1339
1478
  input: normalizedInput,
1340
- summary: summarizePermission(toolName, normalizedInput),
1341
- description: describeTool(toolName, params.toolCache),
1479
+ summary: options2.title ?? summarizePermission(toolName, normalizedInput),
1480
+ title: options2.title,
1481
+ displayName: options2.displayName,
1482
+ description: options2.description ?? describeTool(toolName, params.toolCache),
1342
1483
  decisionReason: options2.decisionReason,
1343
1484
  blockedPath: options2.blockedPath,
1344
1485
  toolUseID: options2.toolUseID,
@@ -1406,7 +1547,11 @@ function consumeQuery(params) {
1406
1547
  }
1407
1548
  };
1408
1549
  const interrupt = () => {
1409
- activeQuery.interrupt?.();
1550
+ try {
1551
+ void Promise.resolve(activeQuery.interrupt?.()).catch(() => {
1552
+ });
1553
+ } catch {
1554
+ }
1410
1555
  };
1411
1556
  const done = (async () => {
1412
1557
  const preInit = [];
@@ -1431,6 +1576,11 @@ function consumeQuery(params) {
1431
1576
  params.toolCache?.updateFromInit(message.tools);
1432
1577
  params.onInit?.(message);
1433
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
+ });
1434
1584
  activeSessionId = message.session_id;
1435
1585
  if (!sessionIdResolved && shouldWaitForInit) {
1436
1586
  sessionIdResolved = true;
@@ -1497,6 +1647,7 @@ function consumeQuery(params) {
1497
1647
  status: agentResult.isError ? "error" : "idle",
1498
1648
  totalTurns: sessionTotalTurns,
1499
1649
  totalCostUsd: sessionTotalCostUsd,
1650
+ fastModeState: agentResult.fastModeState,
1500
1651
  abortController: void 0,
1501
1652
  queryInterrupt: void 0
1502
1653
  });
@@ -1504,6 +1655,7 @@ function consumeQuery(params) {
1504
1655
  params.sessionManager.update(sessionId2, {
1505
1656
  totalTurns: sessionTotalTurns,
1506
1657
  totalCostUsd: sessionTotalCostUsd,
1658
+ fastModeState: agentResult.fastModeState,
1507
1659
  abortController: void 0,
1508
1660
  queryInterrupt: void 0
1509
1661
  });
@@ -1738,10 +1890,14 @@ function buildOptions(src) {
1738
1890
  if (src.fallbackModel !== void 0) opts.fallbackModel = src.fallbackModel;
1739
1891
  if (src.enableFileCheckpointing !== void 0)
1740
1892
  opts.enableFileCheckpointing = src.enableFileCheckpointing;
1893
+ if (src.toolConfig !== void 0) opts.toolConfig = src.toolConfig;
1741
1894
  if (src.includePartialMessages !== void 0)
1742
1895
  opts.includePartialMessages = src.includePartialMessages;
1743
1896
  if (src.promptSuggestions !== void 0) opts.promptSuggestions = src.promptSuggestions;
1897
+ if (src.agentProgressSummaries !== void 0)
1898
+ opts.agentProgressSummaries = src.agentProgressSummaries;
1744
1899
  if (src.strictMcpConfig !== void 0) opts.strictMcpConfig = src.strictMcpConfig;
1900
+ if (src.settings !== void 0) opts.settings = src.settings;
1745
1901
  if (src.settingSources !== void 0) opts.settingSources = src.settingSources;
1746
1902
  else opts.settingSources = DEFAULT_SETTING_SOURCES;
1747
1903
  if (src.debug !== void 0) opts.debug = src.debug;
@@ -1778,9 +1934,12 @@ function toSessionCreateParams(input) {
1778
1934
  sandbox: src.sandbox,
1779
1935
  fallbackModel: src.fallbackModel,
1780
1936
  enableFileCheckpointing: src.enableFileCheckpointing,
1937
+ toolConfig: src.toolConfig,
1781
1938
  includePartialMessages: src.includePartialMessages,
1782
1939
  promptSuggestions: src.promptSuggestions,
1940
+ agentProgressSummaries: src.agentProgressSummaries,
1783
1941
  strictMcpConfig: src.strictMcpConfig,
1942
+ settings: src.settings,
1784
1943
  settingSources: src.settingSources ?? DEFAULT_SETTING_SOURCES,
1785
1944
  debug: src.debug,
1786
1945
  debugFile: src.debugFile,
@@ -2300,6 +2459,23 @@ var TOOL_CATALOG = {
2300
2459
  description: "Ask user a question",
2301
2460
  category: "interaction"
2302
2461
  },
2462
+ SubscribeMcpResource: {
2463
+ description: "Subscribe to an MCP resource stream",
2464
+ category: "mcp",
2465
+ notes: ["Requires an MCP server that supports resource subscriptions."]
2466
+ },
2467
+ UnsubscribeMcpResource: {
2468
+ description: "Unsubscribe from an MCP resource stream",
2469
+ category: "mcp"
2470
+ },
2471
+ SubscribePolling: {
2472
+ description: "Subscribe to periodic polling",
2473
+ category: "mcp"
2474
+ },
2475
+ UnsubscribePolling: {
2476
+ description: "Unsubscribe from periodic polling",
2477
+ category: "mcp"
2478
+ },
2303
2479
  TeamDelete: {
2304
2480
  description: "Delete team (may need shutdown_approved first)",
2305
2481
  category: "agent",
@@ -2412,11 +2588,15 @@ function toPermissionResult(params) {
2412
2588
  interrupt: params.interrupt
2413
2589
  };
2414
2590
  }
2415
- 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
+ }
2416
2596
  const normalizedToolName = toolName?.trim();
2417
- if (!normalizedToolName) return updates;
2597
+ if (!normalizedToolName) return merged.length > 0 ? merged : void 0;
2418
2598
  return [
2419
- ...updates ?? [],
2599
+ ...merged,
2420
2600
  {
2421
2601
  type: "addRules",
2422
2602
  behavior: "allow",
@@ -2654,7 +2834,7 @@ function buildResult(sessionManager, toolCache, input) {
2654
2834
  if (e.type !== "progress") return true;
2655
2835
  const d = e.data;
2656
2836
  const progressType = d?.type;
2657
- return progressType !== "tool_progress" && progressType !== "auth_status";
2837
+ return progressType !== "tool_progress" && progressType !== "auth_status" && progressType !== "api_retry" && progressType !== "task_progress" && progressType !== "hook_progress";
2658
2838
  });
2659
2839
  }
2660
2840
  return filtered;
@@ -2704,6 +2884,8 @@ function buildResult(sessionManager, toolCache, input) {
2704
2884
  toolName: req.toolName,
2705
2885
  input: req.input,
2706
2886
  summary: req.summary,
2887
+ title: req.title,
2888
+ displayName: req.displayName,
2707
2889
  decisionReason: req.decisionReason,
2708
2890
  blockedPath: req.blockedPath,
2709
2891
  toolUseID: req.toolUseID,
@@ -2797,6 +2979,7 @@ function executeClaudeCodeCheck(input, sessionManager, toolCache, requestSignal)
2797
2979
  const pendingRequest = input.decision === "allow_for_session" ? sessionManager.getPendingPermission(input.sessionId, input.requestId) : void 0;
2798
2980
  const updatedPermissions = input.decision === "allow_for_session" ? appendAllowForSessionUpdate(
2799
2981
  input.permissionOptions?.updatedPermissions,
2982
+ pendingRequest?.suggestions,
2800
2983
  pendingRequest?.toolName
2801
2984
  ) : input.permissionOptions?.updatedPermissions;
2802
2985
  const ok = sessionManager.finishRequest(
@@ -2829,6 +3012,7 @@ var ALWAYS_REDACTED_FIELDS = [
2829
3012
  "env",
2830
3013
  "mcpServers",
2831
3014
  "sandbox",
3015
+ "settings",
2832
3016
  "debugFile",
2833
3017
  "pathToClaudeCodeExecutable"
2834
3018
  ];
@@ -2836,7 +3020,8 @@ var CONDITIONAL_REDACTED_FIELDS = [
2836
3020
  "cwd",
2837
3021
  "systemPrompt",
2838
3022
  "agents",
2839
- "additionalDirectories"
3023
+ "additionalDirectories",
3024
+ "toolConfig"
2840
3025
  ];
2841
3026
  function buildRedactions(includeSensitive) {
2842
3027
  const redactions = [];
@@ -3021,6 +3206,7 @@ function buildSessionRedactions(includeSensitive) {
3021
3206
  { field: "env", reason: "secret_or_internal" },
3022
3207
  { field: "mcpServers", reason: "secret_or_internal" },
3023
3208
  { field: "sandbox", reason: "secret_or_internal" },
3209
+ { field: "settings", reason: "secret_or_internal" },
3024
3210
  { field: "debugFile", reason: "secret_or_internal" },
3025
3211
  { field: "pathToClaudeCodeExecutable", reason: "secret_or_internal" }
3026
3212
  ];
@@ -3029,7 +3215,8 @@ function buildSessionRedactions(includeSensitive) {
3029
3215
  { field: "cwd", reason: "sensitive_by_default" },
3030
3216
  { field: "systemPrompt", reason: "sensitive_by_default" },
3031
3217
  { field: "agents", reason: "sensitive_by_default" },
3032
- { field: "additionalDirectories", reason: "sensitive_by_default" }
3218
+ { field: "additionalDirectories", reason: "sensitive_by_default" },
3219
+ { field: "toolConfig", reason: "sensitive_by_default" }
3033
3220
  );
3034
3221
  }
3035
3222
  return redactions;
@@ -3253,6 +3440,7 @@ function registerResources(server, deps) {
3253
3440
  "Notes:",
3254
3441
  "- `respond_user_input` is not supported on this backend.",
3255
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`.",
3256
3444
  "- Prefer `responseMode='delta_compact'` for high-frequency polling."
3257
3445
  ].join("\n"),
3258
3446
  "text/markdown"
@@ -3595,7 +3783,7 @@ function registerResources(server, deps) {
3595
3783
  }
3596
3784
 
3597
3785
  // src/server.ts
3598
- var SERVER_VERSION = true ? "2.4.8" : "0.0.0-dev";
3786
+ var SERVER_VERSION = true ? "2.8.0" : "0.0.0-dev";
3599
3787
  function createServerContext(serverCwd) {
3600
3788
  const sessionManager = new SessionManager();
3601
3789
  const server = new McpServer(
@@ -3635,7 +3823,7 @@ function createServerContext(serverCwd) {
3635
3823
  prompt: z.string(),
3636
3824
  tools: z.array(z.string()).optional().describe("Default: inherit"),
3637
3825
  disallowedTools: z.array(z.string()).optional().describe("Default: none"),
3638
- model: z.enum(AGENT_MODELS).optional().describe("Default: inherit"),
3826
+ model: z.string().optional().describe("Default: inherit"),
3639
3827
  maxTurns: z.number().int().positive().optional().describe("Default: none"),
3640
3828
  mcpServers: z.array(z.union([z.string(), z.record(z.string(), z.unknown())])).optional().describe("Default: inherit"),
3641
3829
  skills: z.array(z.string()).optional().describe("Default: none"),
@@ -3684,9 +3872,12 @@ function createServerContext(serverCwd) {
3684
3872
  sandbox: z.record(z.string(), z.unknown()).optional().describe("Default: none"),
3685
3873
  fallbackModel: z.string().optional().describe("Default: none"),
3686
3874
  enableFileCheckpointing: z.boolean().optional().describe("Default: false"),
3875
+ toolConfig: z.record(z.string(), z.unknown()).optional().describe("Default: none"),
3687
3876
  includePartialMessages: z.boolean().optional().describe("Default: false"),
3688
3877
  promptSuggestions: z.boolean().optional().describe("Default: false"),
3878
+ agentProgressSummaries: z.boolean().optional().describe("Default: false"),
3689
3879
  strictMcpConfig: z.boolean().optional().describe("Default: false"),
3880
+ settings: z.union([z.string(), z.record(z.string(), z.unknown())]).optional().describe("Default: none"),
3690
3881
  settingSources: z.array(z.enum(["user", "project", "local"])).optional().describe("Default: ['user','project','local']. []=isolation"),
3691
3882
  debug: z.boolean().optional().describe("Default: false"),
3692
3883
  debugFile: z.string().optional().describe("Default: none"),