get_weather_by_location
Retrieve current weather data from the nearest AMeDAS station using latitude and longitude coordinates. Provides real-time observations from Japan Meteorological Agency stations across Japan.
Instructions
Get current weather from the nearest AMeDAS station to given coordinates.
Args: lat: Latitude in decimal degrees lon: Longitude in decimal degrees
Returns: Weather data from the nearest station
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | ||
| lon | Yes |
Implementation Reference
- jma_data_mcp/server.py:153-181 (handler)The handler function decorated with @mcp.tool(), implementing the get_weather_by_location tool. It searches for the nearest AMeDAS station within 100km of the given lat/lon, fetches current weather data using fetch_amedas_data, and returns formatted station info and weather observations.@mcp.tool() async def get_weather_by_location( lat: float, lon: float, ) -> dict: """Get current weather from the nearest AMeDAS station to given coordinates. Args: lat: Latitude in decimal degrees lon: Longitude in decimal degrees Returns: Weather data from the nearest station """ nearby = search_stations_by_location(lat, lon, radius_km=100) if not nearby: return {"error": "No stations found within 100km of the specified location"} nearest = nearby[0] station_code = nearest["code"] weather_data = await fetch_amedas_data(station_code) return { "observation_time": weather_data["observation_time"], "observation_time_jst": weather_data["observation_time_jst"], "station": nearest, "weather": weather_data["stations"].get(station_code, {}), }
- jma_data_mcp/server.py:153-153 (registration)The @mcp.tool() decorator registers the get_weather_by_location function as an MCP tool.@mcp.tool()
- jma_data_mcp/server.py:154-157 (schema)Function signature and docstring defining the input schema (lat: float, lon: float) and output type (dict), used by FastMCP for tool schema.async def get_weather_by_location( lat: float, lon: float, ) -> dict: