Skip to main content
Glama

query_weather

Retrieve real-time weather data for a specific city using AMap's location services.

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

  • Handler function for the query_weather MCP tool that logs the invocation and delegates execution to the AmapClient's async_query_weather method.
    async def query_weather(city: str): logger.info(f"query_weather is called.") return await async_client.async_query_weather(city)
  • Registers the 'query_weather' tool on the FastMCP server, including the tool description and input parameter specification.
    @mcp.tool( description="""The weather service of Amap. Query the weather of a given city. Args: city (str): The city to query the weather. """ )
  • Wrapper method in AmapClient that forwards the query_weather request to the specialized AmapQueryWeatherClient's implementation.
    async def async_query_weather(self, city: str): return await self.query_weather_client.async_query_weather_impl(city)
  • Core implementation of the weather query: constructs the API request to Amap's weather endpoint, performs asynchronous HTTP GET, parses JSON response, with logging and error handling.
    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

Other Tools

Related 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