You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: Media type validation/conversion for MCP tool results #12519
When using the filesystem MCP server's ReadMediaFile tool on files with media types not supported by the Claude API (e.g., image/svg+xml, image/bmp, image/tiff), the API returns a Type validation failed error because it only accepts image/jpeg, image/png, image/gif, and image/webp.
The agent has no way to recover from this — the error happens at the API level after the tool result is already assembled.
Current Workaround
Added AGENTS.md instructions telling the agent to never use ReadMediaFile on unsupported formats. This works but relies on the agent remembering the rule, which isn't reliable.
Proposed Solutions (any of these would help)
Option 1: Automatic conversion layer (preferred)
Add a media type validation step before sending tool results to the API. If an MCP tool returns image content with an unsupported media type:
SVG: Convert to PNG (via rsvg-convert, cairosvg, or sips on macOS)
BMP/TIFF/ICO: Convert to PNG (via sips on macOS, ImageMagick, or sharp)
Unknown: Strip the image content and return a text message explaining the format isn't supported
Option 2: Hook support for MCP tool results
Extend the hook system (PostToolUse) to also fire for MCP server tool calls, not just built-in tools. This would allow users to write custom conversion/filtering hooks.
Option 3: MCP tool result filter in config
Allow configuring media type filters in mcp.json or OpenCode settings:
{
"mediaTypeFilter": {
"allowedTypes": ["image/jpeg", "image/png", "image/gif", "image/webp"],
"action": "convert_to_png"// or "strip" or "error"
}
}
Environment
OpenCode v1.1.53
macOS (Apple Silicon)
Filesystem MCP server (@modelcontextprotocol/server-filesystem)
Claude API (Opus 4)
Reproduction
# 1. Have an SVG file in the filesystem MCP's allowed directories# 2. Ask the agent to read the SVG as an image# 3. Agent calls FilesystemReadMediaFile on the .svg# 4. API returns "Type validation failed" error
Activity
github-actions commentedon Feb 6, 2026
This issue might be a duplicate of or closely related to existing issues. Please check:
Feel free to ignore if your specific case differs.
github-actions commentedon Apr 8, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.