Skip to main content
Glama

query_weather

Get current weather conditions for any city using AMap's location services. Provide a city name to receive weather data.

Instructions

The weather service of Amap. Query the weather of a given city.

Args: city (str): The city to query the weather.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYes

Implementation Reference

  • MCP tool handler for 'query_weather'. Registered via @mcp.tool decorator, includes input schema description in Args, executes by delegating to AmapClient.async_query_weather.
    @mcp.tool( description="""The weather service of Amap. Query the weather of a given city. Args: city (str): The city to query the weather. """ ) async def query_weather(city: str): logger.info(f"query_weather is called.") return await async_client.async_query_weather(city)
  • Core asynchronous helper function in AmapQueryWeatherClient that performs the actual HTTP GET request to the Amap weather API endpoint.
    async def async_query_weather_impl(self, city: str): url = "https://restapi.amap.com/v3/weather/weatherInfo" request_data = { "city": city, "key": self.key } logger.info(f"request_data: {request_data}") try: response = await self.httpx_client.get(url, params=request_data) return response.json() except Exception as e: logger.error(f"error: {e}") raise e
  • AmapClient wrapper class that initializes and delegates to AmapQueryWeatherClient for query_weather functionality.
    from .query_weather.client import AmapQueryWeatherClient class AmapClient: def __init__(self, key: str, httpx_client: typing.Union[httpx.Client, httpx.AsyncClient]): self.key = key self.httpx_client = httpx_client self.query_weather_client = AmapQueryWeatherClient(key, httpx_client) def query_weather(self, city: str): return self.query_weather_client.query_weather_impl(city) async def async_query_weather(self, city: str): return await self.query_weather_client.async_query_weather_impl(city)

Other Tools

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

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