get_tokyo_realtime_data
Retrieve measured WBGT values from Tokyo observation points to monitor heat stress conditions and support heat stroke prevention decisions.
Instructions
東京都の実測WBGT値を取得します(実測地点のみ)
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_tokyo_realtime_data"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | No | 年(4桁) | |
| month | No | 月(1-12) |
Implementation Reference
- src/index.ts:154-165 (handler)MCP tool handler function that invokes the WBGT service to retrieve Tokyo realtime data and returns it as JSON.
private async handleGetTokyoRealtimeData(year: number, month: number): Promise<any> { const data = await this.wbgtService.getTokyoRealtimeData(year, month); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } - src/index.ts:61-81 (registration)Tool registration in the ListTools response, defining the tool name, description, and input schema for year and month.
{ name: "get_tokyo_realtime_data", description: "東京都の実測WBGT値を取得します(実測地点のみ)", inputSchema: { type: "object", properties: { year: { type: "number", description: "年(4桁)", default: new Date().getFullYear() }, month: { type: "number", description: "月(1-12)", minimum: 1, maximum: 12, default: new Date().getMonth() + 1 } }, }, } - src/types.ts:38-42 (schema)TypeScript interface defining the output structure for realtime WBGT data.
export interface WBGTRealtimeData { location: string; prefecture: string; data: WBGTRealtimeEntry[]; } - src/wbgt-service.ts:55-71 (helper)Service method that fetches realtime WBGT CSV from the API URL constructed with year and month, then parses it.
async getTokyoRealtimeData(year: number, month: number): Promise<WBGTRealtimeData> { const monthStr = month.toString().padStart(2, '0'); const url = `${WBGT_API_BASE_URLS.realtime}Tokyo_${year}${monthStr}.csv`; try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const csvData = await response.text(); return parseRealtimeCSV(csvData); } catch (error) { throw new Error(`Failed to fetch realtime WBGT data: ${error instanceof Error ? error.message : String(error)}`); } } } - src/utils.ts:133-162 (helper)Utility function that parses the realtime CSV data into structured WBGTRealtimeData, calculating status and limiting to latest 24 hours.
export function parseRealtimeCSV(csvData: string): WBGTRealtimeData { const lines = csvData.split('\n').filter(line => line.trim()); if (lines.length < 2) { throw new Error("Invalid CSV format"); } const realtimeData: WBGTRealtimeEntry[] = []; for (let i = 1; i < lines.length; i++) { const values = lines[i].split(','); if (values.length >= 3) { const date = values[0]; const time = values[1]; const wbgt = parseFloat(values[2]); realtimeData.push({ datetime: `${date} ${time}`, wbgt: isNaN(wbgt) ? null : wbgt, status: getWBGTStatus(wbgt) }); } } return { location: "東京(実測地点)", prefecture: "東京都", data: realtimeData.slice(-24) // 最新24時間のデータ }; }