Description
When an MCP server returns a tool result containing a resource with a base64 blob whose mime type is not an image or PDF (e.g. text/csv), the session fails with:
unsupported tool content part type: file-data with media type: text/csv
The issue is in how opencode processes MCP tool results. Non-image blobs are stored as binary attachments, which the AI SDK maps to file-data content parts. The Anthropic provider only accepts file-data for PDFs.
Minimal reproducible example:
Create a simple MCP server that returns a CSV as a resource blob:
// server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new McpServer({ name: "csv-test", version: "1.0.0" });
server.tool("get_csv", "Returns a CSV file", {}, async () => ({
content: [
{
type: "resource",
resource: {
uri: "file:///test.csv",
mimeType: "text/csv",
blob: Buffer.from("name,age\nAlice,30\nBob,25").toString("base64"),
},
},
],
}));
const transport = new StdioServerTransport();
await server.connect(transport);
Configure in opencode.json:
{
"mcp": {
"csv-test": {
"command": "npx",
"args": ["tsx", "server.ts"]
}
}
}
Call the get_csv tool in a session using any Anthropic model. The session fails.
Plugins
No response
OpenCode version
1.15.13
Steps to reproduce
- Configure an MCP server that returns a resource with a non-image/non-PDF blob (see example above)
- Start a session with an Anthropic model
- Invoke the tool
- Session fails with
unsupported tool content part type: file-data
Screenshot and/or share link
No response
Operating System
macOS
Terminal
Any
Description
When an MCP server returns a tool result containing a
resourcewith a base64 blob whose mime type is not an image or PDF (e.g.text/csv), the session fails with:The issue is in how opencode processes MCP tool results. Non-image blobs are stored as binary attachments, which the AI SDK maps to
file-datacontent parts. The Anthropic provider only acceptsfile-datafor PDFs.Minimal reproducible example:
Create a simple MCP server that returns a CSV as a resource blob:
Configure in
opencode.json:{ "mcp": { "csv-test": { "command": "npx", "args": ["tsx", "server.ts"] } } }Call the
get_csvtool in a session using any Anthropic model. The session fails.Plugins
No response
OpenCode version
1.15.13
Steps to reproduce
unsupported tool content part type: file-dataScreenshot and/or share link
No response
Operating System
macOS
Terminal
Any