diff --git a/src/index.ts b/src/index.ts index caef1d3..10fe576 100644 --- a/src/index.ts +++ b/src/index.ts @@ -225,7 +225,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { } as ToolResponse; } - throw error; + // For any other error, return a proper error response instead of throwing + return { + content: [ + { + type: "text" as const, + text: `Tool execution failed: ${error instanceof Error ? error.message : String(error)}`, + }, + ], + isError: true, + } as ToolResponse; } });