ai.smithery/arjunkmrm-sg-bus-test

Get real-time bus arrival times for any Singapore bus stop by code, with optional service filterin…

0No licenseai-ml

Install

Config snippet generator goes here (5 client tabs)

README

# Singapore Bus Arrival MCP Server

An MCP (Model Context Protocol) server that provides real-time bus arrival information for Singapore using the LTA DataMall API.

## Features

- Get real-time bus arrival times for any Singapore bus stop
- Filter by specific bus service number (optional)
- Shows next 3 buses with:
  - Estimated arrival time in minutes
  - Bus capacity status (Seats/Standing Available/Limited Standing)
  - Bus type (Single/Double Deck/Bendy)
  - Wheelchair accessibility
  - Operator information

## Prerequisites

1. **LTA DataMall API Key**: You need to register for a free API key from LTA DataMall:
   - Go to [LTA DataMall](https://datamall.lta.gov.sg/content/datamall/en.html)
   - Create an account and request for API access
   - Copy your API key (AccountKey)

2. **Node.js**: Version 18 or higher

## Installation

```bash
# Install dependencies
npm install
```

## Usage

### Development Mode

```bash
npm run dev
```

The server will start on `http://localhost:3000`

### Testing the Tool

You can test the bus arrival tool using curl:

```bash
# Initialize the connection with your API key
curl -X POST "http://127.0.0.1:3000/mcp?ltaApiKey=YOUR_API_KEY_HERE&debug=false" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"clientInfo":{"name":"test-client","version":"1.0.0"}}}'

# Send initialized notification
curl -X POST "http://127.0.0.1:3000/mcp?ltaApiKey=YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

# Get bus arrival for a specific bus stop (e.g., 83139)
curl -X POST "http://127.0.0.1:3000/mcp?ltaApiKey=YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"get-bus-arrival","arguments":{"busStopCode":"83139"}}}'

# Get arrival for a specific bus service at a bus stop
curl -X POST "http://127.0.0.1:3000/mcp?ltaApiKey=YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"get-bus-arrival","arguments":{"busStopCode":"83139","serviceNo":"15"}}}'
```

Replace `YOUR_API_KEY_HERE` with your actual LTA DataMall API key.

## Configuration

The server requires the following configuration:

- `ltaApiKey` (required): Your LTA DataMall API key (AccountKey)
- `debug` (optional, default: false): Enable debug logging

## API Reference

### Tool: `get-bus-arrival`

Get real-time bus arrival information for a specific bus stop.

**Parameters:**
- `busStopCode` (required): Bus stop reference code (e.g., "83139")
- `serviceNo` (optional): Specific bus service number to filter (e.g., "15")

**Example Response:**
```
📍 Bus Stop: 83139
⏰ Updated: 10/7/2025, 2:30:00 PM

🚌 Service 15 (GAS)
Next: 3 min 🟢 (SEA) | Single Deck ♿
2nd: 8 min 🟡 (SDA) | Double Deck
3rd: 15 min 🟢 (SEA) | Single Deck

🚌 Service 175 (SMRT)
Next: 5 min 🟢 (SEA) | Double Deck
2nd: 12 min 🟢 (SEA) | Double Deck
3rd: No data

🟢 Seats Available | 🟡 Standing Available | 🔴 Limited Standing | ♿ Wheelchair Accessible
```

## Finding Bus Stop Codes

To find bus stop codes:
1. Use the LTA DataMall Bus Stops API: `https://datamall2.mytransport.sg/ltaodataservice/BusStops`
2. Check physical bus stop signs - the code is usually displayed
3. Use third-party apps like SG BusLeh or transit apps

## Deployment

### Deploy to Smithery

1. Push your code to GitHub
2. Go to [smithery.ai/new](https://smithery.ai/new)
3. Connect your repository
4. Smithery will handle the deployment

### Build for Production

```bash
npm run build
```

## Data Update Frequency

The LTA DataMall Bus Arrival API updates every 20 seconds with real-time information.

## Operators

- **SBST**: SBS Transit
- **SMRT**: SMRT Corporation
- **TTS**: Tower Transit Singapore
- **GAS**: Go-Ahead Singapore

## License

ISC