Skip to main content
Glama
masx200

AMap Maps MCP Server

by masx200

maps_weather

Get weather information for any Chinese city by entering the city name or adcode to check current conditions and forecasts.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYes城市名称或者adcode

Implementation Reference

  • Handler function that queries the Amap weather API for the given city and returns formatted weather forecast data or error.
    async function handleWeather(city) { const url = new URL("https://restapi.amap.com/v3/weather/weatherInfo"); url.searchParams.append("city", city); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("source", "ts_mcp"); url.searchParams.append("extensions", "all"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [{ type: "text", text: `Get weather failed: ${data.info || data.infocode}`, }], isError: true, }; } return { content: [{ type: "text", text: JSON.stringify( { city: data.forecasts[0].city, forecasts: data.forecasts[0].casts, }, null, 2, ), }], isError: false, };
  • Input schema definition for the maps_weather tool, specifying the 'city' parameter.
    const WEATHER_TOOL = { name: "maps_weather", description: "根据城市名称或者标准adcode查询指定城市的天气", inputSchema: { type: "object", properties: { city: { type: "string", description: "城市名称或者adcode", }, }, required: ["city"], }, };
  • build/index.js:866-869 (registration)
    Registration of the maps_weather tool in the switch statement handling CallToolRequestSchema.
    case "maps_weather": { const { city } = request.params.arguments; return await handleWeather(city); }
  • Duplicate handler function in the HTTP server version that queries Amap weather API.
    async function handleWeather(city) { const AMAP_MAPS_API_KEY = getApiKey(); const url = new URL("https://restapi.amap.com/v3/weather/weatherInfo"); url.searchParams.append("city", city); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("source", "ts_mcp"); url.searchParams.append("extensions", "all"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [ { type: "text", text: `Get weather failed: ${data.info || data.infocode}`, }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify( { city: data.forecasts[0].city, forecasts: data.forecasts[0].casts, }, null, 2, ), }, ], isError: false, }; }
  • Input schema definition for maps_weather in the HTTP server factory function.
    const WEATHER_TOOL = { name: "maps_weather", description: "根据城市名称或者标准adcode查询指定城市的天气", inputSchema: { type: "object", properties: { city: { type: "string", description: "城市名称或者adcode", }, }, required: ["city"], }, };

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

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