otp-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@otp-mcpHow long does it take from Shinjuku to Shibuya?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
otp-mcp
セルフホストした OpenTripPlanner (OTP) を MCP(Model Context Protocol)サーバー越しに使えるようにするツール。Claude Code や claude.ai から「AからBは電車で何分?」を、自分の手元のOTPが持つ正確な経路データで聞けるようにする。
作った背景
きっかけは、ある公開の経路検索API(MCP付き)を触ったこと。MCP越しに plan_journey を叩いて経路が返ってくる体験はとても便利だった一方、そのAPIは「力技で集めた時刻表のパッチワーク」で、JRの直通・乗継系統(上野東京ライン・京浜東北快速など)を取りこぼし、関東の所要時間を実態の約2倍に誤ることがあった(飲み会場所最適化アプリ arigatai-score の経路エンジン選定の中で実測)。
一方で、自分は arigatai-score 用に 関東全域のOTP(TokyoGTFS + OSM からビルドしたグラフ)を既にセルフホストしている。これは Yahoo!乗換案内とほぼ一致する精度(平均誤差 約3分)を持つ。
だったら「便利なMCPの体験」を「自前OTPの正確なデータ」で実現すればいい——というのがこのツール。
トレードオフはこうなる:
公開API(パッチワーク) | otp-mcp(自前OTP) | |
カバレッジ | 全国だが穴が多い | 関東のみ |
精度 | 平均誤差 約17分 | 平均誤差 約3分 |
「狭いが正確な経路MCP」を狙ったツール。
Related MCP server: gtfs-pro-mcp
設計思想
薄いラッパーに徹する: 経路検索のロジックはOTPに任せ、このサーバーはOTPのGraphQL(
planConnection/stops)を叩いて結果を読みやすく整形するだけ。stdio / HTTP 両対応: ローカルの Claude Code は stdio、claude.ai のリモートコネクタは HTTP(Streamable HTTP + 任意のBearer認証)。1つの実装で両方をカバーする。足場は自分がフォークして使っている scrapbox-cosense-mcp の構成を下敷きにした。
経路の見せ方: leg(区間)ごとに「路線名・駅・所要分」を並べ、出発/到着時刻と乗換回数を添える。
提供ツール
plan_journey(from, to, numItineraries?)— 経路検索。from/toは駅名(例:新宿)か"緯度,経度"。ランク付けされたルートを返す。suggest_stations(q, limit?)— 駅名サジェスト。座標付きで返す。
出力例(plan_journey 新宿 渋谷):
新宿 → 渋谷
【ルート1】15:26 → 15:34 所要8分 乗換0回
🚶 徒歩 4分 → 新宿
🚃 JR湘南新宿ライン 新宿 → 渋谷 4分
🚶 徒歩 1分 → 渋谷前提
経路検索の本体である OTP が動いていて、このサーバーから到達できること。本リポジトリ自体はOTPを含まない。
既定では arigatai-score の docker compose で動くOTP(サービス名
otp、http://otp:8080)を想定別構成のOTPに繋ぐ場合は
OTP_BASE_URLを設定
使い方
Claude Code(ローカル / stdio)
ビルドして、.mcp.json に登録する:
npm install
npm run build{
"mcpServers": {
"otp": {
"command": "node",
"args": ["/home/kouki/dev/otp-mcp/build/index.js"],
"env": { "OTP_BASE_URL": "http://localhost:8080" }
}
}
}OTP_BASE_URL はOTPに到達できるURLにする(OTPのポートをホスト公開している場合は http://localhost:8080 など)。
claude.ai / リモート(HTTP)
Docker Compose で HTTP サーバーとして起動し、Cloudflare Tunnel 等で公開して claude.ai のカスタムコネクタに登録する:
cp .env.example .env # MCP_AUTH_TOKEN を設定推奨
docker compose up -d --buildエンドポイント:
https://<公開ホスト>/mcpMCP_AUTH_TOKENを設定した場合はAuthorization: Bearer <token>が必要既定の compose は arigatai-score の Docker ネットワーク(
arigatai-score_internal)に相乗りしてhttp://otp:8080に到達する
CLI(動作確認用)
node build/index.js plan 新宿 渋谷
node build/index.js suggest 新宿今後の展望
station_departures(発車標)の追加(OTPのstoptimesクエリ)出発/到着時刻の指定
運賃・乗換回数のメタ情報付与
OTPのカバレッジを関東以外へ広げたら、そのまま全国対応に
関連
arigatai-score — このOTPを使う、飲み会場所最適化アプリ
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/ojimpo/otp-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server