@@ -911,7 +911,19 @@ export class McpHub {
911911 return [ ]
912912 }
913913
914- const response = await connection . client . request ( { method : "tools/list" } , ListToolsResultSchema )
914+ let timeout : number
915+ try {
916+ const parsedConfig = ServerConfigSchema . parse ( JSON . parse ( connection . server . config ) )
917+ timeout = ( parsedConfig . timeout ?? 60 ) * 1000
918+ } catch ( error ) {
919+ console . error ( "Failed to parse server config for timeout:" , error )
920+ // Default to 60 seconds if parsing fails
921+ timeout = 60 * 1000
922+ }
923+
924+ const response = await connection . client . request ( { method : "tools/list" } , ListToolsResultSchema , {
925+ timeout,
926+ } )
915927
916928 // Determine the actual source of the server
917929 const actualSource = connection . server . source || "global"
@@ -965,7 +977,20 @@ export class McpHub {
965977 if ( ! connection || connection . type !== "connected" ) {
966978 return [ ]
967979 }
968- const response = await connection . client . request ( { method : "resources/list" } , ListResourcesResultSchema )
980+
981+ let timeout : number
982+ try {
983+ const parsedConfig = ServerConfigSchema . parse ( JSON . parse ( connection . server . config ) )
984+ timeout = ( parsedConfig . timeout ?? 60 ) * 1000
985+ } catch ( error ) {
986+ console . error ( "Failed to parse server config for timeout:" , error )
987+ // Default to 60 seconds if parsing fails
988+ timeout = 60 * 1000
989+ }
990+
991+ const response = await connection . client . request ( { method : "resources/list" } , ListResourcesResultSchema , {
992+ timeout,
993+ } )
969994 return response ?. resources || [ ]
970995 } catch ( error ) {
971996 // console.error(`Failed to fetch resources for ${serverName}:`, error)
@@ -982,9 +1007,23 @@ export class McpHub {
9821007 if ( ! connection || connection . type !== "connected" ) {
9831008 return [ ]
9841009 }
1010+
1011+ let timeout : number
1012+ try {
1013+ const parsedConfig = ServerConfigSchema . parse ( JSON . parse ( connection . server . config ) )
1014+ timeout = ( parsedConfig . timeout ?? 60 ) * 1000
1015+ } catch ( error ) {
1016+ console . error ( "Failed to parse server config for timeout:" , error )
1017+ // Default to 60 seconds if parsing fails
1018+ timeout = 60 * 1000
1019+ }
1020+
9851021 const response = await connection . client . request (
9861022 { method : "resources/templates/list" } ,
9871023 ListResourceTemplatesResultSchema ,
1024+ {
1025+ timeout,
1026+ } ,
9881027 )
9891028 return response ?. resourceTemplates || [ ]
9901029 } catch ( error ) {
@@ -1564,6 +1603,17 @@ export class McpHub {
15641603 if ( connection . server . disabled ) {
15651604 throw new Error ( `Server "${ serverName } " is disabled` )
15661605 }
1606+
1607+ let timeout : number
1608+ try {
1609+ const parsedConfig = ServerConfigSchema . parse ( JSON . parse ( connection . server . config ) )
1610+ timeout = ( parsedConfig . timeout ?? 60 ) * 1000
1611+ } catch ( error ) {
1612+ console . error ( "Failed to parse server config for timeout:" , error )
1613+ // Default to 60 seconds if parsing fails
1614+ timeout = 60 * 1000
1615+ }
1616+
15671617 return await connection . client . request (
15681618 {
15691619 method : "resources/read" ,
@@ -1572,6 +1622,9 @@ export class McpHub {
15721622 } ,
15731623 } ,
15741624 ReadResourceResultSchema ,
1625+ {
1626+ timeout,
1627+ } ,
15751628 )
15761629 }
15771630
0 commit comments