Skip to content

Fix #1758: Fix Screenshot MCP Tool#1765

Open
priii-25 wants to merge 1 commit intounclecode:developfrom
priii-25:main
Open

Fix #1758: Fix Screenshot MCP Tool#1765
priii-25 wants to merge 1 commit intounclecode:developfrom
priii-25:main

Conversation

@priii-25
Copy link

Summary

Fix Screenshot MCP Tool saving screenshots only to the Docker filesystem instead of returning PNG data, and correct screenshot encoding format from BMP to PNG.

Fixes #1758

This PR ensures that screenshots are always returned as base64-encoded PNG data in the API response, making them accessible to remote MCP clients. It also fixes an incorrect image format encoding that caused scrollable screenshots to be returned as BMP instead of the documented PNG format.

List of files changed and why

crawl4ai/async_crawler_strategy.py

  • Updated take_screenshot_scroller to save stitched screenshots in PNG format instead of BMP.
  • Previously, "BMP" was explicitly specified, causing scrollable screenshots to return BMP-encoded data instead of PNG.
  • This change ensures consistency with documentation and expected client behavior.

deploy/docker/server.py

  • Modified the /screenshot endpoint to always include base64-encoded screenshot data in the response.
  • Previously, when output_path was provided, only a filesystem path inside the Docker container was returned, which is inaccessible to MCP clients.
  • File saving is now best-effort, and the response always includes the screenshot field.
  • Ensures remote MCP clients can reliably access screenshot data regardless of filesystem access.

How Has This Been Tested?

  • Verified existing tests (test_6_multi_endpoint.py, run_security_tests.py) continue to pass without modification.
  • Confirmed MCP bridge (mcp_bridge.py) correctly serializes the updated response using generic json.dumps, with no dependency on specific response keys.
  • Validated response compatibility:
    • Without output_path: response shape remains unchanged.
    • With output_path: response now includes additional screenshot field while preserving existing behavior.
  • Manually verified scrollable screenshots are now encoded and returned as PNG instead of BMP.
  • Confirmed screenshots are accessible remotely via API response even when file saving is enabled.

Note:
No existing unit tests specifically covered:

  • BMP vs PNG encoding correctness
  • Screenshot accessibility when output_path is provided

New tests should be added in future to cover these cases.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@ntohidi ntohidi changed the base branch from main to develop February 19, 2026 06:30
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.

[Bug]: Screenshot MCP Tool saving to Docker filesystem and not providing PNG.

1 participant