mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 14:04:41 -07:00
Simplify MCP server timeout configuration (#7661)
This commit is contained in:
@@ -644,7 +644,9 @@ export async function discoverTools(
|
||||
cliConfig: Config,
|
||||
): Promise<DiscoveredMCPTool[]> {
|
||||
try {
|
||||
const mcpCallableTool = mcpToTool(mcpClient);
|
||||
const mcpCallableTool = mcpToTool(mcpClient, {
|
||||
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
||||
});
|
||||
const tool = await mcpCallableTool.tool();
|
||||
|
||||
if (!Array.isArray(tool.functionDeclarations)) {
|
||||
@@ -675,7 +677,6 @@ export async function discoverTools(
|
||||
funcDecl.name!,
|
||||
funcDecl.description ?? '',
|
||||
funcDecl.parametersJsonSchema ?? { type: 'object', properties: {} },
|
||||
mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
||||
mcpServerConfig.trust,
|
||||
undefined,
|
||||
cliConfig,
|
||||
@@ -871,18 +872,6 @@ export async function connectToMcpServer(
|
||||
unlistenDirectories = undefined;
|
||||
};
|
||||
|
||||
// patch Client.callTool to use request timeout as genai McpCallTool.callTool does not do it
|
||||
// TODO: remove this hack once GenAI SDK does callTool with request options
|
||||
if ('callTool' in mcpClient) {
|
||||
const origCallTool = mcpClient.callTool.bind(mcpClient);
|
||||
mcpClient.callTool = function (params, resultSchema, options) {
|
||||
return origCallTool(params, resultSchema, {
|
||||
...options,
|
||||
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const transport = await createTransport(
|
||||
mcpServerName,
|
||||
|
||||
Reference in New Issue
Block a user