Skip to content

Commit 925d11a

Browse files
author
oleina
committed
initalize logging for UI
1 parent 3acc6d8 commit 925d11a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

client/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const App = () => {
204204
]);
205205
},
206206
getRoots: () => rootsRef.current,
207+
defaultLoggingLevel: "debug"
207208
});
208209

209210
useEffect(() => {

client/src/lib/hooks/useConnection.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
ToolListChangedNotificationSchema,
2929
PromptListChangedNotificationSchema,
3030
Progress,
31+
LoggingLevel,
3132
} from "@modelcontextprotocol/sdk/types.js";
3233
import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
3334
import { useState } from "react";
@@ -63,6 +64,7 @@ interface UseConnectionOptions {
6364
onPendingRequest?: (request: any, resolve: any, reject: any) => void;
6465
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6566
getRoots?: () => any[];
67+
defaultLoggingLevel?: LoggingLevel,
6668
}
6769

6870
export function useConnection({
@@ -78,6 +80,7 @@ export function useConnection({
7880
onStdErrNotification,
7981
onPendingRequest,
8082
getRoots,
83+
defaultLoggingLevel,
8184
}: UseConnectionOptions) {
8285
const [connectionStatus, setConnectionStatus] =
8386
useState<ConnectionStatus>("disconnected");
@@ -521,6 +524,10 @@ export function useConnection({
521524
});
522525
}
523526

527+
if (capabilities?.logging && defaultLoggingLevel) {
528+
await client.setLoggingLevel(defaultLoggingLevel);
529+
}
530+
524531
setMcpClient(client);
525532
setConnectionStatus("connected");
526533
} catch (e) {

0 commit comments

Comments
 (0)