diff --git a/cli/package.json b/cli/package.json index 841a023..53f2aa6 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/inspector-cli", - "version": "0.11.0", + "version": "0.12.0", "description": "CLI for the Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)", diff --git a/client/package.json b/client/package.json index 6ca90eb..2bcf2b0 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/inspector-client", - "version": "0.11.0", + "version": "0.12.0", "description": "Client-side application for the Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)", diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index 57efc63..4ced90e 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -2,8 +2,12 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { SSEClientTransport, SseError, + SSEClientTransportOptions, } from "@modelcontextprotocol/sdk/client/sse.js"; -import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; +import { + StreamableHTTPClientTransport, + StreamableHTTPClientTransportOptions, +} from "@modelcontextprotocol/sdk/client/streamableHttp.js"; import { ClientNotification, ClientRequest, @@ -279,29 +283,6 @@ export function useConnection({ setConnectionStatus("error-connecting-to-proxy"); return; } - let mcpProxyServerUrl; - switch (transportType) { - case "stdio": - mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/stdio`); - mcpProxyServerUrl.searchParams.append("command", command); - mcpProxyServerUrl.searchParams.append("args", args); - mcpProxyServerUrl.searchParams.append("env", JSON.stringify(env)); - break; - - case "sse": - mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/sse`); - mcpProxyServerUrl.searchParams.append("url", sseUrl); - break; - - case "streamable-http": - mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`); - mcpProxyServerUrl.searchParams.append("url", sseUrl); - break; - } - (mcpProxyServerUrl as URL).searchParams.append( - "transportType", - transportType, - ); try { // Inject auth manually instead of using SSEClientTransport, because we're @@ -320,21 +301,82 @@ export function useConnection({ } // Create appropriate transport - const transportOptions = { - eventSourceInit: { - fetch: ( - url: string | URL | globalThis.Request, - init: RequestInit | undefined, - ) => fetch(url, { ...init, headers }), - }, - requestInit: { - headers, - }, - }; + let transportOptions: + | StreamableHTTPClientTransportOptions + | SSEClientTransportOptions; + + let mcpProxyServerUrl; + switch (transportType) { + case "stdio": + mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/stdio`); + mcpProxyServerUrl.searchParams.append("command", command); + mcpProxyServerUrl.searchParams.append("args", args); + mcpProxyServerUrl.searchParams.append("env", JSON.stringify(env)); + transportOptions = { + authProvider: serverAuthProvider, + eventSourceInit: { + fetch: ( + url: string | URL | globalThis.Request, + init: RequestInit | undefined, + ) => fetch(url, { ...init, headers }), + }, + requestInit: { + headers, + }, + }; + break; + + case "sse": + mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/sse`); + mcpProxyServerUrl.searchParams.append("url", sseUrl); + transportOptions = { + authProvider: serverAuthProvider, + eventSourceInit: { + fetch: ( + url: string | URL | globalThis.Request, + init: RequestInit | undefined, + ) => fetch(url, { ...init, headers }), + }, + requestInit: { + headers, + }, + }; + break; + + case "streamable-http": + mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`); + mcpProxyServerUrl.searchParams.append("url", sseUrl); + transportOptions = { + authProvider: serverAuthProvider, + eventSourceInit: { + fetch: ( + url: string | URL | globalThis.Request, + init: RequestInit | undefined, + ) => fetch(url, { ...init, headers }), + }, + requestInit: { + headers, + }, + // TODO these should be configurable... + reconnectionOptions: { + maxReconnectionDelay: 30000, + initialReconnectionDelay: 1000, + reconnectionDelayGrowFactor: 1.5, + maxRetries: 2, + }, + }; + break; + } + (mcpProxyServerUrl as URL).searchParams.append( + "transportType", + transportType, + ); + const clientTransport = transportType === "streamable-http" ? new StreamableHTTPClientTransport(mcpProxyServerUrl as URL, { sessionId: undefined, + ...transportOptions, }) : new SSEClientTransport(mcpProxyServerUrl as URL, transportOptions); diff --git a/package-lock.json b/package-lock.json index ed7f0aa..eb373c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@modelcontextprotocol/inspector", - "version": "0.11.0", + "version": "0.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@modelcontextprotocol/inspector", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "workspaces": [ "client", @@ -14,9 +14,9 @@ "cli" ], "dependencies": { - "@modelcontextprotocol/inspector-cli": "^0.11.0", - "@modelcontextprotocol/inspector-client": "^0.11.0", - "@modelcontextprotocol/inspector-server": "^0.11.0", + "@modelcontextprotocol/inspector-cli": "^0.12.0", + "@modelcontextprotocol/inspector-client": "^0.12.0", + "@modelcontextprotocol/inspector-server": "^0.12.0", "@modelcontextprotocol/sdk": "^1.11.0", "concurrently": "^9.0.1", "shell-quote": "^1.8.2", @@ -39,7 +39,7 @@ }, "cli": { "name": "@modelcontextprotocol/inspector-cli", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.10.2", @@ -62,7 +62,7 @@ }, "client": { "name": "@modelcontextprotocol/inspector-client", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.10.2", @@ -10793,7 +10793,7 @@ }, "server": { "name": "@modelcontextprotocol/inspector-server", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.10.2", diff --git a/package.json b/package.json index d67b199..5e92409 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/inspector", - "version": "0.11.0", + "version": "0.12.0", "description": "Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)", @@ -40,9 +40,9 @@ "publish-all": "npm publish --workspaces --access public && npm publish --access public" }, "dependencies": { - "@modelcontextprotocol/inspector-cli": "^0.11.0", - "@modelcontextprotocol/inspector-client": "^0.11.0", - "@modelcontextprotocol/inspector-server": "^0.11.0", + "@modelcontextprotocol/inspector-cli": "^0.12.0", + "@modelcontextprotocol/inspector-client": "^0.12.0", + "@modelcontextprotocol/inspector-server": "^0.12.0", "@modelcontextprotocol/sdk": "^1.11.0", "concurrently": "^9.0.1", "shell-quote": "^1.8.2", diff --git a/server/package.json b/server/package.json index 24162da..72723d3 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/inspector-server", - "version": "0.11.0", + "version": "0.12.0", "description": "Server-side application for the Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)",