@mcpjam/inspector 1.0.0 → 1.0.1

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.
Binary file
Binary file
Binary file
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/mcp_jam.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>MCPJam Inspector</title>
8
- <script type="module" crossorigin src="/assets/index-BQ-ekSd_.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-Dn41SYnl.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BZlC0Ubf.css">
10
10
  </head>
11
11
  <body>
@@ -272,6 +272,8 @@ tools.post("/list", async (c) => {
272
272
  }
273
273
  });
274
274
  tools.post("/execute", async (c) => {
275
+ const mcp2 = c.mcpJamClientManager;
276
+ let state = null;
275
277
  try {
276
278
  const { serverId, toolName, parameters } = await c.req.json();
277
279
  if (!serverId) return c.json({ error: "serverId is required" }, 400);
@@ -279,19 +281,20 @@ tools.post("/execute", async (c) => {
279
281
  if (activeExecution) {
280
282
  return c.json({ error: "Another execution is already in progress" }, 409);
281
283
  }
282
- const mcp2 = c.mcpJamClientManager;
283
284
  const status = mcp2.getConnectionStatus(serverId);
284
285
  if (status !== "connected") {
285
286
  return c.json({ error: `Server '${serverId}' is not connected` }, 400);
286
287
  }
287
288
  const executionId = `exec_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
288
- const state = {
289
+ const execPromise = Promise.resolve().then(() => mcp2.executeToolDirect(toolName, parameters || {})).catch((error) => {
290
+ if (state) state.error = error;
291
+ throw error;
292
+ });
293
+ state = {
289
294
  id: executionId,
290
295
  serverId,
291
296
  toolName,
292
- execPromise: Promise.resolve().then(
293
- () => mcp2.executeToolDirect(toolName, parameters || {})
294
- ),
297
+ execPromise,
295
298
  completed: false,
296
299
  queue: [],
297
300
  waiters: []
@@ -360,20 +363,27 @@ tools.post("/execute", async (c) => {
360
363
  202
361
364
  );
362
365
  } catch (err) {
366
+ if (state && activeExecution === state) {
367
+ state.error = state.error ?? err;
368
+ state.waiters.length = 0;
369
+ state.queue.length = 0;
370
+ activeExecution = null;
371
+ mcp2.clearElicitationCallback();
372
+ }
363
373
  const msg = err instanceof Error ? err.message : String(err);
364
374
  return c.json({ error: msg }, 500);
365
375
  }
366
376
  });
367
377
  tools.post("/respond", async (c) => {
378
+ const mcp2 = c.mcpJamClientManager;
379
+ const state = activeExecution;
368
380
  try {
369
381
  const { requestId, response } = await c.req.json();
370
382
  if (!requestId) return c.json({ error: "requestId is required" }, 400);
371
- if (!activeExecution) return c.json({ error: "No active execution" }, 404);
372
- const mcp2 = c.mcpJamClientManager;
383
+ if (!state) return c.json({ error: "No active execution" }, 404);
373
384
  const ok = mcp2.respondToElicitation(requestId, response);
374
385
  if (!ok)
375
386
  return c.json({ error: "No pending elicitation for requestId" }, 404);
376
- const state = activeExecution;
377
387
  try {
378
388
  const race = await Promise.race([
379
389
  state.execPromise.then((res) => ({ kind: "done", res })),
@@ -408,10 +418,24 @@ tools.post("/respond", async (c) => {
408
418
  202
409
419
  );
410
420
  } catch (e) {
421
+ state.error = state.error ?? e;
422
+ state.waiters.length = 0;
423
+ state.queue.length = 0;
424
+ if (activeExecution === state) {
425
+ activeExecution = null;
426
+ mcp2.clearElicitationCallback();
427
+ }
411
428
  const msg = e instanceof Error ? e.message : String(e);
412
429
  return c.json({ error: msg }, 500);
413
430
  }
414
431
  } catch (err) {
432
+ if (state && activeExecution === state) {
433
+ state.error = state.error ?? err;
434
+ state.waiters.length = 0;
435
+ state.queue.length = 0;
436
+ activeExecution = null;
437
+ mcp2.clearElicitationCallback();
438
+ }
415
439
  const msg = err instanceof Error ? err.message : String(err);
416
440
  return c.json({ error: msg }, 500);
417
441
  }