@mcpjam/inspector 1.0.18 → 1.0.20
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/.env.production +2 -1
- package/dist/client/assets/index-BzedM9rr.css +1 -0
- package/dist/client/assets/index-CqSEe2h2.js +1891 -0
- package/dist/client/index.html +2 -2
- package/dist/client/openrouter_logo.png +0 -0
- package/dist/server/index.js +47 -102
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/index-2PmT8f40.js +0 -1886
- package/dist/client/assets/index-DkqfjygH.css +0 -1
package/dist/client/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
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-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CqSEe2h2.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BzedM9rr.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="root"></div>
|
|
Binary file
|
package/dist/server/index.js
CHANGED
|
@@ -172,43 +172,52 @@ var MCPClientManager = class {
|
|
|
172
172
|
getServerSummaries() {
|
|
173
173
|
return Array.from(this.clientStates.entries()).map(([serverId, state]) => ({
|
|
174
174
|
id: serverId,
|
|
175
|
-
status: this.
|
|
175
|
+
status: this.getConnectionStatusByAttemptingPing(serverId),
|
|
176
176
|
config: state.config
|
|
177
177
|
}));
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
getConnectionStatusByAttemptingPing(serverId) {
|
|
180
|
+
const state = this.clientStates.get(serverId);
|
|
181
|
+
if (state == null ? void 0 : state.promise) {
|
|
182
|
+
return "connecting";
|
|
183
|
+
}
|
|
184
|
+
const client = state == null ? void 0 : state.client;
|
|
185
|
+
if (!client) {
|
|
186
|
+
return "disconnected";
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
client.ping();
|
|
190
|
+
return "connected";
|
|
191
|
+
} catch (error) {
|
|
192
|
+
return "disconnected";
|
|
193
|
+
}
|
|
181
194
|
}
|
|
182
195
|
getServerConfig(serverId) {
|
|
183
196
|
var _a2;
|
|
184
197
|
return (_a2 = this.clientStates.get(serverId)) == null ? void 0 : _a2.config;
|
|
185
198
|
}
|
|
186
199
|
async connectToServer(serverId, config) {
|
|
187
|
-
|
|
188
|
-
|
|
200
|
+
const timeout = this.getTimeout(config);
|
|
201
|
+
const existingState = this.clientStates.get(serverId);
|
|
202
|
+
if (existingState == null ? void 0 : existingState.client) {
|
|
189
203
|
throw new Error(`MCP server "${serverId}" is already connected.`);
|
|
190
204
|
}
|
|
191
|
-
const
|
|
192
|
-
const state = (_a2 = this.clientStates.get(serverId)) != null ? _a2 : {
|
|
205
|
+
const state = existingState != null ? existingState : {
|
|
193
206
|
config,
|
|
194
207
|
timeout
|
|
195
208
|
};
|
|
196
209
|
state.config = config;
|
|
197
210
|
state.timeout = timeout;
|
|
198
|
-
if (state.client) {
|
|
199
|
-
this.clientStates.set(serverId, state);
|
|
200
|
-
return state.client;
|
|
201
|
-
}
|
|
202
211
|
if (state.promise) {
|
|
203
212
|
this.clientStates.set(serverId, state);
|
|
204
213
|
return state.promise;
|
|
205
214
|
}
|
|
206
215
|
const connectionPromise = (async () => {
|
|
207
|
-
var
|
|
216
|
+
var _a2;
|
|
208
217
|
const client = new Client(
|
|
209
218
|
{
|
|
210
219
|
name: this.defaultClientName ? `${this.defaultClientName}` : serverId,
|
|
211
|
-
version: (
|
|
220
|
+
version: (_a2 = config.version) != null ? _a2 : this.defaultClientVersion
|
|
212
221
|
},
|
|
213
222
|
{
|
|
214
223
|
capabilities: this.buildCapabilities(config)
|
|
@@ -218,8 +227,8 @@ var MCPClientManager = class {
|
|
|
218
227
|
this.applyElicitationHandler(serverId, client);
|
|
219
228
|
if (config.onError) {
|
|
220
229
|
client.onerror = (error) => {
|
|
221
|
-
var
|
|
222
|
-
(
|
|
230
|
+
var _a22;
|
|
231
|
+
(_a22 = config.onError) == null ? void 0 : _a22.call(config, error);
|
|
223
232
|
};
|
|
224
233
|
}
|
|
225
234
|
client.onclose = () => {
|
|
@@ -247,10 +256,7 @@ var MCPClientManager = class {
|
|
|
247
256
|
this.clientStates.set(serverId, state);
|
|
248
257
|
return client;
|
|
249
258
|
})().catch((error) => {
|
|
250
|
-
|
|
251
|
-
state.client = void 0;
|
|
252
|
-
state.transport = void 0;
|
|
253
|
-
this.clientStates.set(serverId, state);
|
|
259
|
+
this.resetState(serverId);
|
|
254
260
|
throw error;
|
|
255
261
|
});
|
|
256
262
|
state.promise = connectionPromise;
|
|
@@ -258,6 +264,10 @@ var MCPClientManager = class {
|
|
|
258
264
|
return connectionPromise;
|
|
259
265
|
}
|
|
260
266
|
async disconnectServer(serverId) {
|
|
267
|
+
const connectionStatus = this.getConnectionStatusByAttemptingPing(serverId);
|
|
268
|
+
if (connectionStatus !== "connected") {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
261
271
|
const client = this.getClientById(serverId);
|
|
262
272
|
try {
|
|
263
273
|
await client.close();
|
|
@@ -1004,7 +1014,7 @@ servers.get("/status/:serverId", async (c) => {
|
|
|
1004
1014
|
try {
|
|
1005
1015
|
const serverId = c.req.param("serverId");
|
|
1006
1016
|
const mcpClientManager2 = c.mcpClientManager;
|
|
1007
|
-
const status = mcpClientManager2.
|
|
1017
|
+
const status = mcpClientManager2.getConnectionStatusByAttemptingPing(serverId);
|
|
1008
1018
|
return c.json({
|
|
1009
1019
|
success: true,
|
|
1010
1020
|
serverId,
|
|
@@ -1075,15 +1085,9 @@ servers.post("/reconnect", async (c) => {
|
|
|
1075
1085
|
normalizedConfig.url = new URL(urlValue.href);
|
|
1076
1086
|
}
|
|
1077
1087
|
}
|
|
1078
|
-
|
|
1079
|
-
const client = mcpClientManager2.getClient(serverId);
|
|
1080
|
-
if (client) {
|
|
1081
|
-
await mcpClientManager2.disconnectServer(serverId);
|
|
1082
|
-
}
|
|
1083
|
-
} catch {
|
|
1084
|
-
}
|
|
1088
|
+
await mcpClientManager2.disconnectServer(serverId);
|
|
1085
1089
|
await mcpClientManager2.connectToServer(serverId, normalizedConfig);
|
|
1086
|
-
const status = mcpClientManager2.
|
|
1090
|
+
const status = mcpClientManager2.getConnectionStatusByAttemptingPing(serverId);
|
|
1087
1091
|
const message = status === "connected" ? `Reconnected to server: ${serverId}` : `Server ${serverId} reconnected with status '${status}'`;
|
|
1088
1092
|
const success = status === "connected";
|
|
1089
1093
|
return c.json({
|
|
@@ -2119,6 +2123,7 @@ import { createDeepSeek } from "@ai-sdk/deepseek";
|
|
|
2119
2123
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
2120
2124
|
import { createMistral } from "@ai-sdk/mistral";
|
|
2121
2125
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2126
|
+
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
2122
2127
|
import { createOllama } from "ollama-ai-provider-v2";
|
|
2123
2128
|
var createLlmModel = (modelDefinition, apiKey, ollamaBaseUrl, litellmBaseUrl) => {
|
|
2124
2129
|
if (!modelDefinition?.id || !modelDefinition?.provider) {
|
|
@@ -2151,6 +2156,8 @@ var createLlmModel = (modelDefinition, apiKey, ollamaBaseUrl, litellmBaseUrl) =>
|
|
|
2151
2156
|
});
|
|
2152
2157
|
return openai.chat(modelDefinition.id);
|
|
2153
2158
|
}
|
|
2159
|
+
case "openrouter":
|
|
2160
|
+
return createOpenRouter({ apiKey })(modelDefinition.id);
|
|
2154
2161
|
default:
|
|
2155
2162
|
throw new Error(
|
|
2156
2163
|
`Unsupported provider: ${modelDefinition.provider} for model: ${modelDefinition.id}`
|
|
@@ -2442,10 +2449,6 @@ var handleAgentStepFinish = (streamingContext, text, toolCalls, toolResults, emi
|
|
|
2442
2449
|
streamingContext.lastEmittedToolCallId = currentToolCallId;
|
|
2443
2450
|
const toolName = call.name || call.toolName;
|
|
2444
2451
|
streamingContext.toolCallIdToName.set(currentToolCallId, toolName);
|
|
2445
|
-
if (!streamingContext.toolNameToCallIds.has(toolName)) {
|
|
2446
|
-
streamingContext.toolNameToCallIds.set(toolName, []);
|
|
2447
|
-
}
|
|
2448
|
-
streamingContext.toolNameToCallIds.get(toolName).push(currentToolCallId);
|
|
2449
2452
|
if (streamingContext.controller && streamingContext.encoder) {
|
|
2450
2453
|
sendSseEvent(
|
|
2451
2454
|
streamingContext.controller,
|
|
@@ -2587,10 +2590,6 @@ var createStreamingResponse = async (model, aiSdkTools, messages, streamingConte
|
|
|
2587
2590
|
const name = chunk.chunk.toolName || chunk.chunk.name;
|
|
2588
2591
|
const parameters = chunk.chunk.input ?? chunk.chunk.parameters ?? chunk.chunk.args ?? {};
|
|
2589
2592
|
streamingContext.toolCallIdToName.set(currentToolCallId, name);
|
|
2590
|
-
if (!streamingContext.toolNameToCallIds.has(name)) {
|
|
2591
|
-
streamingContext.toolNameToCallIds.set(name, []);
|
|
2592
|
-
}
|
|
2593
|
-
streamingContext.toolNameToCallIds.get(name).push(currentToolCallId);
|
|
2594
2593
|
iterationToolCalls.push({ name, params: parameters });
|
|
2595
2594
|
sendSseEvent(
|
|
2596
2595
|
streamingContext.controller,
|
|
@@ -2610,36 +2609,9 @@ var createStreamingResponse = async (model, aiSdkTools, messages, streamingConte
|
|
|
2610
2609
|
}
|
|
2611
2610
|
case "tool-result": {
|
|
2612
2611
|
const result = chunk.chunk.output ?? chunk.chunk.result ?? chunk.chunk.value;
|
|
2613
|
-
const
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
const queue = streamingContext.toolNameToCallIds.get(toolName);
|
|
2617
|
-
if (queue && queue.length > 0) {
|
|
2618
|
-
currentToolCallId = queue.shift();
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
if (!currentToolCallId && streamingContext.lastEmittedToolCallId) {
|
|
2622
|
-
currentToolCallId = streamingContext.lastEmittedToolCallId;
|
|
2623
|
-
}
|
|
2624
|
-
if (!currentToolCallId) {
|
|
2625
|
-
currentToolCallId = `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2626
|
-
}
|
|
2627
|
-
if (toolName && streamingContext.toolNameToCallIds.has(toolName)) {
|
|
2628
|
-
const queue = streamingContext.toolNameToCallIds.get(toolName);
|
|
2629
|
-
const index = queue.indexOf(currentToolCallId);
|
|
2630
|
-
if (index !== -1) {
|
|
2631
|
-
queue.splice(index, 1);
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
streamingContext.lastEmittedToolCallId = currentToolCallId;
|
|
2635
|
-
if (toolName) {
|
|
2636
|
-
streamingContext.toolCallIdToName.set(
|
|
2637
|
-
currentToolCallId,
|
|
2638
|
-
toolName
|
|
2639
|
-
);
|
|
2640
|
-
}
|
|
2641
|
-
const toolNameForLookup = toolName || streamingContext.toolCallIdToName.get(currentToolCallId);
|
|
2642
|
-
const serverId = toolNameForLookup ? extractServerId(toolNameForLookup) : void 0;
|
|
2612
|
+
const currentToolCallId = streamingContext.lastEmittedToolCallId ?? `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2613
|
+
const toolName = streamingContext.toolCallIdToName.get(currentToolCallId);
|
|
2614
|
+
const serverId = toolName ? extractServerId(toolName) : void 0;
|
|
2643
2615
|
iterationToolResults.push({ result });
|
|
2644
2616
|
sendSseEvent(
|
|
2645
2617
|
streamingContext.controller,
|
|
@@ -2711,21 +2683,10 @@ var createStreamingResponse = async (model, aiSdkTools, messages, streamingConte
|
|
|
2711
2683
|
messageHistory.push(...responseMessages);
|
|
2712
2684
|
for (const m of responseMessages) {
|
|
2713
2685
|
if (m.role === "tool") {
|
|
2686
|
+
const currentToolCallId = streamingContext.lastEmittedToolCallId != null ? streamingContext.lastEmittedToolCallId : `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2714
2687
|
const value = m.content;
|
|
2715
|
-
const toolName =
|
|
2716
|
-
|
|
2717
|
-
if (toolName && streamingContext.toolNameToCallIds.has(toolName)) {
|
|
2718
|
-
const queue = streamingContext.toolNameToCallIds.get(toolName);
|
|
2719
|
-
if (queue.length > 0) {
|
|
2720
|
-
currentToolCallId = queue.shift();
|
|
2721
|
-
} else {
|
|
2722
|
-
currentToolCallId = streamingContext.lastEmittedToolCallId ?? `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2723
|
-
}
|
|
2724
|
-
} else {
|
|
2725
|
-
currentToolCallId = streamingContext.lastEmittedToolCallId ?? `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2726
|
-
}
|
|
2727
|
-
const toolNameForLookup = toolName || streamingContext.toolCallIdToName.get(currentToolCallId);
|
|
2728
|
-
const serverId = toolNameForLookup ? extractServerId(toolNameForLookup) : void 0;
|
|
2688
|
+
const toolName = streamingContext.toolCallIdToName.get(currentToolCallId);
|
|
2689
|
+
const serverId = toolName ? extractServerId(toolName) : void 0;
|
|
2729
2690
|
iterationToolResults.push({ result: value });
|
|
2730
2691
|
sendSseEvent(streamingContext.controller, streamingContext.encoder, {
|
|
2731
2692
|
type: "tool_result",
|
|
@@ -2815,10 +2776,6 @@ var sendMessagesToBackend = async (messages, streamingContext, mcpClientManager2
|
|
|
2815
2776
|
const currentToolCallId = `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2816
2777
|
streamingContext.lastEmittedToolCallId = currentToolCallId;
|
|
2817
2778
|
streamingContext.toolCallIdToName.set(currentToolCallId, call.name);
|
|
2818
|
-
if (!streamingContext.toolNameToCallIds.has(call.name)) {
|
|
2819
|
-
streamingContext.toolNameToCallIds.set(call.name, []);
|
|
2820
|
-
}
|
|
2821
|
-
streamingContext.toolNameToCallIds.get(call.name).push(currentToolCallId);
|
|
2822
2779
|
sendSseEvent(streamingContext.controller, streamingContext.encoder, {
|
|
2823
2780
|
type: "tool_call",
|
|
2824
2781
|
toolCall: {
|
|
@@ -2831,18 +2788,7 @@ var sendMessagesToBackend = async (messages, streamingContext, mcpClientManager2
|
|
|
2831
2788
|
});
|
|
2832
2789
|
};
|
|
2833
2790
|
const emitToolResult = (result) => {
|
|
2834
|
-
const
|
|
2835
|
-
let currentToolCallId;
|
|
2836
|
-
if (toolName && streamingContext.toolNameToCallIds.has(toolName)) {
|
|
2837
|
-
const queue = streamingContext.toolNameToCallIds.get(toolName);
|
|
2838
|
-
if (queue.length > 0) {
|
|
2839
|
-
currentToolCallId = queue.shift();
|
|
2840
|
-
} else {
|
|
2841
|
-
currentToolCallId = streamingContext.lastEmittedToolCallId ?? `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2842
|
-
}
|
|
2843
|
-
} else {
|
|
2844
|
-
currentToolCallId = streamingContext.lastEmittedToolCallId ?? `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2845
|
-
}
|
|
2791
|
+
const currentToolCallId = streamingContext.lastEmittedToolCallId != null ? streamingContext.lastEmittedToolCallId : `tc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2846
2792
|
sendSseEvent(streamingContext.controller, streamingContext.encoder, {
|
|
2847
2793
|
type: "tool_result",
|
|
2848
2794
|
toolResult: {
|
|
@@ -2995,8 +2941,7 @@ chat.post("/", async (c) => {
|
|
|
2995
2941
|
toolCallId: 0,
|
|
2996
2942
|
lastEmittedToolCallId: null,
|
|
2997
2943
|
stepIndex: 0,
|
|
2998
|
-
toolCallIdToName: /* @__PURE__ */ new Map()
|
|
2999
|
-
toolNameToCallIds: /* @__PURE__ */ new Map()
|
|
2944
|
+
toolCallIdToName: /* @__PURE__ */ new Map()
|
|
3000
2945
|
};
|
|
3001
2946
|
mcpClientManager2.setElicitationCallback(async (request) => {
|
|
3002
2947
|
const elicitationRequest = {
|
|
@@ -9019,7 +8964,7 @@ var isValidLlmApiKey = (key) => {
|
|
|
9019
8964
|
};
|
|
9020
8965
|
|
|
9021
8966
|
// ../evals-cli/src/utils/helpers.ts
|
|
9022
|
-
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
8967
|
+
import { createOpenRouter as createOpenRouter2 } from "@openrouter/ai-sdk-provider";
|
|
9023
8968
|
import { createOpenAI as createOpenAI2 } from "@ai-sdk/openai";
|
|
9024
8969
|
import { createAnthropic as createAnthropic2 } from "@ai-sdk/anthropic";
|
|
9025
8970
|
var createLlmModel2 = (provider, model, llmsConfig) => {
|
|
@@ -9032,7 +8977,7 @@ var createLlmModel2 = (provider, model, llmsConfig) => {
|
|
|
9032
8977
|
case "openai":
|
|
9033
8978
|
return createOpenAI2({ apiKey: llmsConfig.openai })(model);
|
|
9034
8979
|
case "openrouter":
|
|
9035
|
-
return
|
|
8980
|
+
return createOpenRouter2({ apiKey: llmsConfig.openrouter })(model);
|
|
9036
8981
|
default:
|
|
9037
8982
|
Logger.errorWithExit(`Unsupported provider: ${provider}`);
|
|
9038
8983
|
}
|
|
@@ -9530,7 +9475,7 @@ function transformServerConfigsToEnvironment(serverIds, clientManager) {
|
|
|
9530
9475
|
if (!config) {
|
|
9531
9476
|
throw new Error(`Server '${serverId}' not found`);
|
|
9532
9477
|
}
|
|
9533
|
-
const status = clientManager.
|
|
9478
|
+
const status = clientManager.getConnectionStatusByAttemptingPing(serverId);
|
|
9534
9479
|
if (status !== "connected") {
|
|
9535
9480
|
throw new Error(
|
|
9536
9481
|
`Server '${serverId}' is not connected (status: ${status})`
|
|
@@ -9727,7 +9672,7 @@ function resolveServerIdsOrThrow(requestedIds, clientManager) {
|
|
|
9727
9672
|
async function collectToolsForServers(clientManager, serverIds) {
|
|
9728
9673
|
const perServerTools = await Promise.all(
|
|
9729
9674
|
serverIds.map(async (serverId) => {
|
|
9730
|
-
if (clientManager.
|
|
9675
|
+
if (clientManager.getConnectionStatusByAttemptingPing(serverId) !== "connected") {
|
|
9731
9676
|
return [];
|
|
9732
9677
|
}
|
|
9733
9678
|
try {
|