Skip to main content
Glama
jshis-mcp

jshis-mcp

by koizumikento
README.md
# jshis-mcp

防災科研の地震ハザードステーション(J-SHIS)のデータを使い、指定した地点で一定以上の揺れが起きる確率や、地盤による揺れの増幅率を調べます。MCP、CLI、Pythonライブラリで使える照会専用のツールです。APIキーは不要です。

[MCP登録](#mcpクライアントに登録する) · [CLI](#cliで使う) · [Pythonライブラリ](#pythonライブラリとして使う)

## 準備

[uv](https://docs.astral.sh/uv/) と Git が必要です。Python 3.12以上に対応しています。MCPやCLIで使う場合は、リポジトリをクローンして依存関係をインストールします。

```sh
git clone https://github.com/koizumikento/jshis-mcp.git
cd jshis-mcp
uv sync --locked
```

## MCPクライアントに登録する

設定例の `/absolute/path/to/jshis-mcp` は、クローン先の絶対パスに置き換えてください。Windowsでは `C:/projects/jshis-mcp` のように書けます。

### Codex

```sh
codex mcp add jshis-mcp -- uv --directory "/absolute/path/to/jshis-mcp" run --locked jshis-mcp
codex mcp list
```

`codex mcp list` に `jshis-mcp` が表示されたら、Codexの新しいセッションで `/mcp` を開いて接続状態を確認してください。[Codexの公式設定ガイド](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)

Codexのデスクトップアプリから登録する場合は、設定の「MCP servers」でSTDIOサーバーを追加し、下のJSON例にあるコマンドと引数を指定します。

### Claude Desktop / Cursor

次のファイルに設定します。

- Claude Desktop(Windows) `%APPDATA%/Claude/claude_desktop_config.json`
- Claude Desktop(macOS) `~/Library/Application Support/Claude/claude_desktop_config.json`
- Cursor `.cursor/mcp.json`(プロジェクト内)

```json
{
  "mcpServers": {
    "jshis-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/jshis-mcp",
        "run",
        "--locked",
        "jshis-mcp"
      ]
    }
  }
}
```

`mcpServers` がすでにある場合は、その中に `jshis-mcp` の項目を追加します。保存したらクライアントを再起動し、ツールが表示されることを確認してください。[設定ファイルの場所と接続手順](https://py.sdk.modelcontextprotocol.io/get-started/real-host/)

クライアントが `uv` を見つけられない場合は、`command` に `uv` の実行ファイルの絶対パスを指定してください。

登録後は、チャットで次のように聞けます。

> 東京駅付近(北緯35.6812度、東経139.7671度)で、30年以内に震度5強以上の揺れが起きる確率を調べて。どの年の評価かも教えて。

## ツール

いずれも緯度・経度(WGS84)を指定します。

| 調べたいこと | ツール | 選べる条件 |
| --- | --- | --- |
| 今後30年間に、ある震度以上の揺れに見舞われる確率 | `get_earthquake_hazard` | `minimum_jma_intensity` に `5-lower`(5弱)、`5-upper`(5強)、`6-lower`(6弱、既定)、`6-upper`(6強) |
| 指定した超過確率に対応する計測震度 | `get_hazard_intensity` | `period_years` は30年(既定)または50年。`exceedance_probability_percent` は30年なら3%・6%(既定は3%)、50年なら2%・5%・10%・39%(既定は5%) |
| 工学的基盤から地表までの最大速度増幅率、地形の区分、平均S波速度 | `get_surface_ground_amplification` | 表層地盤モデルV4 |

例えば、東京駅付近の今後30年間の震度5強以上の確率を調べるには、`get_earthquake_hazard` に次を渡します。

```json
{
  "latitude": 35.6812,
  "longitude": 139.7671,
  "minimum_jma_intensity": "5-upper"
}
```

確率と計測震度の照会には、J-SHISの2024年版(平均ケース・全地震)を使います。約250m四方の区画ごとの長期評価です。結果には評価の版と出典も含まれます。

## CLIで使う

[準備](#準備)でクローンしたディレクトリで、調べたい項目に応じて次のコマンドを実行します。

```sh
uv run jshis-mcp get-earthquake-hazard --latitude 35.6812 --longitude 139.7671 --minimum-jma-intensity 5-upper
uv run jshis-mcp get-hazard-intensity --latitude 35.6812 --longitude 139.7671 --period-years 50 --exceedance-probability-percent 5
uv run jshis-mcp get-surface-ground-amplification --latitude 35.6812 --longitude 139.7671
```

結果はUTF-8のJSONとして標準出力に書き出します。引数を確認するには、サブコマンドに `--help` を付けます。たとえば `uv run jshis-mcp get-earthquake-hazard --help` です。

## Pythonライブラリとして使う

自分のPythonプロジェクト(`pyproject.toml` があるディレクトリ)で依存関係に追加します。

```sh
uv add "git+https://github.com/koizumikento/jshis-mcp.git@main"
```

次のコードを `example.py` に保存し、同じディレクトリで `uv run python example.py` を実行します。

```python
import asyncio

from jshis_mcp import get_earthquake_hazard

result = asyncio.run(get_earthquake_hazard(latitude=35.6812, longitude=139.7671))
print(result)
```

[ツール一覧](#ツール)にある3つのツールは、同じ名前のPython関数として呼び出せます。すでにイベントループが動いている場合は、関数を直接 `await` してください。

## 出典と利用条件

コードはMITライセンスです。地震ハザードと表層地盤のデータは、ツールの実行時に防災科研のJ-SHISから取得します。取得したデータにはJ-SHISの利用規約が適用されます。

- 表層地盤データを資料などに転載・引用する場合は、「表層地盤データ記述ファイル規約」に記載された参考文献を引用してください。
- 地震動予測地図データをそのまま第三者に配布することは、ファイル形式だけを変えた場合も禁止されています。加工した成果物を販売する場合は、防災科研にお問い合わせください。

[J-SHIS利用規約](https://www.j-shis.bosai.go.jp/agreement) · [データと参考文献の案内](https://www.j-shis.bosai.go.jp/download) · [地震ハザードAPI](https://www.j-shis.bosai.go.jp/api-pshm-meshinfo) · [表層地盤API](https://www.j-shis.bosai.go.jp/api-sstruct-meshinfo)

## 開発

```sh
uv sync --locked
uv run ruff check .
uv run ty check
uv run pytest
uv build
```

TDQS

A3.5/5.0

Scored across 3 tools

Disambiguation4/5

The three tools target distinct outputs: hazard probability, intensity at an exceedance probability, and surface amplification/geomorphology. The first two share the same point-based hazard domain and their names could be momentarily confused, but the descriptions clarify the inverse relationship between the queries.

Naming Consistency5/5

All tools follow a consistent snake_case get_<resource> pattern: get_earthquake_hazard, get_hazard_intensity, get_surface_ground_amplification. The convention is predictable and readable throughout.

Tool Count5/5

Three tools is a well-scoped surface for a focused point-based seismic hazard lookup server. Each tool provides a distinct hazard or site-amplification product, and no tool appears redundant.

Completeness4/5

The set covers the core JSHIS-style point queries: probabilistic hazard, intensity at exceedance probabilities, and surface amplification with geomorphology. Minor gaps such as metadata, supported probability/period enumeration as a separate tool, or bulk/point-list operations are not present but can likely be worked around from the descriptions.

Maintenance

ActivityMaintained
ResponsivenessOutdated data