get_weather_stats
Retrieve weather statistics, including current conditions, forecasts, and alerts, using simulated data from the Weather MCP Server.
Instructions
Get weather statistics information
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_weather_stats"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:169-179 (handler)MCP CallToolRequest handler case for 'get_weather_stats': calls weatherService.getWeatherStats() and returns JSON stringified response.
case 'get_weather_stats': { const stats = await this.weatherService.getWeatherStats(); return { content: [ { type: 'text', text: JSON.stringify(stats, null, 2), }, ], }; } - src/weather-service.ts:78-108 (handler)Core handler function getWeatherStats() that computes weather statistics from mock data: total locations, avg temp, most common condition, and breakdown.
async getWeatherStats(): Promise<{ totalLocations: number; averageTemperature: number; mostCommonCondition: string; locationBreakdown: Array<{location: string, temperature: number, condition: string}>; }> { const locations = Object.values(mockWeatherData); const totalLocations = locations.length; const averageTemperature = locations.reduce((sum, data) => sum + data.temperature, 0) / totalLocations; const conditionCounts: Record<string, number> = {}; locations.forEach(data => { conditionCounts[data.condition] = (conditionCounts[data.condition] || 0) + 1; }); const mostCommonCondition = Object.entries(conditionCounts) .reduce((a, b) => a[1] > b[1] ? a : b)[0]; const locationBreakdown = locations.map(data => ({ location: data.location, temperature: data.temperature, condition: data.condition })); return { totalLocations, averageTemperature: Math.round(averageTemperature * 10) / 10, mostCommonCondition, locationBreakdown }; } - src/index.ts:99-106 (registration)Tool registration in ListToolsRequest handler: defines name 'get_weather_stats', description, and empty input schema (no parameters).
{ name: 'get_weather_stats', description: 'Get weather statistics information', inputSchema: { type: 'object', properties: {}, }, }, - src/index.ts:102-105 (schema)Input schema for get_weather_stats tool: empty object properties (no input parameters required).
inputSchema: { type: 'object', properties: {}, },