diff --git a/src/mcp/plugin-tools-handlers.ts b/src/mcp/plugin-tools-handlers.ts index 4378d1944c3..99db6fa5b87 100644 --- a/src/mcp/plugin-tools-handlers.ts +++ b/src/mcp/plugin-tools-handlers.ts @@ -4,6 +4,7 @@ import { } from "../agents/pi-tools.before-tool-call.js"; import type { AnyAgentTool } from "../agents/tools/common.js"; import { formatErrorMessage } from "../infra/errors.js"; +import { coerceChatContentText } from "../shared/chat-content.js"; type CallPluginToolParams = { name: string; @@ -54,7 +55,7 @@ export function createPluginToolsMcpHandlers(tools: AnyAgentTool[]) { return { content: Array.isArray(result.content) ? result.content - : [{ type: "text", text: String(result.content) }], + : [{ type: "text", text: coerceChatContentText(result.content) }], }; } catch (err) { return {