Hong Kong Bus

by kennyckk

3 stars
225 downloads
Not rated
GitHub

About

Provides real-time Hong Kong bus information through KMB API integration, enabling users to find routes, locate stops, and check arrival times through conversational queries.

Details

Author
kennyckk
Repository
kennyckk/mcp_hkbus
GitHub stars
3
Downloads
225
License
Apache License 2.0
Categories
AI, Design, Developer Tools, Search, Frontend, Knowledge Base, API, Other
Tags
#integration

- 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)

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Hong Kong Bus
    Command (node, npx, python, etc.) path/to/uv.exe
    Arguments
    • Argument 1 --directory
    • Argument 2 path/to/kmb_bus
    • Argument 3 run
    • Argument 4 kmb_mcp.py

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

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
    }
  }
}

2. 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

To install KMB Bus MCP for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @kennyckk/mcp_hkbus --client claude

1. First, install uv if you haven't already:

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Clone the repository:

git clone git@github.com:kennyckk/mcp_hkbus.git
cd mcp_hkbus

3. Use uv to handle the python package:

uv sync #using uv.lock

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.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "hong kong bus": {
            "env": {},
            "args": [
                "--directory",
                "path/to/kmb_bus",
                "run",
                "kmb_mcp.py"
            ],
            "command": "path/to/uv.exe",
            "background": true
        }
    }
}

Linux

{
    "env": [],
    "args": [
        "--directory",
        "path/to/kmb_bus",
        "run",
        "kmb_mcp.py"
    ],
    "command": "path/to/uv.exe",
    "background": true
}

Macos

{
    "env": [],
    "args": [
        "--directory",
        "path/to/kmb_bus",
        "run",
        "kmb_mcp.py"
    ],
    "command": "path/to/uv.exe",
    "background": true
}

Windows

{
    "env": [],
    "args": [
        "--directory",
        "path/to/kmb_bus",
        "run",
        "kmb_mcp.py"
    ],
    "command": "path/to/uv.exe",
    "background": true
}

MseeP.ai Security Assessment Badge

KMB Bus MCP Server

smithery badge

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.

<a href="https://glama.ai/mcp/servers/@kennyckk/mcp_hkbus">
KMB Bus Server MCP server
</a>

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:

- Base URL: https://data.etabus.gov.hk/v1/transport/kmb
- KMB Open Data API Documentation

Prerequisites

- Python 3.10 or higher
- uv package manager

Installation

Installing via Smithery

To install KMB Bus MCP for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @kennyckk/mcp_hkbus --client claude

Manual Installation

1. First, install uv if you haven't already:

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Clone the repository:

git clone git@github.com:kennyckk/mcp_hkbus.git
cd mcp_hkbus

3. 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
    }
  }
}

2. 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.29:["$","div",nu

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.