diff --git a/client/src/lib/hooks/__tests__/useConnection.test.tsx b/client/src/lib/hooks/__tests__/useConnection.test.tsx index 1671b70..c1d67d7 100644 --- a/client/src/lib/hooks/__tests__/useConnection.test.tsx +++ b/client/src/lib/hooks/__tests__/useConnection.test.tsx @@ -17,6 +17,8 @@ const mockClient = { connect: jest.fn().mockResolvedValue(undefined), close: jest.fn(), getServerCapabilities: jest.fn(), + getServerVersion: jest.fn(), + getInstructions: jest.fn(), setNotificationHandler: jest.fn(), setRequestHandler: jest.fn(), }; diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index d5d7070..485e8e3 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -335,8 +335,19 @@ export function useConnection({ ); } + let capabilities; try { await client.connect(clientTransport); + + capabilities = client.getServerCapabilities(); + const initializeRequest = { + method: "initialize", + }; + pushHistory(initializeRequest, { + capabilities, + serverInfo: client.getServerVersion(), + instructions: client.getInstructions(), + }); } catch (error) { console.error( `Failed to connect to MCP Server via the MCP Inspector Proxy: ${mcpProxyServerUrl}:`, @@ -353,8 +364,6 @@ export function useConnection({ } throw error; } - - const capabilities = client.getServerCapabilities(); setServerCapabilities(capabilities ?? null); setCompletionsSupported(true); // Reset completions support on new connection