From 925d11a91dc7fd61c95d45006a2226ee59497788 Mon Sep 17 00:00:00 2001 From: oleina Date: Fri, 11 Jul 2025 11:18:01 -0700 Subject: [PATCH 1/5] initalize logging for UI --- client/src/App.tsx | 1 + client/src/lib/hooks/useConnection.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/client/src/App.tsx b/client/src/App.tsx index cff51b4ff..bef4ec4e6 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -204,6 +204,7 @@ const App = () => { ]); }, getRoots: () => rootsRef.current, + defaultLoggingLevel: "debug" }); useEffect(() => { diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index 9009e698f..1ef551546 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -28,6 +28,7 @@ import { ToolListChangedNotificationSchema, PromptListChangedNotificationSchema, Progress, + LoggingLevel, } from "@modelcontextprotocol/sdk/types.js"; import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js"; import { useState } from "react"; @@ -63,6 +64,7 @@ interface UseConnectionOptions { onPendingRequest?: (request: any, resolve: any, reject: any) => void; // eslint-disable-next-line @typescript-eslint/no-explicit-any getRoots?: () => any[]; + defaultLoggingLevel?: LoggingLevel, } export function useConnection({ @@ -78,6 +80,7 @@ export function useConnection({ onStdErrNotification, onPendingRequest, getRoots, + defaultLoggingLevel, }: UseConnectionOptions) { const [connectionStatus, setConnectionStatus] = useState("disconnected"); @@ -521,6 +524,10 @@ export function useConnection({ }); } + if (capabilities?.logging && defaultLoggingLevel) { + await client.setLoggingLevel(defaultLoggingLevel); + } + setMcpClient(client); setConnectionStatus("connected"); } catch (e) { From f4d9bf6d5ee9cb00fa4a04f12a6e48230b7dc58f Mon Sep 17 00:00:00 2001 From: oleina Date: Fri, 11 Jul 2025 11:18:01 -0700 Subject: [PATCH 2/5] initalize logging for cli mode --- cli/src/client/connection.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/src/client/connection.ts b/cli/src/client/connection.ts index 931f803da..dcbe8e518 100644 --- a/cli/src/client/connection.ts +++ b/cli/src/client/connection.ts @@ -18,6 +18,12 @@ export async function connect( ): Promise { try { await client.connect(transport); + + if (client.getServerCapabilities()?.logging) { + // default logging level is undefined in the spec, but the user of the + // inspector most likely wants debug. + await client.setLoggingLevel("debug"); + } } catch (error) { throw new Error( `Failed to connect to MCP server: ${error instanceof Error ? error.message : String(error)}`, From d810680b93fc6b64feb6ef652ddd0df8277152b6 Mon Sep 17 00:00:00 2001 From: oleina Date: Mon, 14 Jul 2025 07:57:58 -0700 Subject: [PATCH 3/5] use default logging level from useState --- client/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index bef4ec4e6..594640356 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -204,7 +204,7 @@ const App = () => { ]); }, getRoots: () => rootsRef.current, - defaultLoggingLevel: "debug" + defaultLoggingLevel: logLevel }); useEffect(() => { From 7ce0938e2713ef2d4513fa6f4224a8482e5b996d Mon Sep 17 00:00:00 2001 From: oleina Date: Mon, 14 Jul 2025 08:00:13 -0700 Subject: [PATCH 4/5] run linter --- client/src/App.tsx | 2 +- client/src/lib/hooks/useConnection.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 594640356..c80cfd351 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -204,7 +204,7 @@ const App = () => { ]); }, getRoots: () => rootsRef.current, - defaultLoggingLevel: logLevel + defaultLoggingLevel: logLevel, }); useEffect(() => { diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index 1ef551546..b32552f49 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -64,7 +64,7 @@ interface UseConnectionOptions { onPendingRequest?: (request: any, resolve: any, reject: any) => void; // eslint-disable-next-line @typescript-eslint/no-explicit-any getRoots?: () => any[]; - defaultLoggingLevel?: LoggingLevel, + defaultLoggingLevel?: LoggingLevel; } export function useConnection({ From eec20ff1fcfb63391ad452a89a4e4677541e1335 Mon Sep 17 00:00:00 2001 From: oleina Date: Thu, 31 Jul 2025 10:20:47 -0700 Subject: [PATCH 5/5] add missing close bracket --- client/src/lib/hooks/useConnection.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index 268ba8ff4..78dfa6df6 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -565,6 +565,7 @@ export function useConnection({ if (capabilities?.logging && defaultLoggingLevel) { await client.setLoggingLevel(defaultLoggingLevel); + } if (onElicitationRequest) { client.setRequestHandler(ElicitRequestSchema, async (request) => {