Skip to content

Add an MCP tool that returns a rendered resource map image #409

Description

@ewlarson

Summary

Expose the existing static-map capability through the MCP server so an AI client can request a map for a GeoBTAA resource and receive an actual image result rather than only a URL or textual geometry description.

The first implementation should reuse the current static-map service and cache behind GET /api/v1/static-maps/{resource_id}. It should not introduce a parallel rendering pipeline.

Proposed tool

render_resource_map(resource_id, width?, height?, format?) -> image

The final tool name and schema may follow the existing MCP naming conventions.

Behavior

  • Resolve the requested resource using its canonical GeoBTAA identifier.
  • Render or retrieve the cached static map for the resource geometry.
  • Return the image through MCP as image content with the correct MIME type.
  • Include compact textual context alongside the image: resource ID, title, geographic extent, canonical resource URL, and map endpoint URL.
  • Return a useful structured error when the resource does not exist, has no usable geometry, cannot be rendered, or exceeds configured limits.
  • Preserve the existing static-map fallback/placeholder behavior only when it communicates a real no-geometry state; do not present a placeholder as a successfully rendered geographic map.

Acceptance criteria

  • A new MCP tool is discoverable through tools/list with a clear description and JSON schema.
  • Calling the tool for a resource with valid geometry returns valid image content and the correct MIME type.
  • The implementation delegates rendering and caching to the existing static-map service.
  • The response includes enough text metadata for clients that do not display MCP image content.
  • Unknown IDs, missing geometry, renderer failures, timeouts, and unsupported options produce stable, documented errors.
  • Width, height, and output format are constrained to safe supported values with sensible defaults.
  • Authorization and visibility rules are applied before returning metadata or imagery.
  • Unit and MCP integration tests cover successful, cached, missing-geometry, unauthorized, invalid-input, and renderer-failure paths.
  • The MCP documentation includes example requests and describes the returned content blocks.

Implementation context

Relevant existing components include:

  • backend/app/services/mcp_service.py
  • backend/app/tasks/static_maps.py
  • GET /api/v1/static-maps/{resource_id}
  • GET /api/v1/static-maps/{resource_id}/geometry
  • backend/tests/services/test_mcp_service.py
  • backend/tests/api/v1/test_static_map_endpoints.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions