Skip to content

MCP Text Resources #4699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions core/tools/callTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
2 changes: 1 addition & 1 deletion gui/src/pages/config-error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
Expand Down
Loading