diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 959752af1..8d4b1f1b3 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -86,20 +86,44 @@ async function callToolFromUri( throw new Error(`Failed to call tool: ${toolName}`); } - return (response.content as any).map((item: any): ContextItem => { - if (item.type !== "text") { - throw new Error( - `Continue received item of type "${item.type}" from MCP tool, but currently only supports "text".`, - ); + const contextItems: ContextItem[] = []; + (response.content as any).forEach((item: any) => { + if (item.type === "text") { + contextItems.push({ + name: extras.tool.displayTitle, + description: "Tool output", + content: item.text, + icon: extras.tool.faviconUrl, + }); + } else if (item.type === "resource") { + // TODO resource change subscribers https://modelcontextprotocol.io/docs/concepts/resources + if (item.resource?.blob) { + contextItems.push({ + name: extras.tool.displayTitle, + description: "MCP Item Error", + content: + "Error: tool call received unsupported blob resource item", + icon: extras.tool.faviconUrl, + }); + } + // TODO account for mimetype? // const mimeType = item.resource.mimeType + // const uri = item.resource.uri; + contextItems.push({ + name: extras.tool.displayTitle, + description: "Tool output", + content: item.resource.text, + icon: extras.tool.faviconUrl, + }); + } else { + contextItems.push({ + name: extras.tool.displayTitle, + description: "MCP Item Error", + content: `Error: tool call received unsupported item of type "${item.type}"`, + icon: extras.tool.faviconUrl, + }); } - return { - name: extras.tool.displayTitle, - description: "Tool output", - content: item.text, - icon: extras.tool.faviconUrl, - }; }); - + return contextItems; default: throw new Error(`Unsupported protocol: ${parsedUri?.protocol}`); } diff --git a/gui/src/pages/config-error/index.tsx b/gui/src/pages/config-error/index.tsx index 3efad9d30..7bd3a3050 100644 --- a/gui/src/pages/config-error/index.tsx +++ b/gui/src/pages/config-error/index.tsx @@ -33,7 +33,7 @@ export default function ConfigErrorPage() {
- Please resolve the following errors in your config.json file. + Please resolve the following errors in your assistant configuration.