Skip to main content
Glama
Hong Kong Bus ETA MCP

Hong Kong Bus ETA MCP

by devanshg03
README.md
# Hong Kong Bus ETA MCP API Wrapper

This project is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server built as a wrapper for the Hong Kong government's bus ETA API from [data.gov.hk](https://data.gov.hk/en-data/dataset/hk-td-tis_21-etakmb). The MCP server provides tools to search bus routes, stops, and get real-time arrival times for KMB and LWB bus services.

```javascript
// index.ts - MCP server mounted on /mcp endpoint
app.post('/mcp', async (req: Request, res: Response) => {
  try {
    const transport: StreamableHTTPServerTransport = new StreamableHTTPServerTransport({
      sessionIdGenerator: undefined,
    });
    await server.connect(transport);
    await transport.handleRequest(req, res, req.body);
    ...

// mcp-server.ts - Available MCP tools
server.tool('search_bus_routes', 'Search for bus routes by number or destination', ...)
server.tool('search_bus_stops', 'Search for bus stops by name', ...)
server.tool('get_bus_eta', 'Get real-time bus arrival times for a stop', ...)
server.tool('get_route_stops', 'Get all stops for a specific route', ...)
```

## Quick Start

```bash
# Install dependencies
npm install

# Build the project
npm run build

# Run the dev server
npm run dev
```

## MCP Client Connection

To connect Claude Desktop to this Hong Kong Bus ETA MCP server, add the server to your `claude_desktop_config.json` file:

```json
{
  "mcpServers": {
    "hk-bus-eta": {
      "command": "npx",
      "args": ["mcp-remote", "http://localhost:4000/mcp"]
    }
  }
}
```

## Usage Examples

Once connected, you can ask Claude to help with Hong Kong bus information:

> "What bus routes go to Central?"

> "When is the next bus arriving at Admiralty Station?"

> "Show me all stops for bus route 104 going outbound"

> "Find bus stops near Times Square"

The MCP tools will automatically fetch real-time data from the Hong Kong government's official bus API.