
Onebusaway Mcp Server
io.github.cyanheadsv0.2.0更新於 Oct 8, 2026
Real-time transit stops, routes, arrivals, vehicle positions, and schedules via OneBusAway APIs.
概覽
讓助理查詢 OneBusAway 大眾運輸資料:站點、路線、即時到站、車輛位置、時刻表與服務公告。
- 功能
- 包裝 OneBusAway 運輸 API,提供 16 個工具與 2 個資源。可依位置、名稱或編號尋找站點與路線;回傳含時刻偏差與車輛位置的即時到站資訊;並取得全天時刻表、行程與車輛班次詳情以及服務公告。站點與路線紀錄也以資源形式提供。預設使用 Puget Sound 實例,也可用於其他 OneBusAway 實例。
- 適用情境
- 當助理需要即時或表定的公共運輸資訊時使用,例如附近站點、下一班到站、路線詳情、車輛位置或服務公告。它只提供唯讀運輸資料,不做行程規劃。
- 執行需求
- 可作為遠端 Streamable HTTP 端點執行,也可透過 npm 套件在本機執行,需要 Bun v1.4.0+ 或 Node.js v24+。需要 OneBusAway API 金鑰,放在 ONEBUSAWAY_API_KEY 中;值 TEST 可在 Puget Sound 實例上用於開發。選用設定包括 ONEBUSAWAY_BASE_URL、限流變數與 HTTP 傳輸變數。需要能連線至 OneBusAway 實例的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Onebusaway Mcp Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
其他 MCP 客戶端
把它新增到你客戶端的 mcpServers 設定中。
{
"mcpServers": {
"onebusaway-mcp-server": {
"type": "http",
"url": "https://onebusaway.caseyjhand.com/mcp"
}
}
}README
@cyanheads/onebusaway-mcp-server
Query stops, routes, real-time arrivals, vehicle positions, and schedules from OneBusAway transit APIs via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://onebusaway.caseyjhand.com/mcp
Overview
Real-time transit data and schedules from OneBusAway. It defaults to the Puget Sound instance (King County Metro, Sound Transit, Pierce Transit, Community Transit, and more) and works with any other OneBusAway instance. Find stops and routes, track live arrivals and vehicle positions, and pull full-day schedules, vehicle blocks, and service alerts. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Resources
The same data is available to tool-only clients through onebusaway_get_stop and onebusaway_get_route.
Capability reference
onebusaway_list_agencies tool
- No input; returns every agency with
id, contact info,timezone, andcoverageCenter/coverageSpan limitExceededflags an upstream-capped list, with no pagination to fetch the rest
onebusaway_find_stops tool
lat/lonrequired;radiusin meters, default 300, max 1600; optionalquerymatches the stop code printed on the sign- Each stop carries
id,code,direction,routeIds, andwheelchairBoarding(ACCESSIBLE/NOT_ACCESSIBLE/UNKNOWN);limitExceededmeans more stops exist within the radius
onebusaway_search_stops tool
query(stop name fragment or stop code) required;maxCountup to 100, default 10- Same stop shape as
onebusaway_find_stops;limitExceededmeans more stops matched thanmaxCount
onebusaway_get_stop tool
- Single
stopId; returnsname,code, coordinates,direction,routeIds, andwheelchairBoarding - Unknown IDs fail as
stop_not_found, with recovery viaonebusaway_find_stopsoronebusaway_search_stops
onebusaway_find_routes tool
lat/lonrequired;radiusin meters, default 500, max 1600, or alatSpan+lonSpanbox (both set) in its place; optionalqueryby route name or number- Each route carries
shortName,longName,agencyId, GTFStype(0=tram … 5=cable_car),color, and scheduleurl;limitExceededmeans more routes exist in the area
onebusaway_search_routes tool
query(route name or number) required;maxCountup to 100, default 10- Returns
shortName,longName,agencyId, and GTFStype;limitExceededmeans more routes matched thanmaxCount - Fails as
endpoint_unavailableon instances whose route-search endpoint returns 404, Puget Sound among them; useonebusaway_find_routesoronebusaway_list_routes_for_agencyinstead
onebusaway_get_route tool
- Single
routeId; returnsshortName,longName,description, agency, GTFStype,color, and scheduleurl - Unknown IDs fail as
route_not_found, with recovery viaonebusaway_find_routesoronebusaway_search_routes
onebusaway_list_routes_for_agency tool
agencyIdrequired; unknown agencies fail asagency_not_found- Every route with
shortName,longName, GTFStype,color, andurl;limitExceededflags an upstream-capped list with no pagination
onebusaway_get_arrivals tool
stopIdrequired; the window isminutesBefore(integer 0–60, default 5) /minutesAfter(integer 0–240, default 35), with longer horizons left toonebusaway_get_schedule_for_stop; unknown stops fail asstop_not_found- Each arrival carries
predicted(false = schedule-only),scheduleDeviationin seconds (positive = late, meaningful only when predicted),predictedArrivalTime,vehiclePosition,stopsAway, andtripId - Active alerts arrive in
situations[]: those on the stop itself plus those linked from each arrival'ssituationIds, each once
onebusaway_get_stop_context tool
- Same input as
onebusaway_get_arrivals, and the samestop_not_found/rate_limitedfailures; one call issues one upstream request - Returns
stop(theonebusaway_get_stopfields minusrouteIds),arrivalsin theonebusaway_get_arrivalsshape, andalertsin theonebusaway_get_alertshape — every alert on the stop or on an arrival in the window, including stop-wide alerts no arrival in the window carries - When the upstream response omits the stop,
stopis null; a referenced alert missing from the response is left out; either way anoticenames the tool to fetch it with
onebusaway_get_alert tool
- Single
situationId, fromonebusaway_get_arrivals(situations[].idorarrivals[].situationIds); unknown IDs fail assituation_not_found - Returns a TPEG
reasoncode,severity,consequenceMessage,affects(agency, route, stop, or trip scope),consequenceswith diversion stop IDs, andactiveWindows
onebusaway_get_trip tool
tripIdrequired;serviceDateMs(non-negative integer, midnight local) only for a trip on a previous service day;includeSchedule(default true) adds the stop sequence with GTFS times anddistanceAlongTripMetersstatuscarriesphase(e.g.in_progress,layover_before),predicted,position,scheduleDeviation, andnextStop;blockId(null when the trip has none) feedsonebusaway_get_block- Fails as
trip_not_foundwhen the trip isn't active for the service date; a completed trip's times come fromonebusaway_get_schedule_for_route
onebusaway_get_block tool
- Single
blockId, fromonebusaway_get_trip; unknown IDs fail asblock_not_found - The vehicle's trips for the service day in order, each with
distanceAlongBlock,accumulatedSlackTime(layover seconds), andblockStopTimes;activeServiceIds/inactiveServiceIdsshow which service calendars apply
onebusaway_get_vehicles tool
agencyIdrequired, unknown agencies fail asagency_not_found; optionalrouteIdis filtered client-side after all of the agency's vehicles are fetched- Each vehicle carries
position,orientation,phase,scheduleDeviation,tripId,nextStop, andpredicted(reporting real-time GPS);limitExceededflags an upstream-capped list with no pagination
onebusaway_get_schedule_for_stop tool
stopIdrequired; optionaldateas a realYYYY-MM-DDcalendar date, default (omitted or blank) today in the agency's timezone; unknown stops fail asstop_not_found- Departures grouped by route and direction, each with
scheduledDepartureTimeandtripId - Static schedule only; live predictions come from
onebusaway_get_arrivals
onebusaway_get_schedule_for_route tool
routeIdrequired; optionaldateas a realYYYY-MM-DDcalendar date, default (omitted or blank) today; unknown routes fail asroute_not_found- Every trip that day with
tripId,tripHeadsign,serviceId, and its stop sequence - Static schedule only; live predictions come from
onebusaway_get_arrivalsat a stop
onebusaway://stop/{stopId} resource
- Stop record as
application/json, the same shapeonebusaway_get_stopreturns stopIdcomes fromonebusaway_find_stopsoronebusaway_search_stops
onebusaway://route/{routeId} resource
- Route record as
application/json, the same shapeonebusaway_get_routereturns routeIdcomes fromonebusaway_find_routesoronebusaway_search_routes
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
OneBusAway-specific:
- Wraps
onebusaway-sdkwith typed error classification (NotFound,RateLimited,ValidationErrorfor an upstream 400,ServiceUnavailable) - Defaults to the Puget Sound instance (
api.pugetsound.onebusaway.org), whereONEBUSAWAY_API_KEY=TESTworks for development;ONEBUSAWAY_BASE_URLpoints it at any other OneBusAway instance - Stop and route IDs are agency-prefixed,
{agencyId}_{localId}(stop1_75403, route1_100259); agency IDs are the bare prefix (1for Metro Transit,40for Sound Transit) - One shared pacer, sized by
ONEBUSAWAY_RATE_LIMIT_*, queues every upstream request against the API key's budget; a call that gets no slot within the wait cap fails as retryablerate_limitedwithdata.retryAfter, on any tool - Transit data only, no trip planning; server-level instructions walk agents through the ID format and the common lookup chains
Agent-friendly output:
predictedon every arrival, trip, and vehicle separates GPS-tracked data from schedule-only projections- Machine-readable times:
scheduleDeviationin seconds; arrival, stop-schedule, and update timestamps in Unix milliseconds; trip, route-schedule, and block stop times in GTFS seconds from midnight - Chainable IDs:
stopIdfrom the stop tools feeds arrivals,tripIdfeedsonebusaway_get_trip,blockIdfeedsonebusaway_get_block,situationIdsfeedonebusaway_get_alert, andagencyIdfeeds vehicles and route listing - Typed error contracts whose recovery hints name the next tool to call, plus a
noticeon empty or truncated results
Getting started
Public Hosted Instance
A public instance is available at https://onebusaway.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
Self-Hosted / Local
Add the following to your MCP client configuration file. ONEBUSAWAY_API_KEY=TEST works on the Puget Sound instance without registration.
Or with npx (no Bun required):
Or with Docker:
For Streamable HTTP, set the transport and start the server:
Prerequisites
- Bun v1.4.0 or higher (or Node.js v24+).
- A OneBusAway API key.
TESTworks on the Puget Sound instance for development; for production use or other instances, register at the relevant agency's developer portal.
Installation
- Clone the repository:
- Navigate into the directory:
- Install dependencies:
- Configure environment:
Configuration
See .env.example for the full list of optional overrides.
Running the server
Local development
-
Build and run the production version:
-
Run checks and tests:
Docker
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/onebusaway-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storage - Register new tools and resources in the
createApp()arrays insrc/index.ts - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
License
Apache-2.0 — see LICENSE for details.
Transit data from the default Puget Sound OneBusAway API, operated by Sound Transit and King County Metro, is governed by the Sound Transit Transit Data Terms of Use, and users of the hosted endpoint receive it under those terms. Key obligations:
- Clause 2: usage metrics are available on request.
- Clause 3: data is fetched live from the OneBusAway API and is not modified or cached beyond the request cycle.
- Clause 4: you agree to pass substantially similar terms through to any users you provide this data to.
- Clause 7: this server does not use Sound Transit trademarks in its name or branding.
來源:README.md,提交 5dca0ec
工具
0版本歷史
3- v0.2.0最新Sep 25, 2026
- v0.1.15Sep 20, 2026
- v0.1.14Sep 16, 2026

