Skip to content

fix(filesystem): use valid MCP content type for read_media_file#4044

Open
MukundaKatta wants to merge 1 commit into
modelcontextprotocol:mainfrom
MukundaKatta:fix/filesystem-read-media-content-type
Open

fix(filesystem): use valid MCP content type for read_media_file#4044
MukundaKatta wants to merge 1 commit into
modelcontextprotocol:mainfrom
MukundaKatta:fix/filesystem-read-media-content-type

Conversation

@MukundaKatta

Copy link
Copy Markdown

Closes #4029.

read_media_file returned content with type: "blob", which is not a valid MCP content type, so strict clients drop the response with "MCP error -32602: Invalid tools/call result". Mapped the file's MIME type to the correct MCP content (image for images, audio for audio, resource with embedded blob for other binaries) and updated outputSchema to match.

Tests added in src/filesystem/__tests__/structured-content.test.ts.

read_media_file returned content with type: "blob", which is not a
valid MCP content type per the 2025-11-25 spec (only text, image,
audio, resource_link, and resource are allowed). Strict clients
rejected the response at the transport layer with
"MCP error -32602: Invalid tools/call result".

Map the resolved MIME type to a valid content type:
  - image/* -> { type: "image", data, mimeType }
  - audio/* -> { type: "audio", data, mimeType }
  - other  -> { type: "resource", resource: { uri, mimeType, blob } }

Update the tool's outputSchema to match the new union shape and add
integration tests covering both the image and arbitrary-binary paths.

Closes modelcontextprotocol#4029.

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

@Seedmanc

Copy link
Copy Markdown

Can it be fixed that it reads images as base64 thus overflowing any context window, while it should instead send it as image to the vision model? Otherwise it pretty much impossible to use if you have to worry about image sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

filesystem: read_media_file returns invalid 'blob' content type, violating MCP spec

3 participants