Skip to content

fix(static-map): store large images as temporary resources to avoid 1MB tool result limit#140

Open
mattpodwysocki wants to merge 1 commit intomainfrom
fix/static-map-large-image
Open

fix(static-map): store large images as temporary resources to avoid 1MB tool result limit#140
mattpodwysocki wants to merge 1 commit intomainfrom
fix/static-map-large-image

Conversation

@mattpodwysocki
Copy link
Contributor

@mattpodwysocki mattpodwysocki commented Mar 6, 2026

Problem

static_map_image_tool inlines the map image as a base64 image content item in the tool result. For large maps (e.g. 800x600 streets at zoom 12), the PNG can exceed 700KB raw, and base64 encoding adds ~33% overhead, pushing the tool result over Claude Desktop's 1MB limit:

Tool result is too large. Maximum size is 1MB.
Screenshot 2026-03-06 at 16 33 19

Fix

Images over 700KB are stored in the temporary resource cache instead of being inlined as base64:

  • Small images (≤700KB): inlined as image content as before — no behavior change for most requests
  • Large images (>700KB): stored at mapbox://temp/static-map-{id}, retrievable via resources/read with a 30-minute TTL; tool result contains the resource URI as text

Additionally:

  • TemporaryResourceManager now enforces a 50MB byte cap with oldest-first eviction to prevent unbounded memory growth (previously unbounded)
  • TemporaryDataResource now serves blob content for image/* mime types instead of always returning JSON text

Test plan

  • All existing tests pass
  • New test: stores large images as temporary resources instead of inlining base64
Screenshot 2026-03-06 at 16 37 12

Closes #139

🤖 Generated with Claude Code

@mattpodwysocki mattpodwysocki requested a review from a team as a code owner March 6, 2026 21:32
…MB limit

Images over 700KB are stored in the temporary resource cache instead of
being inlined as base64 in the tool result, preventing Claude Desktop's
1MB tool result limit from being exceeded.

- TemporaryResourceManager: add 50MB byte cap with oldest-first eviction
  and mimeType field on stored resources
- TemporaryDataResource: serve blob content for image/* mime types
- StaticMapImageTool: inline base64 for small images, temp resource for large

Closes #139

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki force-pushed the fix/static-map-large-image branch from c5c5a99 to 3d56be3 Compare March 6, 2026 23:19
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.

static_map_image_tool: return image as temporary resource to avoid 1MB tool result limit

1 participant