Skip to content

Commit 71c947a

Browse files
authored
Merge pull request #7604 from uinstinct/mcp-request-timeout
feat: add mcp request timeout when calling tool
2 parents bf9ba15 + d080ab1 commit 71c947a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

core/tools/callTool.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CallToolResultSchema } from "@modelcontextprotocol/sdk/types.js";
12
import { ContextItem, Tool, ToolCall, ToolExtras } from "..";
23
import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton";
34
import { canParseUrl } from "../util/url";
@@ -87,10 +88,14 @@ async function callToolFromUri(
8788
if (!client) {
8889
throw new Error("MCP connection not found");
8990
}
90-
const response = await client.client.callTool({
91-
name: toolName,
92-
arguments: args,
93-
});
91+
const response = await client.client.callTool(
92+
{
93+
name: toolName,
94+
arguments: args,
95+
},
96+
CallToolResultSchema,
97+
{ timeout: client.options.timeout },
98+
);
9499

95100
if (response.isError === true) {
96101
throw new Error(JSON.stringify(response.content));

0 commit comments

Comments
 (0)