Skip to main content

MCP Server for BMKG Indonesia - Weather, Earthquake, and Region Data for AI Assistants

Project description

BMKG API

Docker PyPI Python 3.12+ FastAPI License: MIT

English | Bahasa Indonesia


๐Ÿ‡ฌ๐Ÿ‡ง English

Free REST API for Indonesian weather forecasts, earthquake data, weather warnings, and region lookup from BMKG.

๐ŸŒ Demo: https://bmkg-restapi.vercel.app

โš ๏ธ Important Notice

This is a demo/public instance with rate limits (30 requests/minute) to ensure fair usage.

For production use with unlimited requests, please self-host.

Features

  • ๐ŸŒ Earthquake Data โ€” Latest, recent (M 5.0+), felt earthquakes, nearby search by coordinates
  • ๐ŸŒค๏ธ Weather Forecast โ€” 3-day forecasts & current weather for any kelurahan/desa in Indonesia
  • โš ๏ธ Weather Warnings (Nowcast) โ€” Real-time severe weather alerts with affected area polygons
  • ๐Ÿ“ Region Lookup โ€” Indonesian provinces, districts, subdistricts, villages, plus search
  • ๐Ÿ“Š Auto-generated Docs โ€” Interactive API documentation at /docs
  • โšก Caching โ€” Fast responses with in-memory cache (configurable TTL)
  • ๐ŸŒ CORS Enabled โ€” Use from any frontend
  • ๐Ÿ”“ No API Key Required โ€” Simple, anonymous access
  • ๐Ÿ“ˆ Rate Limit Headers โ€” X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset on every response
  • ๐Ÿณ Docker & GHCR โ€” Automated multi-arch Docker images published to GitHub Container Registry
  • ๐Ÿค– MCP Server โ€” Model Context Protocol for AI assistants (Claude, Cursor, etc.)

Quick Start

# Latest earthquake
curl https://bmkg-restapi.vercel.app/v1/earthquake/latest

# Weather forecast for Pejaten Barat, Pasar Minggu, Jakarta Selatan
curl https://bmkg-restapi.vercel.app/v1/weather/31.74.04.1006

# Current weather
curl https://bmkg-restapi.vercel.app/v1/weather/31.74.04.1006/current

# Active weather warnings
curl https://bmkg-restapi.vercel.app/v1/nowcast

# Search regions
curl https://bmkg-restapi.vercel.app/v1/wilayah/search?q=tebet

API Endpoints

๐ŸŒ Earthquake

Endpoint Description
GET /v1/earthquake/latest Latest earthquake
GET /v1/earthquake/recent Recent earthquakes (M 5.0+)
GET /v1/earthquake/felt Felt earthquakes
GET /v1/earthquake/nearby?lat=&lon=&radius_km= Nearby earthquakes

๐ŸŒค๏ธ Weather

Endpoint Description
GET /v1/weather/{adm4_code} 3-day forecast for a kelurahan/desa
GET /v1/weather/{adm4_code}/current Current weather for a kelurahan/desa

โš ๏ธ Nowcast (Weather Warnings)

Endpoint Description
GET /v1/nowcast Active weather warnings by province
GET /v1/nowcast/{alert_code} Warning detail with affected area polygons
GET /v1/nowcast/check?location= Check warnings for a specific location

๐Ÿ“ Wilayah (Region)

Endpoint Description
GET /v1/wilayah/provinces List provinces
GET /v1/wilayah/districts?province_code= List districts
GET /v1/wilayah/subdistricts?district_code= List subdistricts
GET /v1/wilayah/villages?subdistrict_code= List villages
GET /v1/wilayah/search?q={query} Search regions

Full documentation: https://bmkg-restapi.vercel.app/docs

๐Ÿค– MCP Server (for AI Assistants)

PyPI

Use BMKG data directly in Claude Desktop, Cursor, VS Code, Windsurf, Zed, and other MCP-compatible AI assistants.

Installation

# Via pipx (recommended)
pipx install bmkg-api-mcp

# Via pip
pip install bmkg-api-mcp

Quick Setup

Claude Desktop:

# Edit config file
nano ~/Library/Application\ Support/Claude/claude_desktop_config.json

Add this to your config:

{
  "mcpServers": {
    "bmkg-api": {
      "command": "bmkg-api-mcp"
    }
  }
}

Cursor:

  1. Open Settings โ†’ Features โ†’ MCP Servers
  2. Click "Add New MCP Server"
  3. Name: bmkg-api, Type: command, Command: bmkg-api-mcp

VS Code (Cline/Roo Code):

{
  "mcpServers": {
    "bmkg-api": {
      "command": "bmkg-api-mcp",
      "disabled": false,
      "autoApprove": []
    }
  }
}

Available Tools (15)

Category Tools
๐ŸŒ Earthquake get_latest_earthquake, get_recent_earthquakes, get_felt_earthquakes, get_nearby_earthquakes
๐ŸŒค๏ธ Weather get_weather_forecast, get_current_weather
โš ๏ธ Nowcast get_weather_warnings, check_location_warnings
๐Ÿ“ Region search_regions, get_provinces, get_districts, get_subdistricts, get_villages
๐Ÿ”ง Utility get_cache_stats, debug_ping

Example Prompts

Try these natural language queries in your AI assistant:

"Gempa terbaru di Indonesia berapa magnitudenya?"
"Cuaca 3 hari ke depan di Jakarta Selatan?"
"Cari kode wilayah untuk Kelapa Gading"
"Ada peringatan cuaca ekstrem di Yogyakarta?"
"Gempa dengan magnitud di atas 5 derajat minggu ini?"
"Bandung ada gempa dekat-dekat sini?"

Features

  • โšก Caching โ€” Smart TTL-based caching for optimal performance
  • ๐Ÿ› Debug Mode โ€” Run bmkg-api-mcp --debug for verbose logging
  • ๐Ÿ”Œ 7 Specialized Prompts โ€” Earthquake, weather, region, emergency, travel, research, and daily briefing assistants

๐Ÿ“– Full Setup Guide: See MCP_SETUP.md for detailed configuration for all supported IDEs.

Self-Hosting

Option 1: Docker (Recommended)

# Pull from GitHub Container Registry
docker pull ghcr.io/dhanyyudi/bmkg-api:latest

# Or build and run with Docker Compose
git clone https://github.com/dhanyyudi/bmkg-api.git
cd bmkg-api
docker-compose up -d

Option 2: Local Development

git clone https://github.com/dhanyyudi/bmkg-api.git
cd bmkg-api
make setup
source venv/bin/activate
make dev     # starts server on http://localhost:8099

Option 3: Vercel (Serverless)

Deploy to Vercel with one click โ€” the api/index.py and vercel.json are pre-configured.

See Self-Hosting Guide for detailed instructions.

Code Examples

Available on the landing page for: cURL, JavaScript, Python, Go, PHP, Ruby, and Dart (Flutter).


๐Ÿ‡ฎ๐Ÿ‡ฉ Bahasa Indonesia

API REST gratis untuk prakiraan cuaca, data gempa bumi, peringatan cuaca, dan pencarian wilayah Indonesia dari BMKG.

๐ŸŒ Demo: https://bmkg-restapi.vercel.app

โš ๏ธ Pemberitahuan Penting

Ini adalah instance demo/publik dengan batasan rate limit (30 request/menit).

Untuk penggunaan produksi dengan request tanpa batas, silakan self-host.

Fitur

  • ๐ŸŒ Data Gempa โ€” Gempa terbaru, terkini (M 5.0+), dirasakan, pencarian radius
  • ๐ŸŒค๏ธ Prakiraan Cuaca โ€” 3 hari & cuaca saat ini untuk lokasi mana pun di Indonesia
  • โš ๏ธ Peringatan Cuaca (Nowcast) โ€” Peringatan dini real-time dengan poligon area terdampak
  • ๐Ÿ“ Pencarian Wilayah โ€” Provinsi, kabupaten, kecamatan, desa, plus pencarian
  • ๐Ÿ“Š Dokumentasi Auto โ€” Dokumentasi API interaktif di /docs
  • โšก Caching โ€” Response cepat dengan cache lokal (TTL bisa dikonfigurasi)
  • ๐ŸŒ CORS Enabled โ€” Bisa dipakai dari frontend mana saja
  • ๐Ÿ”“ Tanpa API Key โ€” Akses sederhana dan anonim
  • ๐Ÿ“ˆ Rate Limit Headers โ€” X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset di setiap response
  • ๐Ÿณ Docker & GHCR โ€” Image Docker multi-arsitektur otomatis di GitHub Container Registry
  • ๐Ÿค– MCP Server โ€” Model Context Protocol untuk AI assistants (Claude, Cursor, dll)

Cepat Mulai

# Gempa terbaru
curl https://bmkg-restapi.vercel.app/v1/earthquake/latest

# Prakiraan cuaca Pejaten Barat, Pasar Minggu, Jakarta Selatan
curl https://bmkg-restapi.vercel.app/v1/weather/31.74.04.1006

# Cuaca saat ini
curl https://bmkg-restapi.vercel.app/v1/weather/31.74.04.1006/current

# Peringatan cuaca aktif
curl https://bmkg-restapi.vercel.app/v1/nowcast

# Cari wilayah
curl https://bmkg-restapi.vercel.app/v1/wilayah/search?q=wiradesa

Endpoint API

๐ŸŒ Gempa Bumi

Endpoint Deskripsi
GET /v1/earthquake/latest Gempa terbaru
GET /v1/earthquake/recent Gempa terkini (M 5.0+)
GET /v1/earthquake/felt Gempa dirasakan
GET /v1/earthquake/nearby?lat=&lon=&radius_km= Gempa terdekat

๐ŸŒค๏ธ Cuaca

Endpoint Deskripsi
GET /v1/weather/{adm4_code} Prakiraan 3 hari
GET /v1/weather/{adm4_code}/current Cuaca saat ini

โš ๏ธ Nowcast (Peringatan Cuaca)

Endpoint Deskripsi
GET /v1/nowcast Peringatan cuaca aktif per provinsi
GET /v1/nowcast/{alert_code} Detail peringatan dengan poligon area
GET /v1/nowcast/check?location= Cek peringatan untuk lokasi tertentu

๐Ÿ“ Wilayah

Endpoint Deskripsi
GET /v1/wilayah/provinces Daftar provinsi
GET /v1/wilayah/districts?province_code= Daftar kabupaten/kota
GET /v1/wilayah/subdistricts?district_code= Daftar kecamatan
GET /v1/wilayah/villages?subdistrict_code= Daftar desa/kelurahan
GET /v1/wilayah/search?q={query} Cari wilayah

Dokumentasi lengkap: https://bmkg-restapi.vercel.app/docs

๐Ÿค– MCP Server (untuk AI Assistants)

PyPI

Gunakan data BMKG langsung di Claude Desktop, Cursor, VS Code, Windsurf, Zed, dan AI assistants lain yang kompatibel dengan MCP.

Instalasi

# Via pipx (direkomendasikan)
pipx install bmkg-api-mcp

# Via pip
pip install bmkg-api-mcp

Setup Cepat

Claude Desktop:

# Edit file config
nano ~/Library/Application\ Support/Claude/claude_desktop_config.json

Tambahkan ke config:

{
  "mcpServers": {
    "bmkg-api": {
      "command": "bmkg-api-mcp"
    }
  }
}

Cursor:

  1. Buka Settings โ†’ Features โ†’ MCP Servers
  2. Klik "Add New MCP Server"
  3. Name: bmkg-api, Type: command, Command: bmkg-api-mcp

VS Code (Cline/Roo Code):

{
  "mcpServers": {
    "bmkg-api": {
      "command": "bmkg-api-mcp",
      "disabled": false,
      "autoApprove": []
    }
  }
}

Tools Tersedia (15)

Kategori Tools
๐ŸŒ Gempa get_latest_earthquake, get_recent_earthquakes, get_felt_earthquakes, get_nearby_earthquakes
๐ŸŒค๏ธ Cuaca get_weather_forecast, get_current_weather
โš ๏ธ Nowcast get_weather_warnings, check_location_warnings
๐Ÿ“ Wilayah search_regions, get_provinces, get_districts, get_subdistricts, get_villages
๐Ÿ”ง Utility get_cache_stats, debug_ping

Contoh Prompt

Coba query bahasa alami ini di AI assistant Anda:

"Gempa terbaru di Indonesia berapa magnitudenya?"
"Cuaca 3 hari ke depan di Jakarta Selatan?"
"Cari kode wilayah untuk Kelapa Gading"
"Ada peringatan cuaca ekstrem di Yogyakarta?"
"Gempa dengan magnitud di atas 5 derajat minggu ini?"
"Bandung ada gempa dekat-dekat sini?"

Fitur

  • โšก Caching โ€” Caching cerdas dengan TTL untuk performa optimal
  • ๐Ÿ› Debug Mode โ€” Jalankan bmkg-api-mcp --debug untuk logging detail
  • ๐Ÿ”Œ 7 Prompt Spesialis โ€” Asisten gempa, cuaca, wilayah, darurat, travel, riset, dan briefing harian

๐Ÿ“– Panduan Lengkap: Lihat MCP_SETUP.md untuk konfigurasi detail semua IDE yang didukung.

Self-Hosting

Opsi 1: Docker (Direkomendasikan)

# Pull dari GitHub Container Registry
docker pull ghcr.io/dhanyyudi/bmkg-api:latest

# Atau build dan jalankan dengan Docker Compose
git clone https://github.com/dhanyyudi/bmkg-api.git
cd bmkg-api
docker-compose up -d

Opsi 2: Lokal

git clone https://github.com/dhanyyudi/bmkg-api.git
cd bmkg-api
make setup
source venv/bin/activate
make dev     # jalankan server di http://localhost:8099

Opsi 3: Vercel (Serverless)

Deploy ke Vercel โ€” api/index.py dan vercel.json sudah dikonfigurasi.

Lihat Panduan Self-Hosting untuk detail.

Contoh Kode

Tersedia di halaman utama untuk: cURL, JavaScript, Python, Go, PHP, Ruby, dan Dart (Flutter).


Data Source

All data is sourced from BMKG (Badan Meteorologi, Klimatologi, dan Geofisika).

Attribution

This API is not affiliated with BMKG. All data belongs to BMKG.

License

MIT License โ€” see LICENSE


Built with โค๏ธ by dhanypedia

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bmkg_api_mcp-1.0.2.tar.gz (57.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bmkg_api_mcp-1.0.2-py3-none-any.whl (60.0 kB view details)

Uploaded Python 3

File details

Details for the file bmkg_api_mcp-1.0.2.tar.gz.

File metadata

  • Download URL: bmkg_api_mcp-1.0.2.tar.gz
  • Upload date:
  • Size: 57.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bmkg_api_mcp-1.0.2.tar.gz
Algorithm Hash digest
SHA256 59124299fe4d8fe66da855c571fc8696ccffdc53040af963404cea425c88d08c
MD5 fb627accbfc647f123bd737f995c2cdd
BLAKE2b-256 758a4c43d7fee8f994e34c0d0a211dc37fa04c0ca8dca2652066850185bd9d45

See more details on using hashes here.

File details

Details for the file bmkg_api_mcp-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: bmkg_api_mcp-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 60.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bmkg_api_mcp-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45a4005a8ef55494a68978f7d125be06b1b7932294c5ca264537ba19b0bbd7ec
MD5 998734fd0b9c6ecec5173e5e97c5bc93
BLAKE2b-256 9d04f0a3739398f7c06361b8789a47d6931049cd042a889226729dce10ecf293

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page