From 4261adcd5d2b54bbd2c99e18492940c3ef5bc26d Mon Sep 17 00:00:00 2001 From: Dustin Healy <54083382+dustinhealy@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:09:43 -0700 Subject: [PATCH] fix(mcp): keep app tool calls alive on progress and always send tool input Sets resetTimeoutOnProgress on app-initiated tool calls so a long-running tool that keeps streaming MCP progress is not aborted at the fixed connection timeout, matching the model-initiated callTool path. Always sends the tool-input notification before the result, even when the tool has no arguments. MCP Apps expect ui tool-input exactly once before the result, so apps that initialize from ontoolinput no longer stay blank for no-argument tools. --- client/src/hooks/MCP/useAppBridge.ts | 10 +++++----- packages/api/src/mcp/MCPManager.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/hooks/MCP/useAppBridge.ts b/client/src/hooks/MCP/useAppBridge.ts index 0ad90f82a8..dfc583c93b 100644 --- a/client/src/hooks/MCP/useAppBridge.ts +++ b/client/src/hooks/MCP/useAppBridge.ts @@ -155,11 +155,11 @@ export function useAppBridge( bridge.oninitialized = async () => { const args = toolArgsRef.current; const result = toolResultRef.current; - if (args) { - await bridge! - .sendToolInput({ arguments: args }) - .catch((err: unknown) => logger.error('[MCP App] sendToolInput failed', err)); - } + // MCP Apps expect tool input exactly once before the result, even for no-argument tools, + // so apps that initialize from ontoolinput always receive it. + await bridge! + .sendToolInput({ arguments: args ?? {} }) + .catch((err: unknown) => logger.error('[MCP App] sendToolInput failed', err)); if (result) { await bridge! .sendToolResult(result as never) diff --git a/packages/api/src/mcp/MCPManager.ts b/packages/api/src/mcp/MCPManager.ts index 0f5d95a2f8..91708e9da8 100644 --- a/packages/api/src/mcp/MCPManager.ts +++ b/packages/api/src/mcp/MCPManager.ts @@ -966,7 +966,7 @@ Please follow these instructions when using tools from the respective MCP server }, }, CallToolResultSchema, - { timeout: connection.timeout }, + { timeout: connection.timeout, resetTimeoutOnProgress: true }, ); return result;