An MCP (Model Context Protocol) server that provides real-time train schedule information for the MBTA Worcester Line. Built with Next.js and deployable on Vercel.
- Real-time train departures from any Worcester Line station
- Merges scheduled times with live predictions
- Supports all 18 Worcester Line stops
- Works with Gemini CLI and other MCP clients
Get a free API key at: https://api-v3.mbta.com
npm installCopy .env.example to .env.local and add your MBTA API key:
MBTA_API_KEY=your-mbta-api-key-here
MCP_API_KEY=your-secret-token # Optional: for authenticationnpm run devnpm run test:mcp- Push to GitHub
- Import to Vercel
- Add environment variables:
MBTA_API_KEY: Your MBTA API keyMCP_API_KEY: Secret token for authentication (optional)
Add to ~/.gemini/settings.json:
{
"mcpServers": {
"mbta": {
"httpUrl": "https://your-app.vercel.app/api",
"headers": {
"Authorization": "Bearer YOUR_MCP_API_KEY"
},
"timeout": 30000
}
}
}Or via CLI:
gemini mcp add --transport http mbta https://your-app.vercel.app/api{
"mcpServers": {
"mbta": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://your-app.vercel.app/api/mcp"]
}
}
}Get upcoming train departures from any Worcester Line station.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
stop |
string | Yes | Stop name or ID (e.g., "South Station", "framingham") |
direction |
string | No | "outbound" (toward Worcester) or "inbound" (toward Boston). Default: "outbound" |
date |
string | No | Date in YYYY-MM-DD format. Default: today |
limit |
number | No | Number of departures (1-20). Default: 5 |
Example queries:
- "What trains leave South Station for Worcester?"
- "Get next trains from Framingham to Boston"
- "What trains leave Westborough tomorrow morning?"
South Station, Back Bay, Lansdowne, Boston Landing, Newtonville, West Newton, Auburndale, Wellesley Farms, Wellesley Hills, Wellesley Square, Natick Center, West Natick, Framingham, Ashland, Southborough, Westborough, Grafton, Worcester
src/
├── app/
│ ├── api/[transport]/route.ts # MCP handler
│ └── page.tsx # Status page
├── lib/
│ ├── mbta/
│ │ ├── client.ts # MBTA API client
│ │ ├── types.ts # TypeScript types
│ │ └── stops.ts # Stop ID mappings
│ └── mcp/
│ ├── auth.ts # Authentication
│ └── tools/ # MCP tools
│ ├── get-departures.ts
│ └── index.ts
MIT