Merge pull request #4699 from continuedev/dallin/mcp-items

MCP Text Resources
This commit is contained in:
Dallin Romney 2025-03-18 12:33:19 -07:00 • committed by GitHub
commit f476c7783c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 13 deletions

View file

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

View file

@ -33,7 +33,7 @@ export default function ConfigErrorPage() {
<div className="py-5">
<h3 className="mb-2 mt-0 text-xl">Config Errors</h3>
<p className="text-md mb-4">
Please resolve the following errors in your config.json file.
Please resolve the following errors in your assistant configuration.
</p>
<div className="flex flex-col gap-5">
{sortedErrors.length > 0 ? (