odpt-mcp
Click on "Deploy 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., "@odpt-mcp What are the weekday inner-loop train times from Shinjuku on the Oedo Line?"
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.
odpt-mcp
都営地下鉄、東京さくらトラム、日暮里・舎人ライナーの駅・路線、時刻表、運行情報、駅間運賃を調べられます。都営バスの停留所、時刻表、経路、運賃も調べられます。データは公共交通オープンデータセンター(ODPT)から取得します。
uv と Git が必要です。Python 3.12以上に対応しています。このツールが使う都営交通の公開APIはキー不要です。
MCPクライアントに登録する
Codex
codex mcp add odpt-mcp -- uvx --python 3.12 --from git+https://github.com/koizumikento/odpt-mcp.git@main odpt-mcp
codex mcp list新しいセッションで /mcp を開いて接続を確認できます。デスクトップ版ではMCP設定画面で、下のJSON例と同じコマンド・引数を指定できます。
Claude Desktop / Cursor
Claude Desktop(Windows)
%APPDATA%/Claude/claude_desktop_config.jsonClaude Desktop(macOS)
~/Library/Application Support/Claude/claude_desktop_config.jsonCursor
.cursor/mcp.json(プロジェクト内)
設定ファイルの mcpServers に項目を追加して、クライアントを再起動してください。uvx が見つからない場合は実行ファイルの絶対パスを指定します。
{
"mcpServers": {
"odpt-mcp": {
"command": "uvx",
"args": [
"--python",
"3.12",
"--from",
"git+https://github.com/koizumikento/odpt-mcp.git@main",
"odpt-mcp"
]
}
}
}都営大江戸線の新宿駅で、平日の内回りの時刻表を調べて。運行情報に案内があれば、更新時刻と一緒に教えて。
Related MCP server: japan-transit-mcp
MCPツール
ツール | できること | 主な入力 |
| 都営の駅や路線を和名・英名の部分一致で検索 |
|
| 駅の発車時刻、方向、行先の駅ID、終電フラグを取得 |
|
| 都営各路線の運行情報と提供元の更新時刻・有効期限を取得 |
|
| 指定した駅間の大人・小児のIC運賃ときっぷ運賃を円で取得 |
|
| 都営バスの停留所を日本語名で完全一致検索し、乗り場ごとのID・座標を取得 |
|
| 停留所の発車時刻、系統、行先を取得 |
|
| 経路パターンに含まれる停留所を順に取得 |
|
| 同じバス経路パターン内の2停留所間の運賃を円で取得 |
|
鉄道は search_railway が返す id を後続のツールに渡します。バスは search_bus_stops の停留所IDから発車時刻を取得できます。経路を調べるには、停留所検索の route_pattern_ids または時刻表の route_pattern_id を使います。
時刻表の
available_timetablesから曜日区分と方向・系統を選べます。大江戸線の例はodpt.Calendar:Weekday(平日)とodpt.RailDirection:InnerLoop(内回り)です。バスでは各時刻表のtitleに「平日」「土曜」「休日」などの区分が含まれます。時刻表は時刻表IDごとにまとまり、各時刻表内は提供元の運行日内の順序です。深夜0時台の便が23時台の後に続く場合があります。
ページ分割するツールの
limitは1〜50件(既定10件)です。続きはnext_offsetをoffsetに渡します。search_railwayではlimitのみ指定できます。運行情報は照会ごとに公開APIから取得します。回答に使う際は提供元の
updated_atとvalid_untilを確認してください。0件の場合、指定した条件に一致する案内が提供元から返っていません。運行状況と時刻表には別々のツールを使います。運賃は提供元の登録額を返します。バス運賃には経路上の乗車・降車停留所IDを指定します。乗り継ぎを含む運賃計算には対応していません。
対応範囲は駅・停留所単位の発車時刻、鉄道の路線単位の運行案内、経路・運賃です。便単位の全停車時刻、車両位置、乗降者数、GTFS/GTFS-RTの取得は別のデータセットです。
CLIで使う
GitHubから直接実行できます。
uvx --python 3.12 --from git+https://github.com/koizumikento/odpt-mcp.git@main odpt-mcp search-railway --kind station --query 新宿 --limit 3クローン済みの場合は uv run odpt-mcp で同じ操作ができます。
uv run odpt-mcp get-station-timetable --station-id odpt.Station:Toei.Oedo.Shinjuku --calendar-id odpt.Calendar:Weekday --direction-id odpt.RailDirection:InnerLoop --limit 3
uv run odpt-mcp get-train-status --line-id odpt.Railway:Toei.Oedo
uv run odpt-mcp get-railway-fare --from-station-id odpt.Station:Toei.Oedo.Shinjuku --to-station-id odpt.Station:Toei.Oedo.Tochomae
uv run odpt-mcp search-bus-stops --name 新宿駅西口 --limit 3
uv run odpt-mcp get-bus-stop-timetable --stop-id odpt.BusstopPole:Toei.ShinjukuStationNishiguchi.702.1 --route-id odpt.Busroute:Toei.Shuku74 --limit 3
uv run odpt-mcp get-bus-route --pattern-id odpt.BusroutePattern:Toei.Shuku74.12001.1 --limit 3
uv run odpt-mcp get-bus-fare --pattern-id odpt.BusroutePattern:Toei.Shuku74.12001.1 --from-stop-id odpt.BusstopPole:Toei.ShinjukuStationNishiguchi.702.1 --to-stop-id odpt.BusstopPole:Toei.Kabukicho.334.2結果は標準出力にUTF-8のJSONで返ります。各サブコマンドの --help で引数を確認できます。
Pythonから呼び出す
git clone https://github.com/koizumikento/odpt-mcp.git
cd odpt-mcp
uv sync --lockedimport asyncio
from odpt_mcp import get_station_timetable, search_railway
async def main():
stations = await search_railway("station", query="新宿", limit=10)
station = next(
item
for item in stations["items"]
if item["name"] == "新宿" and item["line_id"] == "odpt.Railway:Toei.Oedo"
)
result = await get_station_timetable(
station["id"],
calendar_id="odpt.Calendar:Weekday",
direction_id="odpt.RailDirection:InnerLoop",
limit=3,
)
print(result["items"])
asyncio.run(main())表にある各ツールを同名の非同期関数として odpt_mcp からインポートできます。既にイベントループがある場合は関数を直接 await してください。
出典と利用条件
コードはMIT Licenseです。東京都交通局・公共交通オープンデータ協議会のデータを絞り込み、項目を整形して返します。各結果には出典URL、提供者名、ライセンスURLが含まれます。CC BY 4.0
開発
uv sync --locked
uv run ruff check .
uv run ty check
uv run pytest
uv buildAvailable Tools
8 toolsget_bus_fareARead-onlyIdempotent
Get listed Toei bus fares in yen between two stops on the same route pattern.
Inputs: pattern_id (required), to_stop_id (required), from_stop_id (required). Returns: result
get_bus_routeBRead-onlyIdempotent
List stops along a Toei bus route pattern from search_bus_stops or its timetable.
Inputs: pattern_id (required), limit, offset. Returns: result
get_bus_stop_timetableBRead-onlyIdempotent
Get scheduled Toei bus departures from a stop ID returned by search_bus_stops.
available_timetables lists services with their weekday/holiday labels,
calendar IDs, and route IDs. Departures retain the provider's order.
Inputs: stop_id (required), limit, offset, route_id, +1 more. Returns: result
get_railway_fareARead-onlyIdempotent
Get listed Toei rail fares in yen for an exact pair of station IDs.
Inputs: to_station_id (required), from_station_id (required). Returns: result
get_station_timetableARead-onlyIdempotent
Get scheduled Toei rail departures by station ID from search_railway.
Filter by full ODPT calendar and rail direction IDs. Departures retain
the provider's service-day order within each timetable.
Inputs: station_id (required), limit, offset, calendar_id, +1 more. Returns: result
get_train_statusARead-onlyIdempotent
Get Toei rail service notices with provider timestamps and expiry.
Supply a line ID from search_railway to restrict the notices. An empty
result means the API returned no matching notices. Check valid_until
before using a notice as current information.
Inputs: line_id. Returns: result
search_bus_stopsARead-onlyIdempotent
Find Toei bus stops by exact Japanese name and get their platform IDs.
Inputs: name (required), limit, offset. Returns: result
search_railwayBRead-onlyIdempotent
Find stations or railway lines operated by Toei, by Japanese or English name.
Inputs: kind (required), limit, query. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct resource+action: search (railway/stops) vs. schedule (timetable) vs. price (fare) vs. status, cleanly partitioned between the rail and bus domains. An agent can unambiguously route a transit query to one tool, and the descriptions reinforce the IDs each downstream tool needs.
All names use consistent snake_case with a verb_noun structure (search_railway, get_station_timetable, get_bus_fare). The domain noun (railway vs. bus) is predictable across the set, with no mixed conventions.
Eight tools is well within the ideal range and each earns its place: a search, timetable, fare, and status tool for each of the two transit domains. Nothing is redundant or obviously missing from a count perspective.
The surface covers the core lifecycle for both rail and bus: find the entity, get its schedule, get the fare, plus rail service status. Minor gaps remain, such as resolving a line to its full station sequence or listing all stops on a rail line (the bus side has get_bus_route but the rail side lacks an equivalent).
Maintenance
Related MCP Connectors
Real-time transit stops, routes, arrivals, vehicle positions, and schedules via OneBusAway APIs.
Read-only public transit departures, stop search, and city coverage for bus and train users.
Japan: next bus/tram/boat from 26 places, RTK bases, JMA warnings, municipality facts. No key.
政府統計 (e-Stat) の API を通じて、統計データやメタ情報を取得するためのサービスです。
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables querying Swiss public transport (trains, buses, trams, boats) for stations, connections, and station boards via the opendata.ch API.-
- AlicenseBqualityDmaintenanceEnables route planning and transit information retrieval for Japan using the public Transit API. Supports searching stations, planning routes, and checking departures.102MIT
- AlicenseNot gradedqualityCmaintenanceEnables real-time access to Boston MBTA transit data (subway, bus, commuter rail, etc.) via the MBTA v3 API.279 npmMIT
- AlicenseAqualityBmaintenanceIntegrates ODPT and JMA APIs to provide comprehensive transit information, route search, weather, and AI advice for the Tokyo metropolitan area.131MIT