Skip to main content
Glama

get_forecast

Retrieve weather forecasts for Japanese prefectures using Japan Meteorological Agency data to plan activities and prepare for conditions.

Instructions

Get weather forecast for a prefecture.

Args: prefecture: Prefecture name in English (e.g., 'tokyo', 'osaka', 'hokkaido_sapporo')

Returns: Weather forecast data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prefectureYes

Implementation Reference

  • Handler function for the 'get_forecast' tool, including the @mcp.tool() registration decorator and the core logic that validates the prefecture using AREA_CODES and fetches forecast data via fetch_forecast.
    @mcp.tool() async def get_forecast(prefecture: str) -> dict: """Get weather forecast for a prefecture. Args: prefecture: Prefecture name in English (e.g., 'tokyo', 'osaka', 'hokkaido_sapporo') Returns: Weather forecast data """ area_code = AREA_CODES.get(prefecture) if not area_code: return { "error": f"Unknown prefecture: {prefecture}", "available": list(AREA_CODES.keys()), } forecast_data = await fetch_forecast(area_code) return { "prefecture": prefecture, "area_code": area_code, "forecast": forecast_data, }
  • Dictionary mapping prefecture names to JMA area codes, used for input validation in get_forecast (determines valid prefectures and their codes). Serves as input schema/reference.
    AREA_CODES = { "hokkaido_sapporo": "016000", "aomori": "020000", "iwate": "030000", "miyagi": "040000", "akita": "050000", "yamagata": "060000", "fukushima": "070000", "ibaraki": "080000", "tochigi": "090000", "gunma": "100000", "saitama": "110000", "chiba": "120000", "tokyo": "130000", "kanagawa": "140000", "niigata": "150000", "toyama": "160000", "ishikawa": "170000", "fukui": "180000", "yamanashi": "190000", "nagano": "200000", "gifu": "210000", "shizuoka": "220000", "aichi": "230000", "mie": "240000", "shiga": "250000", "kyoto": "260000", "osaka": "270000", "hyogo": "280000", "nara": "290000", "wakayama": "300000", "tottori": "310000", "shimane": "320000", "okayama": "330000", "hiroshima": "340000", "yamaguchi": "350000", "tokushima": "360000", "kagawa": "370000", "ehime": "380000", "kochi": "390000", "fukuoka": "400000", "saga": "410000", "nagasaki": "420000", "kumamoto": "430000", "oita": "440000", "miyazaki": "450000", "kagoshima": "460000", "okinawa": "470000", }
  • Helper function that performs the actual HTTP fetch of forecast data from JMA API for the given area code, called by the get_forecast handler.
    async def fetch_forecast(area_code: str) -> list[dict[str, Any]]: """ Fetch weather forecast for a specific area. Args: area_code: JMA area code (e.g., "130000" for Tokyo) Returns: List of forecast data """ url = f"https://www.jma.go.jp/bosai/forecast/data/forecast/{area_code}.json" async with httpx.AsyncClient() as client: response = await client.get(url, timeout=30.0) response.raise_for_status() data: list[dict[str, Any]] = response.json() return data

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/koizumikento/jma-data-mcp'

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