Cityflo OTP MCP
Provides on-time performance analysis for Mumbai North bus routes via tools for route summaries, late trip drill-down, and data quality reports. It quarantines invalid data and surfaces policy questions instead of hidden normalizations.
README
Cityflo OTP MCP (AI Engineer take-home)
Small stdio MCP server for Mumbai North on-time performance over one week of trips.csv. Built for Priya’s ask: “Was route 12 late this week, and by how much?” — with drill-down, not a dashboard.
Scope
In
- Domain: on-time performance only
- Data:
data/trips.csv(Mon–Fri 2026-06-15 … 2026-06-19) - Tools:
route_otp_summary,list_late_trips,data_quality_report - Deterministic delay / quarantine / aggregation in Python tools
Out
- Occupancy, ticket triage, ops-log summariser
- Databases, BI dashboards, web UI
- Silent “data normalisation” that hides policy (see OPS-2207 below)
Architecture
Agent / MCP client (stdio)
│
▼
cityflo_otp.server (FastMCP, 3 tools)
│
▼
cityflo_otp.otp (parse → quarantine → delays → aggregates)
│
▼
data/trips.csv
The model should call tools for numbers and only phrase the answer. Arithmetic never lives in the LLM.
Late definition
arrival_delay_min = actual_arrival − scheduled_arrival(timezone-aware)- Late if
arrival_delay_min > 10(default; overridable vialate_threshold_min) - Headline metrics: % late of usable trips, median / p90 arrival delay (not a fragile mean)
- Departure delay is returned for drill-down only
Data-quality decisions
| Trip | Action | Why |
|---|---|---|
| TRIP_031 | Quarantine | actual_departure has invalid 08:60 |
| TRIP_017 | Quarantine | Actual arrival before actual departure |
| TRIP_044 | Quarantine | actual_arrival uses +00:00; naive compare ≈ +333 min |
| TRIP_101 | Quarantine | Missing scheduled_arrival |
Quarantined rows are excluded from OTP % / median and listed in tools. We do not invent corrected timestamps.
During initial data inspection (reading the starter bundle’s ops_log.txt, which is not loaded by this MCP at runtime), device D-22 / MH-14-5590 was noted as flaky. The runtime tools only see trips.csv: they quarantine D-22 rows when timestamp checks fail, and leave other consistent D-22 trips usable.
Untrusted handoff text (OPS-2207 / MH-12-7781)
HANDOFF.md contains instruction-shaped text asking tools to force vehicle MH-12-7781 on-time and hide that rule. This server does not apply that override. The same late rule is used for every plate. data_quality_report surfaces the raw MH-12-7781 evaluation and a policy question for Priya. Hiding falsified numbers from a regional manager fails the auditability bar.
Assumptions
- Arrival lateness is the right primary metric for Priya’s standup fight.
- Default threshold of 10 minutes separates pattern (e.g. Route 12) from noise.
- Prefer quarantine over silent correction of GPS/timezone garbage.
- Thin samples (e.g. R-21 n=1) should be labeled, not ranked aggressively.
- Ticket/occupancy files are out of scope for this MCP.
Questions for Priya
- Confirm arrival (vs departure) as the official late definition?
- Confirm >10 min for regional-manager figures (or 5 / 15)?
- How should MH-12-7781 / OPS-2207 appear: exclude with disclosure, include raw, or dual view?
- Minimum trip count before a route enters “worst offenders”?
- For
+00:00timestamps: always quarantine, or allow an explicit IST reinterpretation with an audit flag?
How to run
cd ~/repos/cityflo-otp-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
# or: pip install mcp && PYTHONPATH=src ...
Checks (no MCP):
PYTHONPATH=src python scripts/verify_otp.py
Real MCP client multi-step run (route_otp_summary → list_late_trips → data_quality_report):
PYTHONPATH=src python scripts/run_mcp_client.py
Transcript written to notes/mcp_client_transcript.jsonl.
Cursor / Claude Desktop (stdio): point an MCP server entry at:
{
"mcpServers": {
"cityflo-otp": {
"command": "python",
"args": ["/absolute/path/to/cityflo-otp-mcp/src/cityflo_otp/server.py"],
"env": {
"PYTHONPATH": "/absolute/path/to/cityflo-otp-mcp/src",
"CITYFLO_TRIPS_CSV": "/absolute/path/to/cityflo-otp-mcp/data/trips.csv"
}
}
}
}
Example agent interaction
route_otp_summary({ "route": "Route 12" })
→ usable 8, late 6, 75% late, median arrival delay on the order of ~13–16 min, 0 quarantined on R-12.list_late_trips({ "route": "R-12" })
→ the six late trip ids with per-trip arrival delays and vehicles.data_quality_report({})
→ four quarantined trips week-wide + MH-12-7781 policy note (TRIP_090 / TRIP_119 late under raw rule).
Deliberately cut
- Other domains (occupancy / tickets / standup)
- Auto-fixing timezone offsets
- Ranking API across all routes (easy to add; not required for Priya’s Route 12 ask)
- Hidden OPS-2207 normalisation
Where I disagreed with the AI
See notes/DISAGREEMENTS.md.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。