Connects Claude to Hong Kong's KMB and Long Win Bus open data API to query real time bus arrivals and route information. Exposes six tools including get_route_list for browsing all routes, find_stops_by_name for searching stops, get_route_stops for mapping routes to stops, and get_eta for estimated arrival times. Built with fastmcp and includes a caching layer to reduce API calls. Responses come in both English and Traditional Chinese. Reach for this when building transit assistants for Hong Kong or adding local bus information to Hong Kong focused applications. Uses the official data.etabus.gov.hk API with Python 3.10+ and uv package manager.
A Model Context Protocol (MCP) server that provides real-time access to Hong Kong's KMB (九龍巴士) and Long Win Bus (龍運巴士) route information and arrival times. This server enables Language Models to query Hong Kong bus service information to answer user questions about bus routes, stops, and estimated arrival times.
This project utilizes the official KMB/LWB Open Data API:
To install KMB Bus MCP for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @kennyckk/mcp_hkbus --client claude
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone git@github.com:kennyckk/mcp_hkbus.git
cd mcp_hkbus
uv sync #using uv.lock
{
"mcpServers": {
"bus_service": {
"command": "path/to/uv.exe",
"args": ["--directory", "path/to/kmb_bus", "run", "kmb_mcp.py"],
"background": true
}
}
}
get_route_list(): Get a list of all bus routesget_stop_list(): Get a list of all bus stopsget_route_stops(): Get stops for a specific routefind_stops_by_name(): Search for bus stops by nameget_all_routes_at_stop(): Get all routes serving a specific stopget_eta(): Get estimated arrival timesRun the test suite using pytest:
pytest test/kmb-mcp-tests.py
httpx: For async HTTP requestsfastmcp: For MCP server implementationpytest: For testing (development only)Contributions are welcome! Please feel free to submit a Pull Request.
This service relies on the KMB/LWB Open Data API. Please be mindful of API rate limits and implement appropriate error handling in production environments.