From 48ec8a5fa6864b97b2ad1523dfc757db9f34d2ae Mon Sep 17 00:00:00 2001 From: Tim Smart Date: Tue, 7 Oct 2025 08:57:04 +1300 Subject: [PATCH] improve mcp errors --- packages/effect/src/unstable/ai/AiToolkit.ts | 2 +- packages/effect/src/unstable/ai/McpServer.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/effect/src/unstable/ai/AiToolkit.ts b/packages/effect/src/unstable/ai/AiToolkit.ts index 215af325ae..cbb71e76a9 100644 --- a/packages/effect/src/unstable/ai/AiToolkit.ts +++ b/packages/effect/src/unstable/ai/AiToolkit.ts @@ -161,7 +161,7 @@ const Proto = { new AiError({ module: "AiToolkit", method: `${toolName}.handle`, - description: `Failed to decode tool call parameters for tool '${toolName}' from '${toolParams}'`, + description: `Failed to decode tool call parameters for tool '${toolName}'`, cause }) ) diff --git a/packages/effect/src/unstable/ai/McpServer.ts b/packages/effect/src/unstable/ai/McpServer.ts index 5f9ce21501..c5e49c38af 100644 --- a/packages/effect/src/unstable/ai/McpServer.ts +++ b/packages/effect/src/unstable/ai/McpServer.ts @@ -577,14 +577,13 @@ export const registerToolkit: (toolkit: AiToolkit.AiTo handle(payload) { return built.handle(tool.name as any, payload).pipe( Effect.provideServices(services as ServiceMap.ServiceMap), - Effect.match({ - onFailure: (error) => + Effect.matchCause({ + onFailure: (cause) => new CallToolResult({ isError: true, - structuredContent: typeof error === "object" ? error : undefined, content: [{ type: "text", - text: JSON.stringify(error) + text: Cause.pretty(cause) }] }), onSuccess: (result: any) =>