Fixes #5252: Handle images without data URI format in access_mcp_resource #5276
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.
Summary
This PR fixes issue #5252 where the
access_mcp_resourcefunction fails to handle images that don't use the standarddata:image/;base64,base64stringformat.Problem
Most image resources in MCP servers don't use the data URI format, causing image processing to fail when the system expects all images to be in
data:image/png;base64,base64stringformat.Solution
Changes Made
Modified
accessMcpResourceTool.ts(lines 71-87):Updated
formatImagesIntoBlocksinresponses.ts(lines 179-203):Added comprehensive test suite (
responses-image-handling.spec.ts):Technical Details
Testing
Fixes
Closes #5252
Important
Fixes image handling in
accessMcpResourceToolto support both data URI and raw base64 formats, with comprehensive tests added.accessMcpResourceToolinaccessMcpResourceTool.tsnow detects if image blobs are in data URI format and converts raw base64 data to data URI with MIME type.formatImagesIntoBlocksinresponses.tsenhanced to handle both data URI and raw base64 formats, defaulting to 'image/png' for raw base64.responses-image-handling.spec.tsadded to test standard data URI, raw base64, mixed formats, and different MIME types.This description was created by
for 86e5ff3. You can customize this summary. It will automatically update as commits are pushed.