From 93144a6a961dfa7a7106caf4fd45ae2318e806b6 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 5 Sep 2025 19:11:33 +0530 Subject: [PATCH] feat: add mcp request timeout when calling tool --- core/tools/callTool.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index c1d2039728c..faec8a94b8c 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -1,3 +1,4 @@ +import { CallToolResultSchema } from "@modelcontextprotocol/sdk/types.js"; import { ContextItem, Tool, ToolCall, ToolExtras } from ".."; import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton"; import { canParseUrl } from "../util/url"; @@ -87,10 +88,14 @@ async function callToolFromUri( if (!client) { throw new Error("MCP connection not found"); } - const response = await client.client.callTool({ - name: toolName, - arguments: args, - }); + const response = await client.client.callTool( + { + name: toolName, + arguments: args, + }, + CallToolResultSchema, + { timeout: client.options.timeout }, + ); if (response.isError === true) { throw new Error(JSON.stringify(response.content));