Skip to content

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

Open
MukundaKatta wants to merge 1 commit intomodelcontextprotocol: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 intomodelcontextprotocol: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.
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

1 participant