Skip to content

Commit 0c15c54

Browse files
authored
Merge branch 'main' into feat/yizhi
2 parents 8373795 + 24e8861 commit 0c15c54

File tree

6 files changed

+92
-50
lines changed

6 files changed

+92
-50
lines changed

cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/inspector-cli",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "CLI for the Model Context Protocol inspector",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/inspector-client",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "Client-side application for the Model Context Protocol inspector",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",

client/src/lib/hooks/useConnection.ts

Lines changed: 77 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
22
import {
33
SSEClientTransport,
44
SseError,
5+
SSEClientTransportOptions,
56
} from "@modelcontextprotocol/sdk/client/sse.js";
6-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
7+
import {
8+
StreamableHTTPClientTransport,
9+
StreamableHTTPClientTransportOptions,
10+
} from "@modelcontextprotocol/sdk/client/streamableHttp.js";
711
import {
812
ClientNotification,
913
ClientRequest,
@@ -279,29 +283,6 @@ export function useConnection({
279283
setConnectionStatus("error-connecting-to-proxy");
280284
return;
281285
}
282-
let mcpProxyServerUrl;
283-
switch (transportType) {
284-
case "stdio":
285-
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/stdio`);
286-
mcpProxyServerUrl.searchParams.append("command", command);
287-
mcpProxyServerUrl.searchParams.append("args", args);
288-
mcpProxyServerUrl.searchParams.append("env", JSON.stringify(env));
289-
break;
290-
291-
case "sse":
292-
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/sse`);
293-
mcpProxyServerUrl.searchParams.append("url", sseUrl);
294-
break;
295-
296-
case "streamable-http":
297-
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`);
298-
mcpProxyServerUrl.searchParams.append("url", sseUrl);
299-
break;
300-
}
301-
(mcpProxyServerUrl as URL).searchParams.append(
302-
"transportType",
303-
transportType,
304-
);
305286

306287
try {
307288
// Inject auth manually instead of using SSEClientTransport, because we're
@@ -320,21 +301,82 @@ export function useConnection({
320301
}
321302

322303
// Create appropriate transport
323-
const transportOptions = {
324-
eventSourceInit: {
325-
fetch: (
326-
url: string | URL | globalThis.Request,
327-
init: RequestInit | undefined,
328-
) => fetch(url, { ...init, headers }),
329-
},
330-
requestInit: {
331-
headers,
332-
},
333-
};
304+
let transportOptions:
305+
| StreamableHTTPClientTransportOptions
306+
| SSEClientTransportOptions;
307+
308+
let mcpProxyServerUrl;
309+
switch (transportType) {
310+
case "stdio":
311+
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/stdio`);
312+
mcpProxyServerUrl.searchParams.append("command", command);
313+
mcpProxyServerUrl.searchParams.append("args", args);
314+
mcpProxyServerUrl.searchParams.append("env", JSON.stringify(env));
315+
transportOptions = {
316+
authProvider: serverAuthProvider,
317+
eventSourceInit: {
318+
fetch: (
319+
url: string | URL | globalThis.Request,
320+
init: RequestInit | undefined,
321+
) => fetch(url, { ...init, headers }),
322+
},
323+
requestInit: {
324+
headers,
325+
},
326+
};
327+
break;
328+
329+
case "sse":
330+
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/sse`);
331+
mcpProxyServerUrl.searchParams.append("url", sseUrl);
332+
transportOptions = {
333+
authProvider: serverAuthProvider,
334+
eventSourceInit: {
335+
fetch: (
336+
url: string | URL | globalThis.Request,
337+
init: RequestInit | undefined,
338+
) => fetch(url, { ...init, headers }),
339+
},
340+
requestInit: {
341+
headers,
342+
},
343+
};
344+
break;
345+
346+
case "streamable-http":
347+
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`);
348+
mcpProxyServerUrl.searchParams.append("url", sseUrl);
349+
transportOptions = {
350+
authProvider: serverAuthProvider,
351+
eventSourceInit: {
352+
fetch: (
353+
url: string | URL | globalThis.Request,
354+
init: RequestInit | undefined,
355+
) => fetch(url, { ...init, headers }),
356+
},
357+
requestInit: {
358+
headers,
359+
},
360+
// TODO these should be configurable...
361+
reconnectionOptions: {
362+
maxReconnectionDelay: 30000,
363+
initialReconnectionDelay: 1000,
364+
reconnectionDelayGrowFactor: 1.5,
365+
maxRetries: 2,
366+
},
367+
};
368+
break;
369+
}
370+
(mcpProxyServerUrl as URL).searchParams.append(
371+
"transportType",
372+
transportType,
373+
);
374+
334375
const clientTransport =
335376
transportType === "streamable-http"
336377
? new StreamableHTTPClientTransport(mcpProxyServerUrl as URL, {
337378
sessionId: undefined,
379+
...transportOptions,
338380
})
339381
: new SSEClientTransport(mcpProxyServerUrl as URL, transportOptions);
340382

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/inspector",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "Model Context Protocol inspector",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",
@@ -40,9 +40,9 @@
4040
"publish-all": "npm publish --workspaces --access public && npm publish --access public"
4141
},
4242
"dependencies": {
43-
"@modelcontextprotocol/inspector-cli": "^0.11.0",
44-
"@modelcontextprotocol/inspector-client": "^0.11.0",
45-
"@modelcontextprotocol/inspector-server": "^0.11.0",
43+
"@modelcontextprotocol/inspector-cli": "^0.12.0",
44+
"@modelcontextprotocol/inspector-client": "^0.12.0",
45+
"@modelcontextprotocol/inspector-server": "^0.12.0",
4646
"@modelcontextprotocol/sdk": "^1.11.0",
4747
"concurrently": "^9.0.1",
4848
"shell-quote": "^1.8.2",

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/inspector-server",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "Server-side application for the Model Context Protocol inspector",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",

0 commit comments

Comments
 (0)