Skip to main content
Glama
yukit7s
by yukit7s

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値を取得します(実測地点のみ)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNo年(4桁)
monthNo月(1-12)

Implementation Reference

  • 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
          }
        },
      },
    }
  • TypeScript interface defining the output structure for realtime WBGT data.
    export interface WBGTRealtimeData {
      location: string;
      prefecture: string;
      data: WBGTRealtimeEntry[];
    }
  • 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)}`);
        }
      }
    }
  • 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時間のデータ
      };
    }

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/yukit7s/cc-get-wbgt'

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