fix(filesystem): use valid MCP content type for read_media_file#4044
Open
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
fix(filesystem): use valid MCP content type for read_media_file#4044MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4029.
read_media_filereturned content withtype: "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 (imagefor images,audiofor audio,resourcewith embedded blob for other binaries) and updatedoutputSchemato match.Tests added in
src/filesystem/__tests__/structured-content.test.ts.