mbta-mcp


Namembta-mcp JSON
Version 1.0.17 PyPI version JSON
download
home_pageNone
SummaryMCP server for MBTA V3 API
upload_time2025-07-29 01:13:45
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.11
licenseApache-2.0
keywords api boston mbta mcp transit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MBTA MCP Server

![PyPI - Version](https://img.shields.io/pypi/v/mbta-mcp?link=https%3A%2F%2Fpypi.org%2Fproject%2Fmbta-mcp%2F)

An MCP (Model Context Protocol) server for the MBTA V3 API, providing access to Boston's public transit data.

## Features

- **Routes**: Get information about MBTA routes (subway, bus, commuter rail, ferry)
- **Stops**: Find transit stops by location, route, or ID
- **Predictions**: Real-time arrival predictions
- **Schedules**: Scheduled service times
- **Trips**: Trip information and details
- **Alerts**: Service alerts and disruptions
- **Vehicles**: Real-time vehicle positions
- **External APIs**: Vehicle positions and alerts from external sources
- **Track Predictions**: Machine learning-powered track assignment predictions
- **Historical Data**: Access to historical track assignments and performance metrics
- **Caching**: Memory-based caching with configurable TTL for improved performance

## Installation

### Option 1: Direct run with uv (Easiest)

No installation required! Just run directly:

```bash
uv tool run mbta-mcp
```

Set your MBTA API key as an environment variable:

```bash
export MBTA_API_KEY=your_api_key_here
uv tool run mbta-mcp
```

### Option 2: Install as a tool

Install directly with uv tool:

```bash
uv tool install mbta-mcp
```

Set your MBTA API key:

```bash
export MBTA_API_KEY=your_api_key_here
```

Run the server:

```bash
mbta-mcp
```

### Option 3: Development Setup

1. Clone and install dependencies:

   ```bash
   git clone https://github.com/cubismod/mbta-mcp.git
   cd mbta-mcp
   uv sync
   ```

2. Configure your MBTA API key:

   ```bash
   cp .env.example .env
   # Edit .env and add your MBTA_API_KEY
   ```

3. Get an API key from <https://api-v3.mbta.com>

## Usage

### MCP Server (for AI clients)

Run the MCP server for use with AI clients like Claude Desktop:

```bash
# Direct run (no installation needed)
uv tool run mbta-mcp

# If installed as a tool
mbta-mcp

# If using development setup
uv run mbta-mcp
```

### CLI Interface (for direct usage)

For direct command-line access to MBTA and Amtrak data:

```bash
# Show available commands
uv run mbta-cli --help

# Get Amtrak trains
uv run mbta-cli trains --limit 5

# Get Amtrak trains in JSON format
uv run mbta-cli trains --json --limit 3

# Test MBTA routes
uv run mbta-cli routes

# Show available MCP tools
uv run mbta-cli tools
```

### Available Tools

**Core Transit Data:**

- `mbta_get_routes` - Get MBTA routes (subway, bus, commuter rail, ferry)
- `mbta_get_stops` - Get MBTA stops by ID, route, or location
- `mbta_get_predictions` - Get real-time arrival predictions
- `mbta_get_schedules` - Get scheduled service times
- `mbta_get_trips` - Get trip information and details
- `mbta_get_alerts` - Get service alerts and disruptions
- `mbta_get_vehicles` - Get real-time vehicle positions

**Extended Features:**

- `mbta_get_services` - Get service definitions and calendars
- `mbta_get_shapes` - Get route shape/path information for mapping
- `mbta_get_facilities` - Get facility information (elevators, escalators, parking)
- `mbta_get_live_facilities` - Get real-time facility status and outages
- `mbta_search_stops` - Search for stops by name or near a location
- `mbta_get_nearby_stops` - Get stops near a specific location
- `mbta_get_predictions_for_stop` - Get all predictions for a specific stop

**External API Tools:**

- `mbta_get_vehicle_positions` - Get real-time vehicle positions from external API (GeoJSON format)
- `mbta_get_external_alerts` - Get general alerts from external API (delays, disruptions, service info)

**Boston Amtrak Tracker API:**

- `mbta_get_amtrak_trains` - Get all tracked Amtrak trains from Boston Amtrak Tracker API
- `mbta_get_amtrak_trains_geojson` - Get Amtrak trains as GeoJSON for mapping applications
- `mbta_get_amtrak_health_status` - Get health status of the Boston Amtrak Tracker API

**IMT Track Prediction API:**

- `mbta_get_track_prediction` - Predict which track a train will use at a station
- `mbta_get_chained_track_predictions` - Get multiple track predictions in a single request
- `mbta_get_prediction_stats` - Get prediction statistics and accuracy metrics
- `mbta_get_historical_assignments` - Get historical track assignments for analysis

## Tool Reference

### Core Transit Data Tools

#### `mbta_get_routes`

Get information about MBTA routes including subway, bus, commuter rail, and ferry services.

- **Parameters:** `route_id` (optional), `route_type` (optional), `page_limit` (default: 10)
- **Route Types:** 0=Light Rail, 1=Subway, 2=Commuter Rail, 3=Bus, 4=Ferry

#### `mbta_get_stops`

Find transit stops by location, route, or ID with optional filtering.

- **Parameters:** `stop_id` (optional), `route_id` (optional), `latitude`/`longitude` (optional), `radius` (optional), `page_limit` (default: 10)

#### `mbta_get_predictions`

Get real-time arrival predictions for MBTA services.

- **Parameters:** `stop_id` (optional), `route_id` (optional), `trip_id` (optional), `page_limit` (default: 10)

#### `mbta_get_schedules`

Get scheduled service times and departure information.

- **Parameters:** `stop_id` (optional), `route_id` (optional), `trip_id` (optional), `direction_id` (optional), `page_limit` (default: 10)

#### `mbta_get_trips`

Get trip information and details for MBTA services.

- **Parameters:** `trip_id` (optional), `route_id` (optional), `direction_id` (optional), `page_limit` (default: 10)

#### `mbta_get_alerts`

Get service alerts and disruptions affecting MBTA services.

- **Parameters:** `alert_id` (optional), `route_id` (optional), `stop_id` (optional), `page_limit` (default: 10)

#### `mbta_get_vehicles`

Get real-time vehicle positions and status information.

- **Parameters:** `vehicle_id` (optional), `route_id` (optional), `trip_id` (optional), `page_limit` (default: 10)

### Extended Features Tools

#### `mbta_get_services`

Get service definitions and calendars for MBTA operations.

- **Parameters:** `service_id` (optional), `page_limit` (default: 10)

#### `mbta_get_shapes`

Get route shape/path information for mapping and visualization.

- **Parameters:** `shape_id` (optional), `route_id` (optional), `page_limit` (default: 10)

#### `mbta_get_facilities`

Get facility information including elevators, escalators, and parking areas.

- **Parameters:** `facility_id` (optional), `stop_id` (optional), `facility_type` (optional), `page_limit` (default: 10)

#### `mbta_get_live_facilities`

Get real-time facility status and outage information.

- **Parameters:** `facility_id` (optional), `page_limit` (default: 10)

#### `mbta_search_stops`

Search for stops by name or near a specific location.

- **Parameters:** `query` (required), `latitude`/`longitude` (optional), `radius` (optional), `page_limit` (default: 10)

#### `mbta_get_nearby_stops`

Get stops near a specific location within a specified radius.

- **Parameters:** `latitude` (required), `longitude` (required), `radius` (default: 1000), `page_limit` (default: 10)

#### `mbta_get_predictions_for_stop`

Get all predictions for a specific stop with optional filtering.

- **Parameters:** `stop_id` (required), `route_id` (optional), `direction_id` (optional), `page_limit` (default: 10)

### External API Tools

#### `mbta_get_vehicle_positions`

Get real-time vehicle positions from external API in GeoJSON format.

- **Parameters:** None
- **Returns:** GeoJSON with vehicle locations, routes, status, speed, and bearing information

#### `mbta_get_external_alerts`

Get general alerts from external API including delays, disruptions, and service information.

- **Parameters:** None
- **Returns:** JSON with alert details, severity levels, affected routes/stops, and active periods

### Boston Amtrak Tracker API Tools

#### `mbta_get_amtrak_trains`

Get all tracked Amtrak trains from the Boston Amtrak Tracker API.

- **Parameters:** None
- **Returns:** JSON with real-time Amtrak train locations, routes, status, speed, and other information

#### `mbta_get_amtrak_trains_geojson`

Get Amtrak trains as GeoJSON for mapping applications.

- **Parameters:** None
- **Returns:** GeoJSON feature collection with train locations suitable for mapping

#### `mbta_get_amtrak_health_status`

Get health status of the Boston Amtrak Tracker API.

- **Parameters:** None
- **Returns:** JSON with server health status and last data update time

### IMT Track Prediction API Tools

#### `mbta_get_track_prediction`

Predict which track a train will use at a specific station using machine learning.

- **Parameters:** `station_id` (required), `route_id` (required), `trip_id` (required), `headsign` (required), `direction_id` (required), `scheduled_time` (required)
- **Returns:** Track prediction with confidence score and prediction method

#### `mbta_get_chained_track_predictions`

Get multiple track predictions in a single request for batch processing.

- **Parameters:** `predictions` (required) - Array of prediction request objects
- **Returns:** Array of track predictions with confidence scores

#### `mbta_get_prediction_stats`

Get prediction statistics and accuracy metrics for a station and route.

- **Parameters:** `station_id` (required), `route_id` (required)
- **Returns:** Statistics including accuracy rate, total predictions, correct predictions, and average confidence

#### `mbta_get_historical_assignments`

Get historical track assignments for analysis and pattern recognition.

- **Parameters:** `station_id` (required), `route_id` (required), `days` (default: 30)
- **Returns:** Historical track assignment data with actual usage patterns

## Integration with LLMs

### Claude Desktop

#### Option 1: Using uv tool run (Easiest - No Installation Required)

**Add to Claude Desktop configuration:**

On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "mbta": {
      "command": "uv",
      "args": ["tool", "run", "mbta-mcp"],
      "env": {
        "MBTA_API_KEY": "your_api_key_here"
      }
    }
  }
}
```

On Windows, edit `%APPDATA%\Claude\claude_desktop_config.json` with the same content.

#### Option 2: Using uv tool install (Recommended for Regular Use)

1. **Install the MCP server:**

   ```bash
   uv tool install mbta-mcp
   ```

2. **Add to Claude Desktop configuration:**

   On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

   ```json
   {
     "mcpServers": {
       "mbta": {
         "command": "mbta-mcp",
         "env": {
           "MBTA_API_KEY": "your_api_key_here"
         }
       }
     }
   }
   ```

   On Windows, edit `%APPDATA%\Claude\claude_desktop_config.json` with the same content.

#### Option 3: Using development setup

1. **Clone and setup the MCP server:**

   ```bash
   git clone https://github.com/cubismod/mbta-mcp.git
   cd mbta-mcp
   task install-dev
   task verify  # Ensure everything works
   ```

2. **Configure your MBTA API key:**

   ```bash
   cp .env.example .env
   # Edit .env and add: MBTA_API_KEY=your_api_key_here
   ```

3. **Add to Claude Desktop configuration:**

   On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

   ```json
   {
     "mcpServers": {
       "mbta": {
         "command": "uv",
         "args": ["run", "mbta-mcp"],
         "cwd": "/path/to/your/mbta-mcp",
         "env": {
           "MBTA_API_KEY": "your_api_key_here"
         }
       }
     }
   }
   ```

   On Windows, edit `%APPDATA%\Claude\claude_desktop_config.json` with the same content.

**Restart Claude Desktop** and you'll see "mbta" in the 🔌 icon, indicating the MCP server is connected.

### Other MCP-Compatible LLMs

#### Continue.dev

**Using uv tool run (easiest):**

```json
{
  "mcpServers": [
    {
      "name": "mbta",
      "command": "uv",
      "args": ["tool", "run", "mbta-mcp"],
      "env": {
        "MBTA_API_KEY": "your_api_key_here"
      }
    }
  ]
}
```

**Using uv tool installation:**

```json
{
  "mcpServers": [
    {
      "name": "mbta",
      "command": "mbta-mcp",
      "env": {
        "MBTA_API_KEY": "your_api_key_here"
      }
    }
  ]
}
```

**Or with development setup:**

```json
{
  "mcpServers": [
    {
      "name": "mbta",
      "command": "uv",
      "args": ["run", "mbta-mcp"],
      "cwd": "/path/to/your/mbta-mcp",
      "env": {
        "MBTA_API_KEY": "your_api_key_here"
      }
    }
  ]
}
```

#### Codeium

**Using uv tool run (easiest):**

```json
{
  "mcp": {
    "servers": {
      "mbta": {
        "command": ["uv", "tool", "run", "mbta-mcp"],
        "env": {
          "MBTA_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}
```

**Using uv tool installation:**

```json
{
  "mcp": {
    "servers": {
      "mbta": {
        "command": ["mbta-mcp"],
        "env": {
          "MBTA_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}
```

**Or with development setup:**

```json
{
  "mcp": {
    "servers": {
      "mbta": {
        "command": ["uv", "run", "mbta-mcp"],
        "cwd": "/path/to/your/mbta-mcp",
        "env": {
          "MBTA_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}
```

#### Generic MCP Client

**Using uv tool run (easiest):**

- **Command:** `uv tool run mbta-mcp`
- **Environment:** `MBTA_API_KEY=your_api_key_here`

**Using uv tool install:**

- **Command:** `mbta-mcp`
- **Environment:** `MBTA_API_KEY=your_api_key_here`

**Using development setup:**

- **Command:** `uv run mbta-mcp`
- **Working Directory:** `/path/to/your/mbta-mcp`
- **Environment:** `MBTA_API_KEY=your_api_key_here`

### Usage Examples

Once connected, you can ask your LLM questions like:

- "What are the next Red Line trains from Harvard?"
- "Are there any service alerts for the Green Line?"
- "Find the nearest T stops to 42.3601° N, 71.0589° W"
- "What bus routes serve Kendall Square?"
- "Show me the schedule for Route 1 bus"
- "Get real-time vehicle positions for all MBTA vehicles"
- "What are the current service alerts and delays?"
- "Predict which track the 3:30 PM Providence train will use at South Station"
- "Show me track prediction accuracy statistics for South Station"
- "Get historical track assignments for the last 30 days"
- "Get all current Amtrak trains in the Boston area"
- "Show me Amtrak trains as GeoJSON for mapping"
- "Check the health status of the Amtrak tracker API"

### Troubleshooting

**Server not connecting:**

1. Verify the path in your config is correct
2. Ensure `uv` is installed and in your PATH
3. Check that the MBTA API key is valid
4. Run `task test-server` to verify the server works

**API rate limiting:**

- The MBTA API has rate limits; the server includes pagination to manage this
- Some endpoints work without an API key, but having one increases limits

**Configuration issues:**

- Ensure your `.env` file is in the project root
- API key should be set as `MBTA_API_KEY=your_key_here`
- Check Claude Desktop logs if the server fails to start

## API Key Requirements

- **Free access:** Many endpoints work without an API key (with lower rate limits)
- **API key benefits:** Higher rate limits and access to all features
- **Get a key:** Register at <https://api-v3.mbta.com>
- **Usage:** Set in `.env` file or environment variable `MBTA_API_KEY`

## External APIs

This MCP server integrates with additional external APIs to provide enhanced functionality:

### Vehicle Positions API

- **Endpoint:** <https://vehicles.ryanwallace.cloud/>
- **Format:** GeoJSON with real-time vehicle locations, routes, and status
- **No authentication required**
- **Data:** Vehicle coordinates, route information, speed, bearing, occupancy status

### External Alerts API

- **Endpoint:** <https://vehicles.ryanwallace.cloud/alerts>
- **Format:** JSON with service alerts, delays, and disruptions
- **No authentication required**
- **Data:** Alert headers, effects, severity levels, affected routes/stops, active periods

### IMT Track Prediction API

- **Endpoint:** <https://imt.ryanwallace.cloud/>
- **Format:** JSON with machine learning-powered track predictions
- **No authentication required**
- **Data:** Track predictions, confidence scores, historical assignments, accuracy metrics

### Boston Amtrak Tracker API

- **Endpoint:** <https://bos.ryanwallace.cloud/>
- **Format:** JSON and GeoJSON with real-time Amtrak train tracking
- **No authentication required**
- **Data:** Train locations, routes, status, speed, and health information


## Development

This project uses [Task](https://taskfile.dev/) for build automation. Install it and run:

```bash
task --list  # Show available tasks
```

### Common Tasks

```bash
task install-dev    # Install dependencies including dev tools
task check          # Run all checks (format, lint, typecheck)
task test-server    # Test MCP server functionality
task run            # Run the MBTA MCP server
task verify         # Full project verification
```

### Manual Commands

Install dev dependencies:

```bash
uv sync --dev
```

Run formatters and linters:

```bash
task format     # or: uv run ruff format mbta_mcp/
task lint       # or: uv run ruff check mbta_mcp/
task typecheck  # or: uv run mypy mbta_mcp/
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mbta-mcp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "api, boston, mbta, mcp, transit",
    "author": null,
    "author_email": "Ryan Wallace <ryan@hexa.mozmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ac/65/36dbc1661cb0b4f1b79809981d8a63ff5f77b3bbd4720eb84c73df6f11f0/mbta_mcp-1.0.17.tar.gz",
    "platform": null,
    "description": "# MBTA MCP Server\n\n![PyPI - Version](https://img.shields.io/pypi/v/mbta-mcp?link=https%3A%2F%2Fpypi.org%2Fproject%2Fmbta-mcp%2F)\n\nAn MCP (Model Context Protocol) server for the MBTA V3 API, providing access to Boston's public transit data.\n\n## Features\n\n- **Routes**: Get information about MBTA routes (subway, bus, commuter rail, ferry)\n- **Stops**: Find transit stops by location, route, or ID\n- **Predictions**: Real-time arrival predictions\n- **Schedules**: Scheduled service times\n- **Trips**: Trip information and details\n- **Alerts**: Service alerts and disruptions\n- **Vehicles**: Real-time vehicle positions\n- **External APIs**: Vehicle positions and alerts from external sources\n- **Track Predictions**: Machine learning-powered track assignment predictions\n- **Historical Data**: Access to historical track assignments and performance metrics\n- **Caching**: Memory-based caching with configurable TTL for improved performance\n\n## Installation\n\n### Option 1: Direct run with uv (Easiest)\n\nNo installation required! Just run directly:\n\n```bash\nuv tool run mbta-mcp\n```\n\nSet your MBTA API key as an environment variable:\n\n```bash\nexport MBTA_API_KEY=your_api_key_here\nuv tool run mbta-mcp\n```\n\n### Option 2: Install as a tool\n\nInstall directly with uv tool:\n\n```bash\nuv tool install mbta-mcp\n```\n\nSet your MBTA API key:\n\n```bash\nexport MBTA_API_KEY=your_api_key_here\n```\n\nRun the server:\n\n```bash\nmbta-mcp\n```\n\n### Option 3: Development Setup\n\n1. Clone and install dependencies:\n\n   ```bash\n   git clone https://github.com/cubismod/mbta-mcp.git\n   cd mbta-mcp\n   uv sync\n   ```\n\n2. Configure your MBTA API key:\n\n   ```bash\n   cp .env.example .env\n   # Edit .env and add your MBTA_API_KEY\n   ```\n\n3. Get an API key from <https://api-v3.mbta.com>\n\n## Usage\n\n### MCP Server (for AI clients)\n\nRun the MCP server for use with AI clients like Claude Desktop:\n\n```bash\n# Direct run (no installation needed)\nuv tool run mbta-mcp\n\n# If installed as a tool\nmbta-mcp\n\n# If using development setup\nuv run mbta-mcp\n```\n\n### CLI Interface (for direct usage)\n\nFor direct command-line access to MBTA and Amtrak data:\n\n```bash\n# Show available commands\nuv run mbta-cli --help\n\n# Get Amtrak trains\nuv run mbta-cli trains --limit 5\n\n# Get Amtrak trains in JSON format\nuv run mbta-cli trains --json --limit 3\n\n# Test MBTA routes\nuv run mbta-cli routes\n\n# Show available MCP tools\nuv run mbta-cli tools\n```\n\n### Available Tools\n\n**Core Transit Data:**\n\n- `mbta_get_routes` - Get MBTA routes (subway, bus, commuter rail, ferry)\n- `mbta_get_stops` - Get MBTA stops by ID, route, or location\n- `mbta_get_predictions` - Get real-time arrival predictions\n- `mbta_get_schedules` - Get scheduled service times\n- `mbta_get_trips` - Get trip information and details\n- `mbta_get_alerts` - Get service alerts and disruptions\n- `mbta_get_vehicles` - Get real-time vehicle positions\n\n**Extended Features:**\n\n- `mbta_get_services` - Get service definitions and calendars\n- `mbta_get_shapes` - Get route shape/path information for mapping\n- `mbta_get_facilities` - Get facility information (elevators, escalators, parking)\n- `mbta_get_live_facilities` - Get real-time facility status and outages\n- `mbta_search_stops` - Search for stops by name or near a location\n- `mbta_get_nearby_stops` - Get stops near a specific location\n- `mbta_get_predictions_for_stop` - Get all predictions for a specific stop\n\n**External API Tools:**\n\n- `mbta_get_vehicle_positions` - Get real-time vehicle positions from external API (GeoJSON format)\n- `mbta_get_external_alerts` - Get general alerts from external API (delays, disruptions, service info)\n\n**Boston Amtrak Tracker API:**\n\n- `mbta_get_amtrak_trains` - Get all tracked Amtrak trains from Boston Amtrak Tracker API\n- `mbta_get_amtrak_trains_geojson` - Get Amtrak trains as GeoJSON for mapping applications\n- `mbta_get_amtrak_health_status` - Get health status of the Boston Amtrak Tracker API\n\n**IMT Track Prediction API:**\n\n- `mbta_get_track_prediction` - Predict which track a train will use at a station\n- `mbta_get_chained_track_predictions` - Get multiple track predictions in a single request\n- `mbta_get_prediction_stats` - Get prediction statistics and accuracy metrics\n- `mbta_get_historical_assignments` - Get historical track assignments for analysis\n\n## Tool Reference\n\n### Core Transit Data Tools\n\n#### `mbta_get_routes`\n\nGet information about MBTA routes including subway, bus, commuter rail, and ferry services.\n\n- **Parameters:** `route_id` (optional), `route_type` (optional), `page_limit` (default: 10)\n- **Route Types:** 0=Light Rail, 1=Subway, 2=Commuter Rail, 3=Bus, 4=Ferry\n\n#### `mbta_get_stops`\n\nFind transit stops by location, route, or ID with optional filtering.\n\n- **Parameters:** `stop_id` (optional), `route_id` (optional), `latitude`/`longitude` (optional), `radius` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_predictions`\n\nGet real-time arrival predictions for MBTA services.\n\n- **Parameters:** `stop_id` (optional), `route_id` (optional), `trip_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_schedules`\n\nGet scheduled service times and departure information.\n\n- **Parameters:** `stop_id` (optional), `route_id` (optional), `trip_id` (optional), `direction_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_trips`\n\nGet trip information and details for MBTA services.\n\n- **Parameters:** `trip_id` (optional), `route_id` (optional), `direction_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_alerts`\n\nGet service alerts and disruptions affecting MBTA services.\n\n- **Parameters:** `alert_id` (optional), `route_id` (optional), `stop_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_vehicles`\n\nGet real-time vehicle positions and status information.\n\n- **Parameters:** `vehicle_id` (optional), `route_id` (optional), `trip_id` (optional), `page_limit` (default: 10)\n\n### Extended Features Tools\n\n#### `mbta_get_services`\n\nGet service definitions and calendars for MBTA operations.\n\n- **Parameters:** `service_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_shapes`\n\nGet route shape/path information for mapping and visualization.\n\n- **Parameters:** `shape_id` (optional), `route_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_facilities`\n\nGet facility information including elevators, escalators, and parking areas.\n\n- **Parameters:** `facility_id` (optional), `stop_id` (optional), `facility_type` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_live_facilities`\n\nGet real-time facility status and outage information.\n\n- **Parameters:** `facility_id` (optional), `page_limit` (default: 10)\n\n#### `mbta_search_stops`\n\nSearch for stops by name or near a specific location.\n\n- **Parameters:** `query` (required), `latitude`/`longitude` (optional), `radius` (optional), `page_limit` (default: 10)\n\n#### `mbta_get_nearby_stops`\n\nGet stops near a specific location within a specified radius.\n\n- **Parameters:** `latitude` (required), `longitude` (required), `radius` (default: 1000), `page_limit` (default: 10)\n\n#### `mbta_get_predictions_for_stop`\n\nGet all predictions for a specific stop with optional filtering.\n\n- **Parameters:** `stop_id` (required), `route_id` (optional), `direction_id` (optional), `page_limit` (default: 10)\n\n### External API Tools\n\n#### `mbta_get_vehicle_positions`\n\nGet real-time vehicle positions from external API in GeoJSON format.\n\n- **Parameters:** None\n- **Returns:** GeoJSON with vehicle locations, routes, status, speed, and bearing information\n\n#### `mbta_get_external_alerts`\n\nGet general alerts from external API including delays, disruptions, and service information.\n\n- **Parameters:** None\n- **Returns:** JSON with alert details, severity levels, affected routes/stops, and active periods\n\n### Boston Amtrak Tracker API Tools\n\n#### `mbta_get_amtrak_trains`\n\nGet all tracked Amtrak trains from the Boston Amtrak Tracker API.\n\n- **Parameters:** None\n- **Returns:** JSON with real-time Amtrak train locations, routes, status, speed, and other information\n\n#### `mbta_get_amtrak_trains_geojson`\n\nGet Amtrak trains as GeoJSON for mapping applications.\n\n- **Parameters:** None\n- **Returns:** GeoJSON feature collection with train locations suitable for mapping\n\n#### `mbta_get_amtrak_health_status`\n\nGet health status of the Boston Amtrak Tracker API.\n\n- **Parameters:** None\n- **Returns:** JSON with server health status and last data update time\n\n### IMT Track Prediction API Tools\n\n#### `mbta_get_track_prediction`\n\nPredict which track a train will use at a specific station using machine learning.\n\n- **Parameters:** `station_id` (required), `route_id` (required), `trip_id` (required), `headsign` (required), `direction_id` (required), `scheduled_time` (required)\n- **Returns:** Track prediction with confidence score and prediction method\n\n#### `mbta_get_chained_track_predictions`\n\nGet multiple track predictions in a single request for batch processing.\n\n- **Parameters:** `predictions` (required) - Array of prediction request objects\n- **Returns:** Array of track predictions with confidence scores\n\n#### `mbta_get_prediction_stats`\n\nGet prediction statistics and accuracy metrics for a station and route.\n\n- **Parameters:** `station_id` (required), `route_id` (required)\n- **Returns:** Statistics including accuracy rate, total predictions, correct predictions, and average confidence\n\n#### `mbta_get_historical_assignments`\n\nGet historical track assignments for analysis and pattern recognition.\n\n- **Parameters:** `station_id` (required), `route_id` (required), `days` (default: 30)\n- **Returns:** Historical track assignment data with actual usage patterns\n\n## Integration with LLMs\n\n### Claude Desktop\n\n#### Option 1: Using uv tool run (Easiest - No Installation Required)\n\n**Add to Claude Desktop configuration:**\n\nOn macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"mbta\": {\n      \"command\": \"uv\",\n      \"args\": [\"tool\", \"run\", \"mbta-mcp\"],\n      \"env\": {\n        \"MBTA_API_KEY\": \"your_api_key_here\"\n      }\n    }\n  }\n}\n```\n\nOn Windows, edit `%APPDATA%\\Claude\\claude_desktop_config.json` with the same content.\n\n#### Option 2: Using uv tool install (Recommended for Regular Use)\n\n1. **Install the MCP server:**\n\n   ```bash\n   uv tool install mbta-mcp\n   ```\n\n2. **Add to Claude Desktop configuration:**\n\n   On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`:\n\n   ```json\n   {\n     \"mcpServers\": {\n       \"mbta\": {\n         \"command\": \"mbta-mcp\",\n         \"env\": {\n           \"MBTA_API_KEY\": \"your_api_key_here\"\n         }\n       }\n     }\n   }\n   ```\n\n   On Windows, edit `%APPDATA%\\Claude\\claude_desktop_config.json` with the same content.\n\n#### Option 3: Using development setup\n\n1. **Clone and setup the MCP server:**\n\n   ```bash\n   git clone https://github.com/cubismod/mbta-mcp.git\n   cd mbta-mcp\n   task install-dev\n   task verify  # Ensure everything works\n   ```\n\n2. **Configure your MBTA API key:**\n\n   ```bash\n   cp .env.example .env\n   # Edit .env and add: MBTA_API_KEY=your_api_key_here\n   ```\n\n3. **Add to Claude Desktop configuration:**\n\n   On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`:\n\n   ```json\n   {\n     \"mcpServers\": {\n       \"mbta\": {\n         \"command\": \"uv\",\n         \"args\": [\"run\", \"mbta-mcp\"],\n         \"cwd\": \"/path/to/your/mbta-mcp\",\n         \"env\": {\n           \"MBTA_API_KEY\": \"your_api_key_here\"\n         }\n       }\n     }\n   }\n   ```\n\n   On Windows, edit `%APPDATA%\\Claude\\claude_desktop_config.json` with the same content.\n\n**Restart Claude Desktop** and you'll see \"mbta\" in the \ud83d\udd0c icon, indicating the MCP server is connected.\n\n### Other MCP-Compatible LLMs\n\n#### Continue.dev\n\n**Using uv tool run (easiest):**\n\n```json\n{\n  \"mcpServers\": [\n    {\n      \"name\": \"mbta\",\n      \"command\": \"uv\",\n      \"args\": [\"tool\", \"run\", \"mbta-mcp\"],\n      \"env\": {\n        \"MBTA_API_KEY\": \"your_api_key_here\"\n      }\n    }\n  ]\n}\n```\n\n**Using uv tool installation:**\n\n```json\n{\n  \"mcpServers\": [\n    {\n      \"name\": \"mbta\",\n      \"command\": \"mbta-mcp\",\n      \"env\": {\n        \"MBTA_API_KEY\": \"your_api_key_here\"\n      }\n    }\n  ]\n}\n```\n\n**Or with development setup:**\n\n```json\n{\n  \"mcpServers\": [\n    {\n      \"name\": \"mbta\",\n      \"command\": \"uv\",\n      \"args\": [\"run\", \"mbta-mcp\"],\n      \"cwd\": \"/path/to/your/mbta-mcp\",\n      \"env\": {\n        \"MBTA_API_KEY\": \"your_api_key_here\"\n      }\n    }\n  ]\n}\n```\n\n#### Codeium\n\n**Using uv tool run (easiest):**\n\n```json\n{\n  \"mcp\": {\n    \"servers\": {\n      \"mbta\": {\n        \"command\": [\"uv\", \"tool\", \"run\", \"mbta-mcp\"],\n        \"env\": {\n          \"MBTA_API_KEY\": \"your_api_key_here\"\n        }\n      }\n    }\n  }\n}\n```\n\n**Using uv tool installation:**\n\n```json\n{\n  \"mcp\": {\n    \"servers\": {\n      \"mbta\": {\n        \"command\": [\"mbta-mcp\"],\n        \"env\": {\n          \"MBTA_API_KEY\": \"your_api_key_here\"\n        }\n      }\n    }\n  }\n}\n```\n\n**Or with development setup:**\n\n```json\n{\n  \"mcp\": {\n    \"servers\": {\n      \"mbta\": {\n        \"command\": [\"uv\", \"run\", \"mbta-mcp\"],\n        \"cwd\": \"/path/to/your/mbta-mcp\",\n        \"env\": {\n          \"MBTA_API_KEY\": \"your_api_key_here\"\n        }\n      }\n    }\n  }\n}\n```\n\n#### Generic MCP Client\n\n**Using uv tool run (easiest):**\n\n- **Command:** `uv tool run mbta-mcp`\n- **Environment:** `MBTA_API_KEY=your_api_key_here`\n\n**Using uv tool install:**\n\n- **Command:** `mbta-mcp`\n- **Environment:** `MBTA_API_KEY=your_api_key_here`\n\n**Using development setup:**\n\n- **Command:** `uv run mbta-mcp`\n- **Working Directory:** `/path/to/your/mbta-mcp`\n- **Environment:** `MBTA_API_KEY=your_api_key_here`\n\n### Usage Examples\n\nOnce connected, you can ask your LLM questions like:\n\n- \"What are the next Red Line trains from Harvard?\"\n- \"Are there any service alerts for the Green Line?\"\n- \"Find the nearest T stops to 42.3601\u00b0 N, 71.0589\u00b0 W\"\n- \"What bus routes serve Kendall Square?\"\n- \"Show me the schedule for Route 1 bus\"\n- \"Get real-time vehicle positions for all MBTA vehicles\"\n- \"What are the current service alerts and delays?\"\n- \"Predict which track the 3:30 PM Providence train will use at South Station\"\n- \"Show me track prediction accuracy statistics for South Station\"\n- \"Get historical track assignments for the last 30 days\"\n- \"Get all current Amtrak trains in the Boston area\"\n- \"Show me Amtrak trains as GeoJSON for mapping\"\n- \"Check the health status of the Amtrak tracker API\"\n\n### Troubleshooting\n\n**Server not connecting:**\n\n1. Verify the path in your config is correct\n2. Ensure `uv` is installed and in your PATH\n3. Check that the MBTA API key is valid\n4. Run `task test-server` to verify the server works\n\n**API rate limiting:**\n\n- The MBTA API has rate limits; the server includes pagination to manage this\n- Some endpoints work without an API key, but having one increases limits\n\n**Configuration issues:**\n\n- Ensure your `.env` file is in the project root\n- API key should be set as `MBTA_API_KEY=your_key_here`\n- Check Claude Desktop logs if the server fails to start\n\n## API Key Requirements\n\n- **Free access:** Many endpoints work without an API key (with lower rate limits)\n- **API key benefits:** Higher rate limits and access to all features\n- **Get a key:** Register at <https://api-v3.mbta.com>\n- **Usage:** Set in `.env` file or environment variable `MBTA_API_KEY`\n\n## External APIs\n\nThis MCP server integrates with additional external APIs to provide enhanced functionality:\n\n### Vehicle Positions API\n\n- **Endpoint:** <https://vehicles.ryanwallace.cloud/>\n- **Format:** GeoJSON with real-time vehicle locations, routes, and status\n- **No authentication required**\n- **Data:** Vehicle coordinates, route information, speed, bearing, occupancy status\n\n### External Alerts API\n\n- **Endpoint:** <https://vehicles.ryanwallace.cloud/alerts>\n- **Format:** JSON with service alerts, delays, and disruptions\n- **No authentication required**\n- **Data:** Alert headers, effects, severity levels, affected routes/stops, active periods\n\n### IMT Track Prediction API\n\n- **Endpoint:** <https://imt.ryanwallace.cloud/>\n- **Format:** JSON with machine learning-powered track predictions\n- **No authentication required**\n- **Data:** Track predictions, confidence scores, historical assignments, accuracy metrics\n\n### Boston Amtrak Tracker API\n\n- **Endpoint:** <https://bos.ryanwallace.cloud/>\n- **Format:** JSON and GeoJSON with real-time Amtrak train tracking\n- **No authentication required**\n- **Data:** Train locations, routes, status, speed, and health information\n\n\n## Development\n\nThis project uses [Task](https://taskfile.dev/) for build automation. Install it and run:\n\n```bash\ntask --list  # Show available tasks\n```\n\n### Common Tasks\n\n```bash\ntask install-dev    # Install dependencies including dev tools\ntask check          # Run all checks (format, lint, typecheck)\ntask test-server    # Test MCP server functionality\ntask run            # Run the MBTA MCP server\ntask verify         # Full project verification\n```\n\n### Manual Commands\n\nInstall dev dependencies:\n\n```bash\nuv sync --dev\n```\n\nRun formatters and linters:\n\n```bash\ntask format     # or: uv run ruff format mbta_mcp/\ntask lint       # or: uv run ruff check mbta_mcp/\ntask typecheck  # or: uv run mypy mbta_mcp/\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "MCP server for MBTA V3 API",
    "version": "1.0.17",
    "project_urls": {
        "Homepage": "https://github.com/cubismod/mbta-mcp",
        "Issues": "https://github.com/cubismod/mbta-mcp/issues",
        "Repository": "https://github.com/cubismod/mbta-mcp.git"
    },
    "split_keywords": [
        "api",
        " boston",
        " mbta",
        " mcp",
        " transit"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "65160958cf99d782643cd79bf1206c4648e1aa2193f3096a58d07c2fbe0651c0",
                "md5": "62e6c9119d528158bcd642839b286c06",
                "sha256": "c10db415c69b08c3d039f79668474ebb91b6547c9fdae47c935384f5861fe9c8"
            },
            "downloads": -1,
            "filename": "mbta_mcp-1.0.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "62e6c9119d528158bcd642839b286c06",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 22995,
            "upload_time": "2025-07-29T01:13:44",
            "upload_time_iso_8601": "2025-07-29T01:13:44.721175Z",
            "url": "https://files.pythonhosted.org/packages/65/16/0958cf99d782643cd79bf1206c4648e1aa2193f3096a58d07c2fbe0651c0/mbta_mcp-1.0.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ac6536dbc1661cb0b4f1b79809981d8a63ff5f77b3bbd4720eb84c73df6f11f0",
                "md5": "2fec84cd818e0d3971dd839b55f9f358",
                "sha256": "a5b453f64ed2fe2a4c3e57b7ac7ffb1c97e55d4261b375503d9ebbca7ac1e57a"
            },
            "downloads": -1,
            "filename": "mbta_mcp-1.0.17.tar.gz",
            "has_sig": false,
            "md5_digest": "2fec84cd818e0d3971dd839b55f9f358",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 93629,
            "upload_time": "2025-07-29T01:13:45",
            "upload_time_iso_8601": "2025-07-29T01:13:45.811654Z",
            "url": "https://files.pythonhosted.org/packages/ac/65/36dbc1661cb0b4f1b79809981d8a63ff5f77b3bbd4720eb84c73df6f11f0/mbta_mcp-1.0.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-29 01:13:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cubismod",
    "github_project": "mbta-mcp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mbta-mcp"
}
        
Elapsed time: 0.96326s