Skip to main content
Glama
KMB Bus MCP Server

KMB Bus MCP Server

by kennyckk

KMBバスMCPサーバー

香港のKMB(九龍巴士)とLong Win Bus(龍運巴士)の路線情報と到着時刻にリアルタイムでアクセスできるモデルコンテキストプロトコル(MCP)サーバー。このサーバーにより、言語モデルは香港のバスサービス情報を照会し、バスの路線、停留所、到着予定時刻に関するユーザーの質問に答えることができます。

特徴

  • リアルタイムのバス到着情報(ETA)

  • 包括的なバス路線検索

  • バス停情報と検索

  • ルート停留所マッピング

  • API呼び出しを最適化するキャッシュシステム

  • バイリンガルサポート(英語と中国語(繁体字))

Related MCP server: Hong Kong Transportation MCP Server

データソース

このプロジェクトでは、公式の KMB/LWB オープン データ API を利用しています。

前提条件

  • Python 3.10以上

  • UVパッケージマネージャー

インストール

  1. まず、まだインストールしていない場合は uv をインストールします。

curl -LsSf https://astral.sh/uv/install.sh | sh
  1. リポジトリをクローンします。

git clone git@github.com:kennyckk/mcp_hkbus.git
cd mcp_hkbus
  1. uv を使用して Python パッケージを処理します。

uv sync #using uv.lock

使用法

  1. MCP クライアント (例: Claude Desktop) で構成を編集します。

{
  "mcpServers": {
    "bus_service": {
      "command": "path/to/uv.exe",
      "args": ["--directory", "path/to/kmb_bus", "run", "kmb_mcp.py"],
      "background": true
    }
  }
}
  1. サーバーは、言語モデルがバス情報を照会するために使用できるいくつかのツールを提供します。

  • get_route_list() : すべてのバス路線のリストを取得する

  • get_stop_list() : すべてのバス停のリストを取得する

  • get_route_stops() : 特定のルートの停留所を取得する

  • find_stops_by_name() : バス停を名前で検索する

  • get_all_routes_at_stop() : 特定の停留所を通るすべてのルートを取得する

  • get_eta() : 到着予定時刻を取得する

テスト

pytest を使用してテスト スイートを実行します。

pytest test/kmb-mcp-tests.py

依存関係

  • httpx : 非同期HTTPリクエスト用

  • fastmcp : MCPサーバーの実装用

  • pytest : テスト用(開発のみ)

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

謝辞

  • オープンデータAPIを提供するKMB/LWB

  • MCPプロトコル開発者

注記

このサービスはKMB/LWB Open Data APIに依存しています。APIのレート制限に留意し、本番環境では適切なエラー処理を実装してください。

Available Tools

5 tools
find_buses_to_destinationB

Find bus routes that go to a specified destination.

Args:
    destination: The destination to search for (e.g., "Central", "Mong Kok", "Airport")

Inputs: destination (required). Returns: result

find_stop_by_nameA

Find bus stops matching a name or partial name.

Args:
    stop_name: Full or partial name of the bus stop to search for

Inputs: stop_name (required). Returns: result

get_all_routes_at_stopB

Get all bus routes that pass through a specified bus stop.

Args:
    stop_name: Name of the bus stop

Inputs: stop_name (required). Returns: result

get_next_busB

Get the next arrival time for a specified bus route at a stop.

Args:
    route: The bus route number (e.g., "1A", "6", "960")
    stop_name: The name of the bus stop

Inputs: route (required), stop_name (required). Returns: result

get_route_stops_infoB

Get all stops along a specified bus route.

Args:
    route: The bus route number (e.g., "1A", "6", "960")

Inputs: route (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: finding buses to destinations, searching stops by name, getting routes at a stop, checking next bus arrivals, and listing stops on a route. The descriptions reinforce these unique functions, making misselection unlikely.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with underscores (e.g., find_buses_to_destination, get_route_stops_info). The naming is uniform and predictable, using clear action verbs like 'find' and 'get' paired with descriptive nouns.

    Tool Count5/5

    With 5 tools, this server is well-scoped for a bus information system. Each tool serves a specific, necessary function in querying routes, stops, and schedules, avoiding bloat while covering core use cases effectively.

    Completeness4/5

    The tool set covers essential bus information queries: route discovery, stop lookup, schedule checking, and route details. A minor gap exists in lacking tools for broader operations like route planning or real-time updates, but agents can work around this with the provided tools.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    Appeared in Searches