Skip to main content
Glama

get_weather_by_location

Retrieve current weather conditions from the nearest AMeDAS station using latitude and longitude coordinates. Provides real-time meteorological data for specific locations 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
NameRequiredDescriptionDefault
latYes
lonYes

Implementation Reference

  • Handler function for the get_weather_by_location tool. It finds the nearest AMeDAS station to the given coordinates and fetches current weather data from it. The @mcp.tool() decorator registers the tool.
    @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, {}),
        }
  • The @mcp.tool() decorator registers the get_weather_by_location function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/koizumikento/jma-data-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server