search_location
Search for locations in the Netherlands to retrieve weather data from KNMI stations.
Instructions
Search for locations in the Netherlands
Args:
query: Search term for locationInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/knmi_weather_mcp/server.py:115-142 (handler)The 'search_location' tool handler function. Decorated with @mcp.tool(), it queries OpenStreetMap's Nominatim API to search for locations in the Netherlands and returns a list of results with name, type, latitude, and longitude.
@mcp.tool() async def search_location(query: str, ctx: Context) -> List[Dict[str, str]]: """ Search for locations in the Netherlands Args: query: Search term for location """ async with httpx.AsyncClient() as client: response = await client.get( "https://nominatim.openstreetmap.org/search", params={"q": f"{query}, Netherlands", "format": "json", "limit": 5}, headers={"User-Agent": "KNMI_Weather_MCP/1.0"}, ) response.raise_for_status() results = [] for place in response.json(): results.append( { "name": place["display_name"], "type": place["type"], "latitude": place["lat"], "longitude": place["lon"], } ) return results - src/knmi_weather_mcp/server.py:115-115 (registration)The tool is registered via the @mcp.tool() decorator on line 115, which is how FastMCP registers it as an MCP tool.
@mcp.tool()