maps_weather
Get weather forecasts for Chinese cities using city names or adcodes to plan travel and outdoor activities.
Instructions
根据城市名称或者标准adcode查询指定城市的天气
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| city | Yes |
Implementation Reference
- amap_mcp_server/server.py:110-137 (handler)The main handler function for the 'maps_weather' tool. It takes a city parameter, calls the Amap weather API, and returns weather forecast data or an error.@mcp.tool() def maps_weather(city: str) -> Dict[str, Any]: """根据城市名称或者标准adcode查询指定城市的天气""" try: response = requests.get( "https://restapi.amap.com/v3/weather/weatherInfo", params={ "key": AMAP_MAPS_API_KEY, "city": city, "extensions": "all" } ) response.raise_for_status() data = response.json() if data["status"] != "1": return {"error": f"Get weather failed: {data.get('info') or data.get('infocode')}"} forecasts = data.get("forecasts", []) if not forecasts: return {"error": "No forecast data available"} return { "city": forecasts[0]["city"], "forecasts": forecasts[0]["casts"] } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}
- amap_mcp_server/server.py:110-110 (registration)The @mcp.tool() decorator registers the maps_weather function as an MCP tool.@mcp.tool()