Shrink get_page_image's tool result to avoid CLIJSONDecodeError #1

Merged
martian merged 1 commit from fix/shrink-page-image-for-vision into main 2026-09-30 18:38:03 +00:00
Owner

Shrink get_page_image's tool result to avoid CLIJSONDecodeError

rsvg-convert renders each page at native size, and base64-encoding
that PNG for the MCP wire format adds ~33% -- once relayed through
the Claude CLI's stream-json stdout, that single NDJSON line can
exceed the Claude Agent SDK's default 1 MiB per-line buffer. This
caused real CLIJSONDecodeError failures on the eprosveta-mcp sibling
for a heavy page; applying the same fix here preemptively. Downscale
to at most 1600px on the long edge and fall back to JPEG at
decreasing quality if still over budget; get_page_image_url/
_serve_page_image stay full-resolution since those are for a human
directly viewing the page.

Shrink get_page_image's tool result to avoid CLIJSONDecodeError rsvg-convert renders each page at native size, and base64-encoding that PNG for the MCP wire format adds ~33% -- once relayed through the Claude CLI's stream-json stdout, that single NDJSON line can exceed the Claude Agent SDK's default 1 MiB per-line buffer. This caused real CLIJSONDecodeError failures on the eprosveta-mcp sibling for a heavy page; applying the same fix here preemptively. Downscale to at most 1600px on the long edge and fall back to JPEG at decreasing quality if still over budget; get_page_image_url/ _serve_page_image stay full-resolution since those are for a human directly viewing the page.
rsvg-convert renders each page at native size, and base64-encoding
that PNG for the MCP wire format adds ~33% -- once relayed through
the Claude CLI's stream-json stdout, that single NDJSON line can
exceed the Claude Agent SDK's default 1 MiB per-line buffer. This
caused real CLIJSONDecodeError failures on the eprosveta-mcp sibling
for a heavy page; applying the same fix here preemptively. Downscale
to at most 1600px on the long edge and fall back to JPEG at
decreasing quality if still over budget; get_page_image_url/
_serve_page_image stay full-resolution since those are for a human
directly viewing the page.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
selfhosted-bg/klett-mcp!1
No description provided.