mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
fix: apply timeout configuration to all MCP client requests
- Added timeout parameter to readResource method - Added timeout parameter to fetchToolsList method - Added timeout parameter to fetchResourcesList method - Added timeout parameter to fetchResourceTemplatesList method Previously, only the callTool method was using the configured timeout, causing other MCP operations to use the default 30-second timeout instead of the user-configured value. Fixes #7836
This commit is contained in:
parent
48d592f433
commit
b57252210e
1 changed files with 55 additions and 2 deletions
|
|
@ -911,7 +911,19 @@ export class McpHub {
|
|||
return []
|
||||
}
|
||||
|
||||
const response = await connection.client.request({ method: "tools/list" }, ListToolsResultSchema)
|
||||
let timeout: number
|
||||
try {
|
||||
const parsedConfig = ServerConfigSchema.parse(JSON.parse(connection.server.config))
|
||||
timeout = (parsedConfig.timeout ?? 60) * 1000
|
||||
} catch (error) {
|
||||
console.error("Failed to parse server config for timeout:", error)
|
||||
// Default to 60 seconds if parsing fails
|
||||
timeout = 60 * 1000
|
||||
}
|
||||
|
||||
const response = await connection.client.request({ method: "tools/list" }, ListToolsResultSchema, {
|
||||
timeout,
|
||||
})
|
||||
|
||||
// Determine the actual source of the server
|
||||
const actualSource = connection.server.source || "global"
|
||||
|
|
@ -965,7 +977,20 @@ export class McpHub {
|
|||
if (!connection || connection.type !== "connected") {
|
||||
return []
|
||||
}
|
||||
const response = await connection.client.request({ method: "resources/list" }, ListResourcesResultSchema)
|
||||
|
||||
let timeout: number
|
||||
try {
|
||||
const parsedConfig = ServerConfigSchema.parse(JSON.parse(connection.server.config))
|
||||
timeout = (parsedConfig.timeout ?? 60) * 1000
|
||||
} catch (error) {
|
||||
console.error("Failed to parse server config for timeout:", error)
|
||||
// Default to 60 seconds if parsing fails
|
||||
timeout = 60 * 1000
|
||||
}
|
||||
|
||||
const response = await connection.client.request({ method: "resources/list" }, ListResourcesResultSchema, {
|
||||
timeout,
|
||||
})
|
||||
return response?.resources || []
|
||||
} catch (error) {
|
||||
// console.error(`Failed to fetch resources for ${serverName}:`, error)
|
||||
|
|
@ -982,9 +1007,23 @@ export class McpHub {
|
|||
if (!connection || connection.type !== "connected") {
|
||||
return []
|
||||
}
|
||||
|
||||
let timeout: number
|
||||
try {
|
||||
const parsedConfig = ServerConfigSchema.parse(JSON.parse(connection.server.config))
|
||||
timeout = (parsedConfig.timeout ?? 60) * 1000
|
||||
} catch (error) {
|
||||
console.error("Failed to parse server config for timeout:", error)
|
||||
// Default to 60 seconds if parsing fails
|
||||
timeout = 60 * 1000
|
||||
}
|
||||
|
||||
const response = await connection.client.request(
|
||||
{ method: "resources/templates/list" },
|
||||
ListResourceTemplatesResultSchema,
|
||||
{
|
||||
timeout,
|
||||
},
|
||||
)
|
||||
return response?.resourceTemplates || []
|
||||
} catch (error) {
|
||||
|
|
@ -1564,6 +1603,17 @@ export class McpHub {
|
|||
if (connection.server.disabled) {
|
||||
throw new Error(`Server "${serverName}" is disabled`)
|
||||
}
|
||||
|
||||
let timeout: number
|
||||
try {
|
||||
const parsedConfig = ServerConfigSchema.parse(JSON.parse(connection.server.config))
|
||||
timeout = (parsedConfig.timeout ?? 60) * 1000
|
||||
} catch (error) {
|
||||
console.error("Failed to parse server config for timeout:", error)
|
||||
// Default to 60 seconds if parsing fails
|
||||
timeout = 60 * 1000
|
||||
}
|
||||
|
||||
return await connection.client.request(
|
||||
{
|
||||
method: "resources/read",
|
||||
|
|
@ -1572,6 +1622,9 @@ export class McpHub {
|
|||
},
|
||||
},
|
||||
ReadResourceResultSchema,
|
||||
{
|
||||
timeout,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue