loading…
Search for a command to run...
loading…
Enables AI clients to access Boston's MBTA public transit data, including real-time predictions, schedules, route planning, and service alerts.
Enables AI clients to access Boston's MBTA public transit data, including real-time predictions, schedules, route planning, and service alerts.
An MCP (Model Context Protocol) server for the MBTA V3 API, providing access to Boston's public transit data.
No installation required! Just run directly:
uv tool run mbta-mcp
Set your MBTA API key as an environment variable:
export MBTA_API_KEY=your_api_key_here
uv tool run mbta-mcp
Install directly with uv tool:
uv tool install mbta-mcp
Set your MBTA API key:
export MBTA_API_KEY=your_api_key_here
Run the server:
mbta-mcp
Clone and install dependencies:
git clone https://github.com/cubismod/mbta-mcp.git
cd mbta-mcp
uv sync
Configure your MBTA API key:
cp .env.example .env
# Edit .env and add your MBTA_API_KEY
Get an API key from https://api-v3.mbta.com
Run the MCP server for use with AI clients like Claude Desktop:
# 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
For direct command-line access to MBTA and Amtrak data:
# 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
Core Transit Data:
mbta_get_routes - Get MBTA routes (subway, bus, commuter rail, ferry)mbta_get_stops - Get MBTA stops by ID, route, or locationmbta_get_predictions - Get real-time arrival predictionsmbta_get_schedules - Get scheduled service timesmbta_get_trips - Get trip information and detailsmbta_get_alerts - Get service alerts and disruptionsmbta_get_vehicles - Get real-time vehicle positionsTrip Planning:
mbta_plan_trip - Plan multi-modal journeys with real-time data and transfer optimizationmbta_get_route_alternatives - Find alternative routes with different transit modesExtended Features:
mbta_get_services - Get service definitions and calendarsmbta_get_shapes - Get route shape/path information for mappingmbta_get_facilities - Get facility information (elevators, escalators, parking)mbta_get_live_facilities - Get real-time facility status and outagesmbta_search_stops - Search for stops by name or near a locationmbta_get_nearby_stops - Get stops near a specific locationmbta_get_predictions_for_stop - Get all predictions for a specific stopExternal 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 APImbta_get_amtrak_trains_geojson - Get Amtrak trains as GeoJSON for mapping applicationsmbta_get_amtrak_health_status - Get health status of the Boston Amtrak Tracker APIIMT Track Prediction API:
mbta_get_track_prediction - Predict which track a train will use at a stationmbta_get_chained_track_predictions - Get multiple track predictions in a single requestmbta_get_prediction_stats - Get prediction statistics and accuracy metricsmbta_get_historical_assignments - Get historical track assignments for analysismbta_get_routesGet information about MBTA routes including subway, bus, commuter rail, and ferry services.
route_id (optional), route_type (optional), page_limit (default: 10)mbta_get_stopsFind transit stops by location, route, or ID with optional filtering.
stop_id (optional), route_id (optional), latitude/longitude (optional), radius (optional), page_limit (default: 10)mbta_get_predictionsGet real-time arrival predictions for MBTA services.
stop_id (optional), route_id (optional), trip_id (optional), page_limit (default: 10)mbta_get_schedulesGet scheduled service times and departure information.
stop_id (optional), route_id (optional), trip_id (optional), direction_id (optional), page_limit (default: 10)mbta_get_tripsGet trip information and details for MBTA services.
trip_id (optional), route_id (optional), direction_id (optional), page_limit (default: 10)mbta_get_alertsGet service alerts and disruptions affecting MBTA services.
alert_id (optional), route_id (optional), stop_id (optional), page_limit (default: 10)mbta_get_vehiclesGet real-time vehicle positions and status information.
vehicle_id (optional), route_id (optional), trip_id (optional), page_limit (default: 10)mbta_get_servicesGet service definitions and calendars for MBTA operations.
service_id (optional), page_limit (default: 10)mbta_get_shapesGet route shape/path information for mapping and visualization.
shape_id (optional), route_id (optional), page_limit (default: 10)mbta_get_facilitiesGet facility information including elevators, escalators, and parking areas.
facility_id (optional), stop_id (optional), facility_type (optional), page_limit (default: 10)mbta_get_live_facilitiesGet real-time facility status and outage information.
facility_id (optional), page_limit (default: 10)mbta_search_stopsSearch for stops by name or near a specific location.
query (required), latitude/longitude (optional), radius (optional), page_limit (default: 10)mbta_get_nearby_stopsGet stops near a specific location within a specified radius.
latitude (required), longitude (required), radius (default: 1000), page_limit (default: 10)mbta_get_predictions_for_stopGet all predictions for a specific stop with optional filtering.
stop_id (required), route_id (optional), direction_id (optional), page_limit (default: 10)mbta_get_vehicle_positionsGet real-time vehicle positions from external API in GeoJSON format.
mbta_get_external_alertsGet general alerts from external API including delays, disruptions, and service information.
mbta_get_amtrak_trainsGet all tracked Amtrak trains from the Boston Amtrak Tracker API.
mbta_get_amtrak_trains_geojsonGet Amtrak trains as GeoJSON for mapping applications.
mbta_get_amtrak_health_statusGet health status of the Boston Amtrak Tracker API.
mbta_get_track_predictionPredict which track a train will use at a specific station using machine learning.
station_id (required), route_id (required), trip_id (required), headsign (required), direction_id (required), scheduled_time (required)mbta_get_chained_track_predictionsGet multiple track predictions in a single request for batch processing.
predictions (required) - Array of prediction request objectsmbta_get_prediction_statsGet prediction statistics and accuracy metrics for a station and route.
station_id (required), route_id (required)mbta_get_historical_assignmentsGet historical track assignments for analysis and pattern recognition.
station_id (required), route_id (required), days (default: 30)The MBTA MCP server provides intelligent trip planning capabilities that combine real-time transit data with multi-modal journey optimization. These tools help plan efficient journeys across the MBTA network with support for accessibility requirements and transfer preferences.
mbta_plan_tripPlan multi-modal journeys with real-time data and transfer optimization. This tool finds the best transit routes between two locations, considering walking distance, transfer limits, and accessibility requirements.
Parameters:
origin_lat (required): Origin latitude coordinateorigin_lon (required): Origin longitude coordinate dest_lat (required): Destination latitude coordinatedest_lon (required): Destination longitude coordinatedeparture_time (optional): ISO 8601 formatted departure time (e.g., "2025-01-01T10:00:00-05:00")max_walk_distance (optional): Maximum walking distance in meters (default: 800)max_transfers (optional): Maximum number of transfers allowed (default: 2)prefer_fewer_transfers (optional): Prioritize routes with fewer transfers (default: true)wheelchair_accessible (optional): Only include accessible routes and vehicles (default: false)Returns: JSON with trip options including:
Example Usage:
Plan a trip from MIT to Harvard Square:
- origin_lat: 42.3601
- origin_lon: -71.0942
- dest_lat: 42.3736
- dest_lon: -71.1190
- max_walk_distance: 600
- prefer_fewer_transfers: true
mbta_get_route_alternativesFind alternative routes with different transit modes. This tool excludes specified primary route types to discover backup options, useful when primary routes have service disruptions.
Parameters:
origin_lat (required): Origin latitude coordinateorigin_lon (required): Origin longitude coordinatedest_lat (required): Destination latitude coordinate dest_lon (required): Destination longitude coordinateprimary_route_modes (optional): Array of route type IDs to exclude (e.g., ["1"] to exclude subway)departure_time (optional): ISO 8601 formatted departure timemax_walk_distance (optional): Maximum walking distance in meters (default: 800)max_transfers (optional): Maximum transfers (default: 2)wheelchair_accessible (optional): Require accessible routes (default: false)Route Type IDs:
"0" - Light Rail (Green Line branches)"1" - Subway (Red, Orange, Blue Lines) "2" - Commuter Rail"3" - Bus"4" - FerryReturns: Alternative route options excluding the specified primary modes, with the same detailed structure as mbta_plan_trip.
Example Usage:
Find bus alternatives when subway is disrupted:
- origin_lat: 42.3601
- origin_lon: -71.0942
- dest_lat: 42.3736
- dest_lon: -71.1190
- primary_route_modes: ["1", "0"] // Exclude subway and light rail
- max_walk_distance: 1000
Morning Commute Planning:
Use mbta_plan_trip with departure time to find the best route for your daily commute, considering real-time delays and service alerts.
Accessibility-First Routing:
Enable wheelchair_accessible: true to ensure all suggested routes are fully accessible, including elevators and ramps at stations.
Service Disruption Backup:
When alerts indicate subway delays, use mbta_get_route_alternatives to find bus routes that avoid the affected lines.
Event Planning: For large events, plan trips with longer walking distances and more transfers to distribute passenger load across the transit network.
Tourist Assistance: Combine trip planning with nearby stops and predictions to help visitors navigate Boston's transit system efficiently.
Add to Claude Desktop configuration:
On macOS, edit ~/Library/Application Support/Claude/claude_desktop_config.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.
Install the MCP server:
uv tool install mbta-mcp
Add to Claude Desktop configuration:
On macOS, edit ~/Library/Application Support/Claude/claude_desktop_config.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.
Clone and setup the MCP server:
git clone https://github.com/cubismod/mbta-mcp.git
cd mbta-mcp
task install-dev
task verify # Ensure everything works
Configure your MBTA API key:
cp .env.example .env
# Edit .env and add: MBTA_API_KEY=your_api_key_here
Add to Claude Desktop configuration:
On macOS, edit ~/Library/Application Support/Claude/claude_desktop_config.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.
Using uv tool run (easiest):
{
"mcpServers": [
{
"name": "mbta",
"command": "uv",
"args": ["tool", "run", "mbta-mcp"],
"env": {
"MBTA_API_KEY": "your_api_key_here"
}
}
]
}
Using uv tool installation:
{
"mcpServers": [
{
"name": "mbta",
"command": "mbta-mcp",
"env": {
"MBTA_API_KEY": "your_api_key_here"
}
}
]
}
Or with development setup:
{
"mcpServers": [
{
"name": "mbta",
"command": "uv",
"args": ["run", "mbta-mcp"],
"cwd": "/path/to/your/mbta-mcp",
"env": {
"MBTA_API_KEY": "your_api_key_here"
}
}
]
}
Using uv tool run (easiest):
{
"mcp": {
"servers": {
"mbta": {
"command": ["uv", "tool", "run", "mbta-mcp"],
"env": {
"MBTA_API_KEY": "your_api_key_here"
}
}
}
}
}
Using uv tool installation:
{
"mcp": {
"servers": {
"mbta": {
"command": ["mbta-mcp"],
"env": {
"MBTA_API_KEY": "your_api_key_here"
}
}
}
}
}
Or with development setup:
{
"mcp": {
"servers": {
"mbta": {
"command": ["uv", "run", "mbta-mcp"],
"cwd": "/path/to/your/mbta-mcp",
"env": {
"MBTA_API_KEY": "your_api_key_here"
}
}
}
}
}
Using uv tool run (easiest):
uv tool run mbta-mcpMBTA_API_KEY=your_api_key_hereUsing uv tool install:
mbta-mcpMBTA_API_KEY=your_api_key_hereUsing development setup:
uv run mbta-mcp/path/to/your/mbta-mcpMBTA_API_KEY=your_api_key_hereOnce connected, you can ask your LLM questions like:
Core Transit Information:
Trip Planning:
Advanced Features:
Server not connecting:
uv is installed and in your PATHtask test-server to verify the server worksAPI rate limiting:
Configuration issues:
.env file is in the project rootMBTA_API_KEY=your_key_here.env file or environment variable MBTA_API_KEYThis MCP server integrates with additional external APIs to provide enhanced functionality:
This project uses Task for build automation. Install it and run:
task --list # Show available tasks
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
Install dev dependencies:
uv sync --dev
Run formatters and linters:
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/
Run in your terminal:
claude mcp add mbta-mcp-server -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.