Skip to main content
Glama
marcusbai

Caiyun Weather MCP Server

by marcusbai

get_minutely_forecast

Retrieve minute-level precipitation forecasts for specific coordinates using the Caiyun Weather MCP Server. Supports multiple languages and unit systems for accurate weather insights.

Instructions

获取分钟级降水预报

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNo语言zh_CN
latitudeYes纬度
longitudeYes经度
unitNo单位制 (metric: 公制, imperial: 英制)metric

Implementation Reference

  • MCP tool handler for get_minutely_forecast: validates longitude/latitude params, calls CaiyunWeatherService.getMinutely, formats response with formatMinutelyData, and returns JSON string as text content.
    case 'get_minutely_forecast': { if (!this.isValidLocationArgs(args)) { throw new McpError( ErrorCode.InvalidParams, '无效的位置参数' ); } const { longitude, latitude } = args; const weatherData = await weatherService.getMinutely(longitude, latitude); return { content: [ { type: 'text', text: JSON.stringify(weatherService.formatMinutelyData(weatherData), null, 2), }, ], }; }
  • src/index.ts:186-215 (registration)
    Tool registration in ListToolsRequestSchema, including name, description, and input schema for longitude, latitude, optional language and unit.
    { name: 'get_minutely_forecast', description: '获取分钟级降水预报', inputSchema: { type: 'object', properties: { longitude: { type: 'number', description: '经度', }, latitude: { type: 'number', description: '纬度', }, language: { type: 'string', enum: ['zh_CN', 'en_US'], description: '语言', default: 'zh_CN', }, unit: { type: 'string', enum: ['metric', 'imperial'], description: '单位制 (metric: 公制, imperial: 英制)', default: 'metric', }, }, required: ['longitude', 'latitude'], }, },
  • Core helper function in CaiyunWeatherService that performs the API request to Caiyun's minutely precipitation forecast endpoint.
    async getMinutely(longitude: number, latitude: number): Promise<CaiyunWeatherResponse> { try { const url = `${this.baseUrl}/${this.apiKey}/${longitude},${latitude}/minutely`; const response = await axios.get<CaiyunWeatherResponse>(url, { params: { lang: this.language, unit: this.unit } }); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`彩云天气API错误: ${error.response?.data?.error || error.message}`); } throw error; } }
  • Helper function to format the raw minutely forecast API response into a structured object with location, server_time, description, precipitation arrays, and probability.
    formatMinutelyData(data: CaiyunWeatherResponse) { const minutely = data.result.minutely; if (!minutely) { throw new Error('没有分钟级降水预报数据'); } return { location: data.location, server_time: new Date(data.server_time * 1000).toISOString(), description: minutely.description, precipitation: minutely.precipitation, precipitation_2h: minutely.precipitation_2h, probability: minutely.probability }; }

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/marcusbai/caiyun-weather-mcp'

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