Skip to main content
Glama

search_nearby_stations

Find nearby AMeDAS weather stations within a specified radius from given coordinates to access Japan Meteorological Agency data.

Instructions

Search AMeDAS stations within a radius from given coordinates.

Args: lat: Latitude in decimal degrees lon: Longitude in decimal degrees radius_km: Search radius in kilometers (default: 50)

Returns: List of nearby stations sorted by distance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latYes
lonYes
radius_kmNo

Implementation Reference

  • The MCP tool handler for 'search_nearby_stations'. It delegates to the helper function and formats the response.
    @mcp.tool() async def search_nearby_stations( lat: float, lon: float, radius_km: float = 50.0, ) -> dict: """Search AMeDAS stations within a radius from given coordinates. Args: lat: Latitude in decimal degrees lon: Longitude in decimal degrees radius_km: Search radius in kilometers (default: 50) Returns: List of nearby stations sorted by distance """ stations = search_stations_by_location(lat, lon, radius_km) return { "count": len(stations), "search_center": {"lat": lat, "lon": lon}, "radius_km": radius_km, "stations": stations, }
  • The @mcp.tool() decorator registers the search_nearby_stations function as an MCP tool.
    @mcp.tool()
  • Core helper function that implements the nearby station search using the Haversine distance formula, filtering and sorting stations by distance.
    def search_stations_by_location( lat: float, lon: float, radius_km: float = 50.0 ) -> list[dict]: """Search stations within radius from given location.""" import math stations = load_stations() results = [] for station in stations.values(): station_lat = station["location"]["lat"] station_lon = station["location"]["lon"] # Haversine formula for distance calculation lat1, lon1 = math.radians(lat), math.radians(lon) lat2, lon2 = math.radians(station_lat), math.radians(station_lon) dlat = lat2 - lat1 dlon = lon2 - lon1 a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2 c = 2 * math.asin(math.sqrt(a)) # Earth radius in km r = 6371 distance = r * c if distance <= radius_km: result = station.copy() result["distance_km"] = round(distance, 2) results.append(result) # Sort by distance results.sort(key=lambda x: x["distance_km"]) return results

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