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,
|
getRoots: () => rootsRef.current,
|
||||||
|
defaultLoggingLevel: "debug"
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import {
|
||||||
ToolListChangedNotificationSchema,
|
ToolListChangedNotificationSchema,
|
||||||
PromptListChangedNotificationSchema,
|
PromptListChangedNotificationSchema,
|
||||||
Progress,
|
Progress,
|
||||||
|
LoggingLevel,
|
||||||
} from "@modelcontextprotocol/sdk/types.js";
|
} from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
@ -63,6 +64,7 @@ interface UseConnectionOptions {
|
||||||
onPendingRequest?: (request: any, resolve: any, reject: any) => void;
|
onPendingRequest?: (request: any, resolve: any, reject: any) => void;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
getRoots?: () => any[];
|
getRoots?: () => any[];
|
||||||
|
defaultLoggingLevel?: LoggingLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useConnection({
|
export function useConnection({
|
||||||
|
|
@ -78,6 +80,7 @@ export function useConnection({
|
||||||
onStdErrNotification,
|
onStdErrNotification,
|
||||||
onPendingRequest,
|
onPendingRequest,
|
||||||
getRoots,
|
getRoots,
|
||||||
|
defaultLoggingLevel,
|
||||||
}: UseConnectionOptions) {
|
}: UseConnectionOptions) {
|
||||||
const [connectionStatus, setConnectionStatus] =
|
const [connectionStatus, setConnectionStatus] =
|
||||||
useState<ConnectionStatus>("disconnected");
|
useState<ConnectionStatus>("disconnected");
|
||||||
|
|
@ -521,6 +524,10 @@ export function useConnection({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (capabilities?.logging && defaultLoggingLevel) {
|
||||||
|
await client.setLoggingLevel(defaultLoggingLevel);
|
||||||
|
}
|
||||||
|
|
||||||
setMcpClient(client);
|
setMcpClient(client);
|
||||||
setConnectionStatus("connected");
|
setConnectionStatus("connected");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue