Skip to main content
Glama

maps_weather

Get weather forecasts for any Chinese city by entering the city name or adcode to plan activities and travel with current conditions.

Instructions

根据城市名称或者标准adcode查询指定城市的天气

Input Schema

NameRequiredDescriptionDefault
cityYes

Input Schema (JSON Schema)

{ "properties": { "city": { "title": "City", "type": "string" } }, "required": [ "city" ], "type": "object" }

Implementation Reference

  • Implementation of the maps_weather tool: fetches current and forecast weather data for a specified city using the Amap weather API. Includes error handling for API requests and response validation.
    @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)}"}

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/sugarforever/amap-mcp-server'

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