Skip to content

Commit 22eb813

Browse files
committed
feat: Show initialize request/response in History panel (modelcontextprotocol#269)
- Add logging for initialize request and response in useConnection.connect - Include server capabilities, version, and instructions in history
1 parent 0b37722 commit 22eb813

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

client/src/lib/hooks/__tests__/useConnection.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const mockClient = {
1717
connect: jest.fn().mockResolvedValue(undefined),
1818
close: jest.fn(),
1919
getServerCapabilities: jest.fn(),
20+
getServerVersion: jest.fn(),
21+
getInstructions: jest.fn(),
2022
setNotificationHandler: jest.fn(),
2123
setRequestHandler: jest.fn(),
2224
};

client/src/lib/hooks/useConnection.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,19 @@ export function useConnection({
335335
);
336336
}
337337

338+
let capabilities;
338339
try {
339340
await client.connect(clientTransport);
341+
342+
capabilities = client.getServerCapabilities();
343+
const initializeRequest = {
344+
method: "initialize",
345+
};
346+
pushHistory(initializeRequest, {
347+
capabilities,
348+
serverInfo: client.getServerVersion(),
349+
instructions: client.getInstructions(),
350+
});
340351
} catch (error) {
341352
console.error(
342353
`Failed to connect to MCP Server via the MCP Inspector Proxy: ${mcpProxyServerUrl}:`,
@@ -353,8 +364,6 @@ export function useConnection({
353364
}
354365
throw error;
355366
}
356-
357-
const capabilities = client.getServerCapabilities();
358367
setServerCapabilities(capabilities ?? null);
359368
setCompletionsSupported(true); // Reset completions support on new connection
360369

0 commit comments

Comments
 (0)