@tonyclaw/agent-inspector 3.0.43 → 3.0.45
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/.output/cli.js +20744 -16945
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{CompareDrawer-BAXxwTwT.js → CompareDrawer-B3_TLTJh.js} +1 -1
- package/.output/public/assets/{InspectorPet-xYuGV4Qz.js → InspectorPet-Cpn6hv4P.js} +1 -1
- package/.output/public/assets/{ProxyViewerContainer-B6GZnUWi.js → ProxyViewerContainer-BEAhuGOJ.js} +27 -27
- package/.output/public/assets/{ReplayDialog-D73pyIg3.js → ReplayDialog-B3EKVdJk.js} +1 -1
- package/.output/public/assets/{RequestAnatomy-CSDta_nu.js → RequestAnatomy-COOQjyUC.js} +1 -1
- package/.output/public/assets/{ResponseView-C4aIUPby.js → ResponseView-DBCjkwye.js} +1 -1
- package/.output/public/assets/{StreamingChunkSequence-D4xxosLx.js → StreamingChunkSequence-CuXhDgMo.js} +1 -1
- package/.output/public/assets/{_sessionId-CZHbJyWO.js → _sessionId-BJlM3nmt.js} +1 -1
- package/.output/public/assets/{_sessionId-DvuNLzSE.js → _sessionId-zbgYl7ZJ.js} +1 -1
- package/.output/public/assets/{index-DZ_wpqQM.js → index-BIK4bPTv.js} +1 -1
- package/.output/public/assets/{index-B17u7JMC.js → index-BZo_8koU.js} +15 -15
- package/.output/public/assets/{index-C0g79BAs.js → index-D2Qw6Ri2.js} +1 -1
- package/.output/public/assets/{index-BWjeqxbk.css → index-ZWschkCh.css} +1 -1
- package/.output/public/assets/{index-CmEO8ykj.js → index-xF_NY8Yb.js} +5 -5
- package/.output/public/assets/{json-viewer-CuWU-H6K.js → json-viewer-B-Ao6pwW.js} +1 -1
- package/.output/public/assets/{jszip.min-DPJI_UKW.js → jszip.min-B_rfAUCe.js} +1 -1
- package/.output/server/_libs/modelcontextprotocol__core.mjs +25 -25
- package/.output/server/_libs/modelcontextprotocol__server.mjs +2 -2
- package/.output/server/_libs/zod.mjs +6 -6
- package/.output/server/{_sessionId-Cun21KZF.mjs → _sessionId-CJ99gZFV.mjs} +3 -1
- package/.output/server/{_sessionId-CoFyeOti.mjs → _sessionId-DEjScBpK.mjs} +5 -3
- package/.output/server/_ssr/{CompareDrawer-Bgc2TZh_.mjs → CompareDrawer-DtOIMeQB.mjs} +4 -2
- package/.output/server/_ssr/{InspectorPet-DyK2ojeh.mjs → InspectorPet-CXc4oCBQ.mjs} +3 -1
- package/.output/server/_ssr/{ProxyViewerContainer-hvn6oVWD.mjs → ProxyViewerContainer-DVPlwfkt.mjs} +52 -27
- package/.output/server/_ssr/{ReplayDialog-KpnrGtZ-.mjs → ReplayDialog-BQEA95qC.mjs} +6 -4
- package/.output/server/_ssr/{RequestAnatomy-uCsfucn8.mjs → RequestAnatomy-BMyd8B7Q.mjs} +4 -2
- package/.output/server/_ssr/{ResponseView-C8UPqoPO.mjs → ResponseView-qrTaEIM8.mjs} +4 -2
- package/.output/server/_ssr/{StreamingChunkSequence-BP28I9sh.mjs → StreamingChunkSequence-BFTL8mIy.mjs} +5 -3
- package/.output/server/_ssr/{index-Du3YNDKx.mjs → index-Bcj1Hcy4.mjs} +4 -2
- package/.output/server/_ssr/{index-BVwVoQlZ.mjs → index-DW-M7XUG.mjs} +3 -1
- package/.output/server/_ssr/index.mjs +4 -3
- package/.output/server/_ssr/{json-viewer-DrE0vtlB.mjs → json-viewer-DiI0Yjsn.mjs} +4 -2
- package/.output/server/_ssr/publicBasePathContext-5264L3rX.mjs +148 -0
- package/.output/server/_ssr/{router-C6nWUZHK.mjs → router-BJ_ltLim.mjs} +2432 -475
- package/.output/server/_ssr/start-C6MjPjxp.mjs +57 -0
- package/.output/server/_tanstack-start-manifest_v-C6pXXX9R.mjs +4 -0
- package/.output/server/index.mjs +99 -99
- package/.output/workers/logFinalizer.worker.js +4 -0
- package/.output/workers/sessionWorkerEntry.js +4 -0
- package/README.md +221 -25
- package/docs/instance-control.openapi.yaml +306 -0
- package/package.json +4 -1
- package/src/cli/alias.ts +440 -0
- package/src/cli/instance.ts +1037 -0
- package/src/cli/instanceArgs.ts +266 -0
- package/src/cli/instanceControl.ts +183 -0
- package/src/cli/instanceModel.ts +275 -0
- package/src/cli/instanceRegistry.ts +740 -0
- package/src/cli/onboard.ts +123 -35
- package/src/cli/onboardTarget.ts +179 -0
- package/src/cli/templates/codex-skill-onboard.ts +76 -28
- package/src/cli/templates/skill-onboard.ts +93 -59
- package/src/cli.ts +154 -16
- package/src/components/ProxyViewer.tsx +13 -5
- package/src/components/providers/SettingsDialog.tsx +13 -8
- package/src/lib/basePath.ts +8 -2
- package/src/lib/codingAgentEndpoints.ts +16 -0
- package/src/lib/instanceContract.ts +220 -0
- package/src/lib/managedInstance.ts +104 -0
- package/src/lib/publicBasePathContext.ts +107 -0
- package/src/mcp/instanceHandlers.ts +149 -0
- package/src/mcp/loopback.ts +16 -5
- package/src/mcp/mode.ts +25 -0
- package/src/mcp/server.ts +258 -18
- package/src/mcp/toolHandlers.ts +2 -2
- package/src/proxy/identityProxy.ts +656 -36
- package/src/proxy/runtimeShutdown.ts +73 -1
- package/src/proxy/sessionInfo.ts +5 -4
- package/src/routes/api/-instances.ts +109 -0
- package/src/routes/api/instances.$name.connection.ts +12 -0
- package/src/routes/api/instances.$name.restart.ts +23 -0
- package/src/routes/api/instances.$name.start.ts +18 -0
- package/src/routes/api/instances.$name.stop.ts +23 -0
- package/src/routes/api/instances.$name.ts +12 -0
- package/src/routes/api/instances.ts +16 -0
- package/src/start.ts +10 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +0 -4
- package/.output/server/_tanstack-start-manifest_v-rshlRaiN.mjs +0 -4
package/src/mcp/server.ts
CHANGED
|
@@ -33,9 +33,14 @@ import {
|
|
|
33
33
|
UpdateInspectorGroupInputSchema,
|
|
34
34
|
} from "../lib/groupContract";
|
|
35
35
|
import { InspectorRunStatusSchema, UpdateInspectorRunInputSchema } from "../lib/runContract";
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
36
|
+
import { withBasePath } from "../lib/basePath";
|
|
37
|
+
import {
|
|
38
|
+
getPublicBasePath,
|
|
39
|
+
getPublicPort,
|
|
40
|
+
runWithRequestPublicBasePath,
|
|
41
|
+
} from "../lib/publicBasePathContext";
|
|
38
42
|
import { JsonValueSchema } from "../contracts";
|
|
43
|
+
import { InstanceListOutputSchema } from "../lib/instanceContract";
|
|
39
44
|
import {
|
|
40
45
|
MAX_PROVIDER_MODEL_NAME_CHARS,
|
|
41
46
|
MAX_PROVIDER_MODELS,
|
|
@@ -43,7 +48,22 @@ import {
|
|
|
43
48
|
MAX_SEARCH_QUERY_CHARS,
|
|
44
49
|
} from "../lib/resourceLimits";
|
|
45
50
|
import { getCurrentContext } from "./currentContext";
|
|
46
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
getMcpInstanceModeInfo,
|
|
53
|
+
getMcpModeInfo,
|
|
54
|
+
isMcpInstanceWriteEnabled,
|
|
55
|
+
isMcpWriteEnabled,
|
|
56
|
+
} from "./mode";
|
|
57
|
+
import {
|
|
58
|
+
getInstanceConnectionImpl,
|
|
59
|
+
getInstanceImpl,
|
|
60
|
+
InstanceLifecycleToolInputSchema,
|
|
61
|
+
InstanceNameToolInputSchema,
|
|
62
|
+
listInstancesImpl,
|
|
63
|
+
restartInstanceImpl,
|
|
64
|
+
startInstanceImpl,
|
|
65
|
+
stopInstanceImpl,
|
|
66
|
+
} from "./instanceHandlers";
|
|
47
67
|
import {
|
|
48
68
|
getInspectorGroup,
|
|
49
69
|
listInspectorGroups,
|
|
@@ -178,17 +198,10 @@ export async function _resetForTests(): Promise<void> {
|
|
|
178
198
|
* handler — accepts a Web `Request`, returns a `Promise<Response>`.
|
|
179
199
|
*/
|
|
180
200
|
export async function handleMcpRequest(request: Request): Promise<Response> {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const port = Number(url.port);
|
|
186
|
-
if (port > 0) setCurrentPort(port);
|
|
187
|
-
} catch {
|
|
188
|
-
// URL parse failure → fall through to PORT env var in getCurrentPort()
|
|
189
|
-
}
|
|
190
|
-
const { transport } = await getServer();
|
|
191
|
-
return transport.handleRequest(request);
|
|
201
|
+
return runWithRequestPublicBasePath(request, async () => {
|
|
202
|
+
const { transport } = await getServer();
|
|
203
|
+
return transport.handleRequest(request);
|
|
204
|
+
});
|
|
192
205
|
}
|
|
193
206
|
|
|
194
207
|
// ---------------------------------------------------------------------------
|
|
@@ -219,6 +232,27 @@ Either preview field is null when the body is unknown format, unparseable, or th
|
|
|
219
232
|
const PROVIDER_WRITE_WARNING =
|
|
220
233
|
"⚠ This tool mutates provider configuration. Confirm with the user before invoking.";
|
|
221
234
|
|
|
235
|
+
const INSTANCE_LIFECYCLE_WRITE_WARNING =
|
|
236
|
+
"This tool changes a local Agent Inspector process. Obtain explicit user approval before invoking it.";
|
|
237
|
+
|
|
238
|
+
const INSTANCE_READ_TOOL_NAMES = [
|
|
239
|
+
"inspector_list_instances",
|
|
240
|
+
"inspector_get_instance",
|
|
241
|
+
"inspector_get_instance_connection",
|
|
242
|
+
] as const;
|
|
243
|
+
|
|
244
|
+
const INSTANCE_WRITE_TOOL_NAMES = [
|
|
245
|
+
"inspector_start_instance",
|
|
246
|
+
"inspector_stop_instance",
|
|
247
|
+
"inspector_restart_instance",
|
|
248
|
+
] as const;
|
|
249
|
+
|
|
250
|
+
const INSTANCE_RESOURCE_URIS = [
|
|
251
|
+
"inspector://instances",
|
|
252
|
+
"inspector://instances/{name}",
|
|
253
|
+
"inspector://instances/{name}/connection",
|
|
254
|
+
] as const;
|
|
255
|
+
|
|
222
256
|
const AddProviderInputSchema = z
|
|
223
257
|
.object({
|
|
224
258
|
name: z.string().min(1).describe("Provider display name."),
|
|
@@ -327,9 +361,9 @@ function jsonResource(uri: URL, data: unknown): ReadResourceResult {
|
|
|
327
361
|
}
|
|
328
362
|
|
|
329
363
|
function mcpEndpointUrl(): string {
|
|
330
|
-
return `http://localhost:${String(
|
|
364
|
+
return `http://localhost:${String(getPublicPort())}${withBasePath(
|
|
331
365
|
"/api/mcp",
|
|
332
|
-
|
|
366
|
+
getPublicBasePath(),
|
|
333
367
|
)}`;
|
|
334
368
|
}
|
|
335
369
|
|
|
@@ -342,7 +376,7 @@ function mcpHealth(): Record<string, unknown> {
|
|
|
342
376
|
},
|
|
343
377
|
transport: {
|
|
344
378
|
primary: "streamable-http",
|
|
345
|
-
endpoint:
|
|
379
|
+
endpoint: mcpEndpointUrl(),
|
|
346
380
|
stateless: true,
|
|
347
381
|
},
|
|
348
382
|
mode: getMcpModeInfo(),
|
|
@@ -355,6 +389,7 @@ function mcpHealth(): Record<string, unknown> {
|
|
|
355
389
|
}
|
|
356
390
|
|
|
357
391
|
const WRITE_TOOL_NAMES = new Set<string>([
|
|
392
|
+
...INSTANCE_WRITE_TOOL_NAMES,
|
|
358
393
|
"inspector_create_run",
|
|
359
394
|
"inspector_update_run",
|
|
360
395
|
"inspector_export_evidence",
|
|
@@ -379,18 +414,36 @@ const WRITE_TOOL_NAMES = new Set<string>([
|
|
|
379
414
|
function mcpCapabilities(): Record<string, unknown> {
|
|
380
415
|
const readTools = TOOL_NAMES.filter((name) => !WRITE_TOOL_NAMES.has(name));
|
|
381
416
|
const writeTools = TOOL_NAMES.filter((name) => WRITE_TOOL_NAMES.has(name));
|
|
417
|
+
const generalWriteMode = getMcpModeInfo();
|
|
418
|
+
const instanceWriteMode = getMcpInstanceModeInfo();
|
|
382
419
|
return {
|
|
383
420
|
serverInfo: {
|
|
384
421
|
name: "agent-inspector",
|
|
385
422
|
version: MCP_SERVER_VERSION,
|
|
386
423
|
},
|
|
387
|
-
mode:
|
|
424
|
+
mode: generalWriteMode,
|
|
388
425
|
tools: {
|
|
389
426
|
read: readTools,
|
|
390
427
|
writeOrAction: writeTools,
|
|
391
428
|
},
|
|
392
429
|
resources: RESOURCE_NAMES,
|
|
393
430
|
prompts: PROMPT_NAMES,
|
|
431
|
+
instanceControl: {
|
|
432
|
+
tools: {
|
|
433
|
+
read: INSTANCE_READ_TOOL_NAMES,
|
|
434
|
+
writeOrAction: INSTANCE_WRITE_TOOL_NAMES,
|
|
435
|
+
},
|
|
436
|
+
resources: INSTANCE_RESOURCE_URIS,
|
|
437
|
+
writeGates: {
|
|
438
|
+
general: generalWriteMode,
|
|
439
|
+
instance: instanceWriteMode,
|
|
440
|
+
lifecycleWritesEnabled: generalWriteMode.writesEnabled && instanceWriteMode.writesEnabled,
|
|
441
|
+
},
|
|
442
|
+
limitations: {
|
|
443
|
+
selfStopOrRestart:
|
|
444
|
+
"The serving managed instance cannot stop or restart itself over REST or MCP. Use the CLI or a sibling controller instance.",
|
|
445
|
+
},
|
|
446
|
+
},
|
|
394
447
|
};
|
|
395
448
|
}
|
|
396
449
|
|
|
@@ -473,6 +526,36 @@ function safeWriteCall(
|
|
|
473
526
|
});
|
|
474
527
|
}
|
|
475
528
|
|
|
529
|
+
function disabledInstanceWriteTool(toolName: string): ToolResult {
|
|
530
|
+
return {
|
|
531
|
+
content: [
|
|
532
|
+
{
|
|
533
|
+
type: "text",
|
|
534
|
+
text: JSON.stringify(
|
|
535
|
+
{
|
|
536
|
+
error: "mcp-instance-write-disabled",
|
|
537
|
+
tool: toolName,
|
|
538
|
+
generalMode: getMcpModeInfo(),
|
|
539
|
+
instanceMode: getMcpInstanceModeInfo(),
|
|
540
|
+
},
|
|
541
|
+
null,
|
|
542
|
+
2,
|
|
543
|
+
),
|
|
544
|
+
},
|
|
545
|
+
],
|
|
546
|
+
isError: true,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function safeInstanceWriteCall(
|
|
551
|
+
toolName: string,
|
|
552
|
+
fn: () => ToolResult | Promise<ToolResult>,
|
|
553
|
+
): Promise<ToolResult> {
|
|
554
|
+
return safeWriteCall(toolName, () =>
|
|
555
|
+
isMcpInstanceWriteEnabled() ? fn() : disabledInstanceWriteTool(toolName),
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
476
559
|
function variableString(variables: Variables, name: string): string | null {
|
|
477
560
|
const value = variables[name];
|
|
478
561
|
if (Array.isArray(value)) return value[0] ?? null;
|
|
@@ -504,6 +587,41 @@ function readServiceJsonResource<T>(
|
|
|
504
587
|
return jsonResource(uri, result.value);
|
|
505
588
|
}
|
|
506
589
|
|
|
590
|
+
async function readInstanceToolResource(
|
|
591
|
+
uri: URL,
|
|
592
|
+
resultPromise: Promise<ToolResult>,
|
|
593
|
+
): Promise<ReadResourceResult> {
|
|
594
|
+
const result = await resultPromise;
|
|
595
|
+
const text = result.content[0]?.text ?? "";
|
|
596
|
+
return textResource(uri, result.isError === true ? "text/plain" : "application/json", text);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
async function listInstanceTemplateResources(connection: boolean): Promise<ListResourcesResult> {
|
|
600
|
+
try {
|
|
601
|
+
const response = await callApi("/api/instances", {
|
|
602
|
+
headers: { accept: "application/json" },
|
|
603
|
+
});
|
|
604
|
+
if (!response.ok) return listResult([]);
|
|
605
|
+
const parsed = InstanceListOutputSchema.safeParse(await response.json());
|
|
606
|
+
if (!parsed.success) return listResult([]);
|
|
607
|
+
return listResult(
|
|
608
|
+
parsed.data.instances.map((instance) => ({
|
|
609
|
+
uri: connection
|
|
610
|
+
? `inspector://instances/${encodeURIComponent(instance.name)}/connection`
|
|
611
|
+
: `inspector://instances/${encodeURIComponent(instance.name)}`,
|
|
612
|
+
name: connection ? `instance-connection:${instance.name}` : `instance:${instance.name}`,
|
|
613
|
+
title: connection
|
|
614
|
+
? `Agent Inspector connection for ${instance.name}`
|
|
615
|
+
: `Agent Inspector instance ${instance.name}`,
|
|
616
|
+
mimeType: "application/json",
|
|
617
|
+
description: `${instance.state} at ${instance.urls.ui}`,
|
|
618
|
+
})),
|
|
619
|
+
);
|
|
620
|
+
} catch {
|
|
621
|
+
return listResult([]);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
507
625
|
async function listSessionResources(): Promise<ListResourcesResult> {
|
|
508
626
|
try {
|
|
509
627
|
const response = await callApi("/api/sessions");
|
|
@@ -707,6 +825,74 @@ function userPrompt(text: string): GetPromptResult {
|
|
|
707
825
|
// ---------------------------------------------------------------------------
|
|
708
826
|
|
|
709
827
|
function registerTools(server: McpServer): void {
|
|
828
|
+
// ----- Named instance discovery and lifecycle -----
|
|
829
|
+
|
|
830
|
+
server.registerTool(
|
|
831
|
+
"inspector_list_instances",
|
|
832
|
+
{
|
|
833
|
+
title: "List named Agent Inspector instances",
|
|
834
|
+
description:
|
|
835
|
+
"Returns the versioned, token-free REST instance list with live state, saved configuration, and public URLs. Available in readonly mode.",
|
|
836
|
+
inputSchema: z.object({}).strict(),
|
|
837
|
+
},
|
|
838
|
+
() => safeCall(() => listInstancesImpl(callApi)),
|
|
839
|
+
);
|
|
840
|
+
|
|
841
|
+
server.registerTool(
|
|
842
|
+
"inspector_get_instance",
|
|
843
|
+
{
|
|
844
|
+
title: "Get a named Agent Inspector instance",
|
|
845
|
+
description:
|
|
846
|
+
"Returns one versioned, token-free named-instance status document from the REST control plane. Available in readonly mode.",
|
|
847
|
+
inputSchema: InstanceNameToolInputSchema,
|
|
848
|
+
},
|
|
849
|
+
({ name }) => safeCall(() => getInstanceImpl(callApi, name)),
|
|
850
|
+
);
|
|
851
|
+
|
|
852
|
+
server.registerTool(
|
|
853
|
+
"inspector_get_instance_connection",
|
|
854
|
+
{
|
|
855
|
+
title: "Get coding-agent connection settings for an instance",
|
|
856
|
+
description:
|
|
857
|
+
"Returns the REST connection descriptor for one named instance, including protocol-correct proxy, OpenAI /v1, MCP, health, environment, and Codex values. It never includes credentials.",
|
|
858
|
+
inputSchema: InstanceNameToolInputSchema,
|
|
859
|
+
},
|
|
860
|
+
({ name }) => safeCall(() => getInstanceConnectionImpl(callApi, name)),
|
|
861
|
+
);
|
|
862
|
+
|
|
863
|
+
server.registerTool(
|
|
864
|
+
"inspector_start_instance",
|
|
865
|
+
{
|
|
866
|
+
title: "Start or create a named Agent Inspector instance",
|
|
867
|
+
description: `${INSTANCE_LIFECYCLE_WRITE_WARNING} Starts, creates, or idempotently reuses a named sibling instance through the REST lifecycle API. Requires both AGENT_INSPECTOR_MCP_WRITES=1 and AGENT_INSPECTOR_MCP_INSTANCE_WRITES=1.`,
|
|
868
|
+
inputSchema: InstanceLifecycleToolInputSchema,
|
|
869
|
+
},
|
|
870
|
+
(args) =>
|
|
871
|
+
safeInstanceWriteCall("inspector_start_instance", () => startInstanceImpl(callApi, args)),
|
|
872
|
+
);
|
|
873
|
+
|
|
874
|
+
server.registerTool(
|
|
875
|
+
"inspector_stop_instance",
|
|
876
|
+
{
|
|
877
|
+
title: "Stop a named Agent Inspector instance",
|
|
878
|
+
description: `${INSTANCE_LIFECYCLE_WRITE_WARNING} Gracefully stops a sibling instance after authenticated ownership checks. The instance serving this MCP connection cannot stop itself. Requires both MCP write gates.`,
|
|
879
|
+
inputSchema: InstanceNameToolInputSchema,
|
|
880
|
+
},
|
|
881
|
+
({ name }) =>
|
|
882
|
+
safeInstanceWriteCall("inspector_stop_instance", () => stopInstanceImpl(callApi, name)),
|
|
883
|
+
);
|
|
884
|
+
|
|
885
|
+
server.registerTool(
|
|
886
|
+
"inspector_restart_instance",
|
|
887
|
+
{
|
|
888
|
+
title: "Restart a named Agent Inspector instance",
|
|
889
|
+
description: `${INSTANCE_LIFECYCLE_WRITE_WARNING} Validates and restarts a sibling instance through the bounded REST lifecycle path. The instance serving this MCP connection cannot restart itself. Requires both MCP write gates.`,
|
|
890
|
+
inputSchema: InstanceLifecycleToolInputSchema,
|
|
891
|
+
},
|
|
892
|
+
(args) =>
|
|
893
|
+
safeInstanceWriteCall("inspector_restart_instance", () => restartInstanceImpl(callApi, args)),
|
|
894
|
+
);
|
|
895
|
+
|
|
710
896
|
// ----- Read tools -----
|
|
711
897
|
|
|
712
898
|
server.registerTool(
|
|
@@ -1460,6 +1646,55 @@ PATCH-style update: only the fields you supply are changed. Use models to update
|
|
|
1460
1646
|
}
|
|
1461
1647
|
|
|
1462
1648
|
function registerResources(server: McpServer): void {
|
|
1649
|
+
server.registerResource(
|
|
1650
|
+
"inspector_instances",
|
|
1651
|
+
"inspector://instances",
|
|
1652
|
+
{
|
|
1653
|
+
title: "Named Agent Inspector instances",
|
|
1654
|
+
description: "Versioned, token-free named-instance list backed by GET /api/instances.",
|
|
1655
|
+
mimeType: "application/json",
|
|
1656
|
+
},
|
|
1657
|
+
(uri) => readInstanceToolResource(uri, listInstancesImpl(callApi)),
|
|
1658
|
+
);
|
|
1659
|
+
|
|
1660
|
+
server.registerResource(
|
|
1661
|
+
"inspector_instance",
|
|
1662
|
+
new ResourceTemplate("inspector://instances/{name}", {
|
|
1663
|
+
list: async () => await listInstanceTemplateResources(false),
|
|
1664
|
+
}),
|
|
1665
|
+
{
|
|
1666
|
+
title: "Named Agent Inspector instance",
|
|
1667
|
+
description:
|
|
1668
|
+
"Versioned, token-free status for one named instance backed by GET /api/instances/{name}.",
|
|
1669
|
+
mimeType: "application/json",
|
|
1670
|
+
},
|
|
1671
|
+
(uri, variables) => {
|
|
1672
|
+
const name = variableString(variables, "name");
|
|
1673
|
+
return name === null
|
|
1674
|
+
? textResource(uri, "text/plain", "Missing instance name")
|
|
1675
|
+
: readInstanceToolResource(uri, getInstanceImpl(callApi, name));
|
|
1676
|
+
},
|
|
1677
|
+
);
|
|
1678
|
+
|
|
1679
|
+
server.registerResource(
|
|
1680
|
+
"inspector_instance_connection",
|
|
1681
|
+
new ResourceTemplate("inspector://instances/{name}/connection", {
|
|
1682
|
+
list: async () => await listInstanceTemplateResources(true),
|
|
1683
|
+
}),
|
|
1684
|
+
{
|
|
1685
|
+
title: "Named instance coding-agent connection",
|
|
1686
|
+
description:
|
|
1687
|
+
"Token-free connection descriptor backed by GET /api/instances/{name}/connection.",
|
|
1688
|
+
mimeType: "application/json",
|
|
1689
|
+
},
|
|
1690
|
+
(uri, variables) => {
|
|
1691
|
+
const name = variableString(variables, "name");
|
|
1692
|
+
return name === null
|
|
1693
|
+
? textResource(uri, "text/plain", "Missing instance name")
|
|
1694
|
+
: readInstanceToolResource(uri, getInstanceConnectionImpl(callApi, name));
|
|
1695
|
+
},
|
|
1696
|
+
);
|
|
1697
|
+
|
|
1463
1698
|
server.registerResource(
|
|
1464
1699
|
"inspector_mcp_health",
|
|
1465
1700
|
"inspector://mcp/health",
|
|
@@ -1958,6 +2193,8 @@ Return:
|
|
|
1958
2193
|
|
|
1959
2194
|
// Surface the tool catalog for tests that assert on the tool name set.
|
|
1960
2195
|
export const TOOL_NAMES = [
|
|
2196
|
+
...INSTANCE_READ_TOOL_NAMES,
|
|
2197
|
+
...INSTANCE_WRITE_TOOL_NAMES,
|
|
1961
2198
|
"inspector_list_logs",
|
|
1962
2199
|
"inspector_search_logs",
|
|
1963
2200
|
"inspector_get_log",
|
|
@@ -2006,6 +2243,9 @@ export const TOOL_NAMES = [
|
|
|
2006
2243
|
] as const;
|
|
2007
2244
|
|
|
2008
2245
|
export const RESOURCE_NAMES = [
|
|
2246
|
+
"inspector_instances",
|
|
2247
|
+
"inspector_instance",
|
|
2248
|
+
"inspector_instance_connection",
|
|
2009
2249
|
"inspector_mcp_health",
|
|
2010
2250
|
"inspector_mcp_capabilities",
|
|
2011
2251
|
"inspector_mcp_config",
|
package/src/mcp/toolHandlers.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
|
20
20
|
import { dirname, join } from "node:path";
|
|
21
21
|
import JSZip from "jszip";
|
|
22
22
|
import { z } from "zod";
|
|
23
|
-
import {
|
|
23
|
+
import { getPublicPort } from "../lib/publicBasePathContext";
|
|
24
24
|
import { LoopbackTimeoutError, type CallApiOptions } from "./loopback";
|
|
25
25
|
import { extractLastUserMessagePreview, extractResponsePreview } from "./previewExtractor";
|
|
26
26
|
import {
|
|
@@ -138,7 +138,7 @@ function redactedProvidersResult(value: unknown): ToolResult {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function inspectorBaseUrl(): string {
|
|
141
|
-
return `http://127.0.0.1:${String(
|
|
141
|
+
return `http://127.0.0.1:${String(getPublicPort())}`;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
function hasBodyText(value: string | null, byteLength: number | null | undefined): boolean {
|