From 9182889b15df6f492cdb15aa61ce00edd9905dc1 Mon Sep 17 00:00:00 2001 From: shusingh Date: Tue, 19 May 2026 17:54:41 -0700 Subject: [PATCH] Expose MCP protocol version --- client/src/App.tsx | 2 ++ client/src/components/Sidebar.tsx | 7 +++++ .../hooks/__tests__/useConnection.test.tsx | 28 +++++++++++++++++++ client/src/lib/hooks/useConnection.ts | 1 + 4 files changed, 38 insertions(+) diff --git a/client/src/App.tsx b/client/src/App.tsx index 59d15ba06..39fc897d2 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -374,6 +374,7 @@ const App = () => { const { connectionStatus, serverCapabilities, + mcpProtocolVersion, serverImplementation, mcpClient, requestHistory, @@ -1342,6 +1343,7 @@ const App = () => { connectionType={connectionType} setConnectionType={setConnectionType} serverImplementation={serverImplementation} + mcpProtocolVersion={mcpProtocolVersion} />
{ const [theme, setTheme] = useTheme(); const [showEnvVars, setShowEnvVars] = useState(false); @@ -847,6 +849,11 @@ const Sidebar = ({ Version: {serverImplementation.version}
)} + {mcpProtocolVersion && ( +
+ Protocol: {mcpProtocolVersion} +
+ )} ); })()} diff --git a/client/src/lib/hooks/__tests__/useConnection.test.tsx b/client/src/lib/hooks/__tests__/useConnection.test.tsx index 1d4f4bd0f..dd54df42d 100644 --- a/client/src/lib/hooks/__tests__/useConnection.test.tsx +++ b/client/src/lib/hooks/__tests__/useConnection.test.tsx @@ -1213,6 +1213,34 @@ describe("useConnection", () => { mockStreamableHTTPTransport.options?.requestInit?.headers, ).toHaveProperty("X-MCP-Proxy-Auth", "Bearer test-proxy-token"); }); + + test("exposes negotiated protocol version from response headers", async () => { + const response = { + headers: { + get: jest.fn((name: string) => + name === "mcp-protocol-version" ? "2025-06-18" : null, + ), + }, + } as unknown as Response; + (global.fetch as jest.Mock).mockResolvedValueOnce(response); + + const { result } = renderHook(() => + useConnection({ + ...defaultProps, + connectionType: "direct", + }), + ); + + await act(async () => { + await result.current.connect(); + }); + + await act(async () => { + await mockSSETransport.options?.fetch?.("http://localhost:8080"); + }); + + expect(result.current.mcpProtocolVersion).toBe("2025-06-18"); + }); }); describe("Custom Headers", () => { diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index 016f8aa4f..7a6bad2e4 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -1200,6 +1200,7 @@ export function useConnection({ return { connectionStatus, serverCapabilities, + mcpProtocolVersion, serverImplementation, mcpClient, requestHistory,