diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index a9c48a7f61..5eeb7201c0 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -228,7 +228,7 @@ export async function callMCPTool(tool: MCPTool): Promise { content: [ { type: 'text', - text: `Error calling tool ${tool.name}: ${e instanceof Error ? (e.stack || e.message || "No error details available") : JSON.stringify(e)}` + text: `Error calling tool ${tool.name}: ${e instanceof Error ? e.stack || e.message || 'No error details available' : JSON.stringify(e)}` } ] }) @@ -309,18 +309,21 @@ export function upsertMCPToolResponse( onChunk: (chunk: MCPToolInProgressChunk | MCPToolCompleteChunk) => void ) { const index = results.findIndex((ret) => ret.id === resp.id) + let result = resp if (index !== -1) { - results[index] = { + const cur = { ...results[index], response: resp.response, status: resp.status } + results[index] = cur + result = cur } else { results.push(resp) } onChunk({ type: resp.status === 'invoking' ? ChunkType.MCP_TOOL_IN_PROGRESS : ChunkType.MCP_TOOL_COMPLETE, - responses: results + responses: [result] }) }