Skip to main content
Glama

KMB Bus MCP Server

KMB Bus MCP Server

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.

Features

  • Real-time bus arrival information (ETA)
  • Comprehensive bus route queries
  • Bus stop information and searches
  • Route-stop mapping
  • Caching system to optimize API calls
  • Bilingual support (English and Traditional Chinese)

Data Source

This project utilizes the official KMB/LWB Open Data API:

Prerequisites

  • Python 3.10 or higher
  • uv package manager

Installation

  1. First, install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Clone the repository:
git clone git@github.com:kennyckk/mcp_hkbus.git cd mcp_hkbus
  1. Use uv to handle the python package:
uv sync #using uv.lock

Usage

  1. Edit the Config in your MCP Client (e.g. Claude Desktop):
{ "mcpServers": { "bus_service": { "command": "path/to/uv.exe", "args": ["--directory", "path/to/kmb_bus", "run", "kmb_mcp.py"], "background": true } } }
  1. The server provides several tools that can be used by Language Models to query bus information:
  • get_route_list(): Get a list of all bus routes
  • get_stop_list(): Get a list of all bus stops
  • get_route_stops(): Get stops for a specific route
  • find_stops_by_name(): Search for bus stops by name
  • get_all_routes_at_stop(): Get all routes serving a specific stop
  • get_eta(): Get estimated arrival times

Testing

Run the test suite using pytest:

pytest test/kmb-mcp-tests.py

Dependencies

  • httpx: For async HTTP requests
  • fastmcp: For MCP server implementation
  • pytest: For testing (development only)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

  • KMB/LWB for providing the open data API
  • The MCP protocol developers

Note

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.

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A Model Context Protocol server that provides real-time access to Hong Kong's KMB and Long Win Bus route information and arrival times, enabling Language Models to answer user questions about bus routes, stops, and ETAs.

  1. Features
    1. Data Source
      1. Prerequisites
        1. Installation
          1. Usage
            1. Testing
              1. Dependencies
                1. Contributing
                  1. Acknowledgments
                    1. Note

                      Related MCP Servers

                      • A
                        security
                        F
                        license
                        A
                        quality
                        Enables Large Language Models to access real-time data on Vilnius public transport stops and routes through the Model Context Protocol.
                        Last updated -
                        2
                        1
                        Python
                      • -
                        security
                        A
                        license
                        -
                        quality
                        A Model Context Protocol Server search realtime flight detail with multiple fligh carrier, price , stop , time duration for any given date using simple prompt
                        Last updated -
                        23
                        Python
                        MIT License
                      • A
                        security
                        A
                        license
                        A
                        quality
                        A Model Context Protocol server that allows large language models to search for and analyze Chinese railway (12306) tickets through a simple API interface.
                        Last updated -
                        8
                        1,400
                        9
                        JavaScript
                        MIT License
                      • -
                        security
                        A
                        license
                        -
                        quality
                        An MCP server providing access to Hong Kong transportation data, including passenger traffic statistics at control points and real-time bus arrival information for KMB and Long Win Bus services.
                        Last updated -
                        3
                        Python
                        MIT License

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/kennyckk/mcp_hkbus'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server