BusTime MCP
Wraps the CTA Bus Tracker API to provide live access to bus routes, stops, predictions, vehicle locations, patterns, and detours via MCP clients.
README
BusTime MCP
An MCP server that wraps the CTA (Chicago Transit Authority) Bus Tracker API, giving MCP clients live access to CTA bus routes, stops, predictions, vehicle locations, patterns, and detours. Built with FastMCP and deployed via Prefect Horizon.
Features
- Full coverage of the CTA Bus Tracker v3 API (routes, directions, stops, patterns, predictions, vehicles, locales, detours, enhanced detours, system time)
- Async HTTP via
httpx, with clean error handling for missing config, bad status codes, and network failures - In-memory TTL caching on slow-changing endpoints (routes, directions, stops, patterns, locales, detours) — real-time endpoints (predictions, vehicles, time) always hit the live API
- Server-level
instructionsand per-tool descriptions designed to help MCP clients chain calls correctly (e.g. routes → directions → stops → predictions) - Test suite covering the HTTP layer, caching behavior, and tool parameter validation
Prerequisites
- A CTA Bus Tracker developer API key
- A GitHub account, with this repo pushed to it (Horizon deploys from a GitHub repo)
- A Horizon account (free personal tier)
Getting a CTA API key
- Sign up for and activate a Bus Tracker account
- Sign in, then go to My Account (upper right)
- Follow the Developer API link to apply for a key
Full details: CTA Developer Center — Bus Tracker APIs
Deploying to Horizon
-
Push this repo to GitHub (public or private both work).
-
Sign in to horizon.prefect.io with GitHub and connect the repo.
-
On the configure screen, set:
- Entrypoint:
main.py:mcp - Authentication: enable this if you want to restrict access to your org rather than leaving the endpoint open — see Rate limits below for why that matters here.
- Dependencies are auto-detected from
pyproject.toml— nothing to configure manually.
- Entrypoint:
-
Set
CTA_URLandCTA_API_KEYas environment variables/secrets for the deployment. Horizon's configuration screen should have a place for this; check the current UI when you get there, since the exact field wasn't fully documented at the time this was written. -
Click Deploy. You'll get a live URL, typically in under 60 seconds:
https://<your-server-name>.fastmcp.app/mcp
Horizon rebuilds and redeploys automatically on every push to main, and builds preview deployments for PRs.
Verifying before you deploy
uv run fastmcp inspect main.py:mcp
This shows what Horizon will see when it runs the server — tools, resources, and prompts — so you can catch config problems locally before pushing.
Connecting a client once deployed
Once live, MCP clients connect by URL rather than by spawning a local process:
{
"mcpServers": {
"BusTime": {
"url": "https://<your-server-name>.fastmcp.app/mcp"
}
}
}
Horizon also provides its own Inspector and ChatMCP for testing the deployed server directly in the browser before wiring up any client.
Available tools
| Tool | Endpoint | Cached? |
|---|---|---|
get_routes() |
/getroutes |
24h |
get_directions(rt) |
/getdirections |
24h |
get_stops_for_route(rt, direction) |
/getstops |
30 min |
get_patterns(pid=, rt=) |
/getpatterns |
1h |
get_predictions_for_stop(stpid, rt, top) |
/getpredictions |
never (real-time) |
get_vehicle(vid) |
/getvehicles |
never (real-time) |
get_time(unix_time=) |
/gettime |
never (real-time) |
get_locale_list(locale=, in_locale_language=) |
/getlocalelist |
24h |
get_detours(rt=, direction=) |
/getdetours |
2 min |
get_enhanced_detours() |
/getenhanceddetours |
2 min |
Typical call sequence: get_routes → get_directions(rt) → get_stops_for_route(rt, direction) → get_predictions_for_stop(stpid, rt, top). See the server's instructions string in main.py for the full call graph, including how patterns, vehicles, and detours fit in.
Known limitation: get_enhanced_detours may return an "Unsupported function" error depending on your API key — this endpoint is GTFS-RT-oriented and appears to require CTA to enable it per-account. This is a CTA-side limitation, not a bug in this server.
Caching
Cacheable endpoints use a simple in-memory TTL cache (see _cached_get in main.py) keyed by endpoint path + parameters. TTLs are set per-endpoint based on how often the underlying data actually changes.
The cache is in-memory and per-instance. It resets on restart/redeploy, and if Horizon ever runs multiple replicas of this server, each replica has its own independent cache rather than a shared one — still correct, just less effective at cutting duplicate calls than a single-instance setup.
Testing
uv sync
uv run pytest -v
Tests use pytest-asyncio (auto mode) and respx to mock HTTP calls — no real network access or live API key is needed to run them. Run this before every push, since Horizon redeploys automatically on main.
Project structure
.
├── main.py # server entrypoint + all tool definitions
├── pyproject.toml # dependencies (uv-managed; also read by Horizon for auto dependency detection)
├── tests/
│ ├── conftest.py # makes main.py importable from tests/
│ └── test_main.py
└── README.md
Rate limits
CTA's Bus Tracker API defaults to a 100,000 request/day limit per key. This server's caching helps reduce call volume for slow-changing data, but there's currently no built-in tracking or backoff as you approach that limit. This matters more once deployed publicly: a hosted URL can be called by anyone who finds it, unlike a local stdio server only you can spawn — enabling Horizon's authentication option (above) is the simplest way to keep usage scoped to people you trust.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。