Skip to content

Conversation

@lillythomas
Copy link
Collaborator

@lillythomas lillythomas commented Feb 2, 2026

Summary

Add MCP-compatible tool for geocoding place names to bounding boxes via the Geodini service, enabling spatial queries for the EIE agent.

What it does

  • Resolves natural language queries (e.g., "I am interested in LA", "California", "Amazon rainforest") to geographic bounding boxes [west, south, east, north]
  • Returns structured output with place, bbox, and error fields
  • Registers with the MCP tool registry via @mcp_tool decorator

How it does

  1. Added GetPlaceTool class inheriting from BaseTool[GetPlaceInputSchema, GetPlaceOutputSchema]
  2. Implemented async _arun() method
    • Uses httpx.AsyncClient to query Geodini geocoding API
    • Extracts bounding box from GeoJSON geometry using shapely
    • Handles errors gracefully (timeouts, HTTP errors, missing results)
  3. Added configuration via GetPlaceToolConfig
    • geodini_host: Base URL for Geodini service (from GEODINI_HOST env var)
    • timeout: HTTP request timeout (default: 15s)

Files changed

  • akd_ext/tools/get_place.py — New tool implementation
  • akd_ext/tools/init.py — Added exports
  • pyproject.toml — Added httpx and shapely dependencies

Testing

import asyncio
from akd_ext.tools import GetPlaceTool
from akd_ext.tools.get_place import GetPlaceInputSchema

async def test():
    tool = GetPlaceTool()
    result = await tool.arun(GetPlaceInputSchema(query="California"))
    print(result)
    # place='California' bbox=[-124.41, 32.53, -114.13, 42.01] error=None

asyncio.run(test())

Environment variables required:

  • GEODINI_HOST — Geodini geocoding service URL

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