@@ -571,25 +571,28 @@ export namespace MCP {
571571 const clientsSnapshot = await clients ( )
572572 const defaultTimeout = cfg . experimental ?. mcp_timeout
573573
574- for ( const [ clientName , client ] of Object . entries ( clientsSnapshot ) ) {
575- // Only include tools from connected MCPs (skip disabled ones)
576- if ( s . status [ clientName ] ?. status !== "connected" ) {
577- continue
578- }
574+ const connectedClients = Object . entries ( clientsSnapshot ) . filter (
575+ ( [ clientName ] ) => s . status [ clientName ] ?. status === "connected" ,
576+ )
579577
580- const toolsResult = await client . listTools ( ) . catch ( ( e ) => {
581- log . error ( "failed to get tools" , { clientName, error : e . message } )
582- const failedStatus = {
583- status : "failed" as const ,
584- error : e instanceof Error ? e . message : String ( e ) ,
585- }
586- s . status [ clientName ] = failedStatus
587- delete s . clients [ clientName ]
588- return undefined
589- } )
590- if ( ! toolsResult ) {
591- continue
592- }
578+ const toolsResults = await Promise . all (
579+ connectedClients . map ( async ( [ clientName , client ] ) => {
580+ const toolsResult = await client . listTools ( ) . catch ( ( e ) => {
581+ log . error ( "failed to get tools" , { clientName, error : e . message } )
582+ const failedStatus = {
583+ status : "failed" as const ,
584+ error : e instanceof Error ? e . message : String ( e ) ,
585+ }
586+ s . status [ clientName ] = failedStatus
587+ delete s . clients [ clientName ]
588+ return undefined
589+ } )
590+ return { clientName, client, toolsResult }
591+ } ) ,
592+ )
593+
594+ for ( const { clientName, client, toolsResult } of toolsResults ) {
595+ if ( ! toolsResult ) continue
593596 const mcpConfig = config [ clientName ]
594597 const entry = isMcpConfigured ( mcpConfig ) ? mcpConfig : undefined
595598 const timeout = entry ?. timeout ?? defaultTimeout
0 commit comments