mcp errors handling

This commit is contained in:
Andrew Pareles
2025-05-22 17:04:52 -07:00
parent b61ef87d41
commit 5ce097dee6
2 changed files with 3 additions and 2 deletions
@@ -716,8 +716,6 @@ class ChatThreadService extends Disposable implements IChatThreadService {
const toolResult_ = toolResult as RawMCPToolCall
if (toolResult_.event === 'text') {
toolResultStr = toolResult_.text
} else if (toolResult_.event === 'error') {
toolResultStr = `Error: ${toolResult_.text}`
} else if (toolResult_.event === 'image') {
toolResultStr = `[Image: ${toolResult_.image.mimeType}]`
} else if (toolResult_.event === 'audio') {
@@ -298,6 +298,9 @@ class MCPService extends Disposable implements IMCPService {
public async callMCPTool(toolData: MCPToolCallParams): Promise<{ result: RawMCPToolCall }> {
const result = await this.channel.call<RawMCPToolCall>('callTool', toolData);
if (result.event === 'error') {
throw new Error(`Error: ${result.text}`)
}
return { result };
}