mcp errors handling

This commit is contained in:
Andrew Pareles 2025-05-22 17:04:52 -07:00
parent 4f4af9b8b9
commit b56cc0d662
2 changed files with 3 additions and 2 deletions

View file

@ -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') {

View file

@ -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 };
}