@@ -28,6 +28,7 @@ import {
2828 ToolListChangedNotificationSchema ,
2929 PromptListChangedNotificationSchema ,
3030 Progress ,
31+ LoggingLevel ,
3132 ElicitRequestSchema ,
3233} from "@modelcontextprotocol/sdk/types.js" ;
3334import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js" ;
@@ -72,6 +73,7 @@ interface UseConnectionOptions {
7273 onElicitationRequest ?: ( request : any , resolve : any ) => void ;
7374 // eslint-disable-next-line @typescript-eslint/no-explicit-any
7475 getRoots ?: ( ) => any [ ] ;
76+ defaultLoggingLevel ?: LoggingLevel ;
7577}
7678
7779export function useConnection ( {
@@ -90,6 +92,7 @@ export function useConnection({
9092 onPendingRequest,
9193 onElicitationRequest,
9294 getRoots,
95+ defaultLoggingLevel,
9396} : UseConnectionOptions ) {
9497 const [ connectionStatus , setConnectionStatus ] =
9598 useState < ConnectionStatus > ( "disconnected" ) ;
@@ -560,6 +563,10 @@ export function useConnection({
560563 } ) ;
561564 }
562565
566+ if ( capabilities ?. logging && defaultLoggingLevel ) {
567+ await client . setLoggingLevel ( defaultLoggingLevel ) ;
568+ }
569+
563570 if ( onElicitationRequest ) {
564571 client . setRequestHandler ( ElicitRequestSchema , async ( request ) => {
565572 return new Promise ( ( resolve ) => {
0 commit comments