九巴資訊服務
STDIO香港九巴及龍運實時路線資訊服務
香港九巴及龍運實時路線資訊服務
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 [email protected]: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.