Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 4, 2025

This PR attempts to address Issue #9817. Feedback and guidance are welcome!

Summary

This PR adds support for handling image content from MCP tool responses, including saving images to the local file system with proper file naming and format handling.

Changes

  • Modified UseMcpToolTool.ts to handle image content in processToolContent method
  • Added image collection and passing to task.say() and formatResponse.toolResult() for UI display
  • Implemented automatic image saving to local file system in mcp-images directory
  • Added comprehensive test coverage for image handling scenarios

Features

  • ✅ Handles image content from MCP tool responses (type: "image" with data and mimeType)
  • ✅ Saves images to local file system with timestamp-based naming
  • ✅ Displays images in UI alongside text responses
  • ✅ Supports multiple images in a single response
  • ✅ Handles both raw base64 and data URL formats
  • ✅ Creates mcp-images directory in workspace (or temp directory if no workspace)
  • ✅ Shows saved file paths in the response text

Testing

  • Added 6 new test cases covering various image handling scenarios
  • All existing tests pass without regression
  • Tests verify image saving, UI display, and mixed content handling

Fixes #9817

- Handle image content from MCP tool responses
- Save images to local file system with proper naming
- Display images in UI alongside text responses
- Add comprehensive tests for image handling

Fixes #9817
@roomote
Copy link
Contributor Author

roomote bot commented Dec 4, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. Found 1 issue that should be addressed:

  • Image saving failures are silently ignored, creating inconsistency between displayed images and saved file references

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +376 to +382
if (images.length > 0) {
for (let i = 0; i < images.length; i++) {
const savedPath = await this.saveImageToFile(images[i], i + 1)
if (savedPath) {
savedImagePaths.push(savedPath)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The image saving logic silently ignores failures when saveImageToFile returns null. If saving fails for any image (e.g., due to invalid data URL format, file system permissions, or disk space), the code continues without logging the failure or notifying the user. This creates an inconsistency where images are displayed in the UI but their corresponding file paths are missing from the response text, potentially confusing users who expect to find saved files.

Fix it with Roo Code or mention @roomote and request a fix.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

The MCP tool does not save the image data as an image file.

3 participants