Skip to content

[BUG] MCP tool results with non-image binary content crash session with 'unsupported tool content part type: file-data' #30249

@a12233

Description

@a12233

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

  1. Configure an MCP server that returns a resource with a non-image/non-PDF blob (see example above)
  2. Start a session with an Anthropic model
  3. Invoke the tool
  4. Session fails with unsupported tool content part type: file-data

Screenshot and/or share link

No response

Operating System

macOS

Terminal

Any

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions