# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
**Tokyo WBGT MCP Server** - A Model Context Protocol (MCP) server that provides access to Tokyo's WBGT (Wet Bulb Globe Temperature) forecast and real-time data from Japan's Ministry of the Environment. WBGT is a heat index used for heatstroke prevention.
## Key Development Commands
```bash
# Install dependencies
npm install
# Build TypeScript to JavaScript
npm run build
# Run in production (requires build first)
npm start
# Run in development mode
npm run dev
```
## Architecture Overview
### Single Class Design
The entire server is implemented as a single `TokyoWBGTServer` class in `tokyo_wbgt_mcp_server.ts` that:
- Implements MCP SDK patterns with request handlers
- Exposes 3 tools: forecast data, all locations, and real-time data
- Fetches and parses CSV data from Ministry of Environment APIs
- Provides structured JSON responses with WBGT risk levels
### Data Flow
1. MCP client calls tool via JSON-RPC → 2. Server routes to handler method → 3. Fetches CSV from `wbgt.env.go.jp` → 4. Parses CSV to structured JSON → 5. Returns formatted response
### Core Methods
- **Data Fetchers**: `getTokyoWBGTForecast()`, `getAllTokyoLocations()`, `getTokyoRealtimeData()`
- **CSV Parsers**: `parseWBGTForecastCSV()`, `parseAllTokyoCSV()`, `parseRealtimeCSV()`
- **Utilities**: `formatDateTime()`, `getWBGTStatus()`, location mapping functions
## Project Structure
### Source Code Organization
- **src/index.ts**: Main MCP server class
- **src/types.ts**: TypeScript type definitions
- **src/constants.ts**: Location mappings and API URLs
- **src/utils.ts**: CSV parsing and utility functions
- **src/wbgt-service.ts**: Data fetching service class
### Build Output
- All TypeScript files compile to `build/` directory
- Entry point is `build/index.js`
## Tokyo Location Data
The server supports 7 Tokyo observation stations with specific station IDs:
- Tokyo (Koishikawa): 44132 (real-time available)
- Hachioji: 44112, Fuchu: 44116, Nerima: 44071
- Ome: 44056, Ogochi: 44046, Edogawa Rinkai: 44136
## WBGT Risk Levels
- Safe (< 21°C), Caution (21-25°C), Alert (25-28°C), High Alert (28-31°C), Danger (≥ 31°C)
## External Dependencies
- Fetches data from `https://www.wbgt.env.go.jp/` APIs
- No rate limiting implemented
- Data updates hourly