Skip to content

[EIE] Add visualization tool#34

Open
lillythomas wants to merge 1 commit intodevelopfrom
feature/eie-stac-viz-mcp-tool
Open

[EIE] Add visualization tool#34
lillythomas wants to merge 1 commit intodevelopfrom
feature/eie-stac-viz-mcp-tool

Conversation

@lillythomas
Copy link
Copy Markdown
Collaborator

Summary

Add a MCP-compatible tool for building raster tile URLs from COG (Cloud Optimized GeoTIFF) items using the VEDA Raster API, enabling map visualization for the EIE agent.

What it does

  • Converts COG item URLs into tile URL templates ({z}/{x}/{y}) suitable for web mapping applications
  • Fetches render parameters (colormap, rescale, bidx) from STAC collection metadata when a collection_id is provided
  • Returns tile URLs along with collection-level metadata (title, description, units, time_density) for frontend display

How it does this

  1. Added VizTool class inheriting from BaseTool[VizInputSchema, VizOutputSchema]
  2. Implemented async _arun() method that:
    • URL-encodes COG URLs and builds tile URL templates pointing to the VEDA Raster API
    • Fetches collection metadata from STAC API to extract renders.dashboard params
    • Appends render params (bidx, colormap_name, rescale) to tile URLs
  3. Added configuration via VizToolConfig:
    • veda_stac_url: VEDA STAC API URL (from VEDA_STAC_URL env var)
    • veda_raster_url: VEDA Raster API URL (from VEDA_RASTER_URL env var)
    • timeout: HTTP timeout (default: 15s)

Files changed

  • akd_ext/tools/eie/__init__.py — New module init with exports
  • akd_ext/tools/eie/viz.py — New tool implementation
  • akd_ext/tools/__init__.py — Added exports
  • pyproject.toml — Added httpx dependency

Testing

import asyncio
from akd_ext.tools.eie.viz import VizTool, VizToolConfig, VizInputSchema, VizItem

async def test():
    config = VizToolConfig(
        veda_stac_url='https://openveda.cloud/api/stac',
        veda_raster_url='https://openveda.cloud/api/raster',
    )
    tool = VizTool(config=config)
    result = await tool._arun(VizInputSchema(
        items=[VizItem(
            url='s3://veda-data-store/no2-monthly/OMI_trno2_0.10x0.10_202112_Col3_V4.nc.tif',
            id='OMI_trno2_0.10x0.10_202112_Col3_V4.nc',
            datetime='2021-12-01T00:00:00Z'
        )],
        collection_id='no2-monthly'
    ))
    print(f"Title: {result.title}")
    print(f"Colormap: {result.colormap_name}")
    print(f"Rescale: {result.rescale}")
    print(f"Tile URL: {result.items[0]['tile_url']}")

asyncio.run(test())

Output:

Title: NO₂
Colormap: rdbu_r
Rescale: [0.0, 1.5e+16]
Tile URL: https://openveda.cloud/api/raster/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.png?url=s3%3A%2F%2Fveda-data-store%2Fno2-monthly%2FOMI_trno2_0.10x0.10_202112_Col3_V4.nc.tif&bidx=1&colormap_name=rdbu_r&rescale=0,15000000000000000

Environment variables required:

  • VEDA_STAC_URL — VEDA STAC API URL (e.g., https://openveda.cloud/api/stac)
  • VEDA_RASTER_URL — VEDA Raster API URL (e.g., https://openveda.cloud/api/raster)

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.

1 participant