gsi-elevation-mcp
by koizumikento
README.md
# gsi-elevation-mcp
緯度・経度を指定すると、国土地理院のデータからその地点の標高(m)と測量データの種類を取得できます。最大10地点を指定して、標高を入力順に比較できます。
## 利用前に
[uv](https://docs.astral.sh/uv/) と Git が必要です。Python 3.12以上に対応しています。APIキーの設定は不要です。
## MCPクライアントに登録する
公開GitHubリポジトリから `uvx` で起動します。初回は依存関係の準備に時間がかかることがあります。
### Codex
```sh
codex mcp add gsi-elevation-mcp -- uvx --python 3.12 --from git+https://github.com/koizumikento/gsi-elevation-mcp.git@main gsi-elevation-mcp
codex mcp list
```
`codex mcp list` で登録を確認し、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`(プロジェクト内)
既に `mcpServers` がある場合は、その中にサーバーの項目を追加してください。保存後にクライアントを再起動し、ツールが表示されるか確認します。[設定ファイルの場所と接続手順](https://py.sdk.modelcontextprotocol.io/get-started/real-host/)
```json
{
"mcpServers": {
"gsi-elevation-mcp": {
"command": "uvx",
"args": [
"--python",
"3.12",
"--from",
"git+https://github.com/koizumikento/gsi-elevation-mcp.git@main",
"gsi-elevation-mcp"
]
}
}
}
```
`uvx` が見つからない場合は、設定のコマンドに実行ファイルの絶対パスを指定してください。
登録後は、チャットで次のように聞けます。
> 北緯36.103543度、東経140.08531度の標高を、測量データの種類と一緒に教えて。
## MCPツール
| ツール | 用途 |
| --- | --- |
| `get_elevation` | 緯度・経度から標高と測量データの種類を取得 |
| `get_elevations` | 指定した1〜10地点の標高と測量データの種類を入力順に取得 |
`get_elevations` は `points` に `latitude` と `longitude` の組を受け取ります。国土地理院には地点ごとに順番に1回ずつ問い合わせます。取得できた標高が2件以上ある場合、`elevation_range_m` に最高値と最低値の差を返します。それ以外は `null` です。
## CLIで使う
結果は標準出力にUTF-8のJSONで返ります。
```sh
uvx --python 3.12 --from git+https://github.com/koizumikento/gsi-elevation-mcp.git@main gsi-elevation-mcp get-elevation --latitude 36.103543 --longitude 140.08531
uvx --python 3.12 --from git+https://github.com/koizumikento/gsi-elevation-mcp.git@main gsi-elevation-mcp get-elevations --point 36.103543 140.08531 --point 35.681236 139.767125
```
## Pythonから呼び出す
リポジトリをクローンし、依存関係を準備します。
```sh
git clone https://github.com/koizumikento/gsi-elevation-mcp.git
cd gsi-elevation-mcp
uv sync --locked
```
次の例を `example.py` に保存し、クローン先で `uv run --locked python example.py` を実行します。
```python
import asyncio
from gsi_elevation_mcp import ElevationPoint, get_elevation, get_elevations
print(asyncio.run(get_elevation(latitude=36.103543, longitude=140.08531)))
points = [
ElevationPoint(latitude=36.103543, longitude=140.08531),
ElevationPoint(latitude=35.681236, longitude=139.767125),
]
print(asyncio.run(get_elevations(points)))
```
## データの出典と利用条件
標高データのない地点は `elevation_m` と `measurement_source` が `null` になります。国土地理院の試験公開APIを利用します。アクセス頻度を抑えてください。[公式仕様と使用上の注意](https://maps.gsi.go.jp/development/elevation_s.html)
MIT Licenseはこのリポジトリのコードに適用します。
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues