Skip to content

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

@mattpodwysocki

Description

@mattpodwysocki

Problem

static_map_image_tool embeds the map image as a base64-encoded image content item in the tool result. For large maps (e.g. 800x600 streets at zoom 12), the PNG can exceed 750KB, 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.

Proposed Fix

Instead of embedding base64 in the tool result, store the image in a bounded in-memory cache and return a resource content item referencing it (e.g. mapbox://temp/static-map-{id}). Clients that support resource fetching can retrieve the image on demand; the tool result itself stays small.

The cache should:

  • Have a max entry count (or total byte) cap to prevent memory exhaustion
  • Use TTL expiry (same pattern as DirectionsTool temp resources)
  • Serve binary PNG/JPEG data with the correct mime type

References

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions