initalize logging for UI
This commit is contained in:
parent
3acc6d891c
commit
925d11a91d
2 changed files with 8 additions and 0 deletions
|
|
@ -204,6 +204,7 @@ const App = () => {
|
|||
]);
|
||||
},
|
||||
getRoots: () => rootsRef.current,
|
||||
defaultLoggingLevel: "debug"
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -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<ConnectionStatus>("disconnected");
|
||||
|
|
@ -521,6 +524,10 @@ export function useConnection({
|
|||
});
|
||||
}
|
||||
|
||||
if (capabilities?.logging && defaultLoggingLevel) {
|
||||
await client.setLoggingLevel(defaultLoggingLevel);
|
||||
}
|
||||
|
||||
setMcpClient(client);
|
||||
setConnectionStatus("connected");
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue