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
获取分钟级降水预报
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"longitude": "<longitude>",
"latitude": "<latitude>"
},
"name": "get_minutely_forecast"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | No | 语言 | zh_CN |
| latitude | Yes | 纬度 | |
| longitude | Yes | 经度 | |
| unit | No | 单位制 (metric: 公制, imperial: 英制) | metric |
Implementation Reference
- src/index.ts:472-492 (handler)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'], }, }, - src/caiyun-service.ts:55-72 (helper)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; } } - src/caiyun-service.ts:285-299 (helper)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 }; }