
Caltrain
Provides real-time Caltrain schedules and station information for San Francisco Bay Area commuters. Uses official GTFS data to show next departures between any stations.
Provides real-time Caltrain commuter rail information including schedules, station details, and trip planning for the San Francisco Bay Area
What it does
- Get next train departures between stations
- List all Caltrain stations
- Plan trips with time-specific queries
- Search stations with partial names
Best for
About Caltrain
Caltrain is a community-built MCP server published by davidyen1124 that provides AI assistants with tools and capabilities via the Model Context Protocol. Get real-time Caltrain schedules, station info, and trip planning. Check Caltrain hours and cal train time for your Bay It is categorized under developer tools, analytics data. This server exposes 2 tools that AI clients can invoke during conversations and coding sessions.
How to install
You can install Caltrain in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
License
Caltrain is released under the NOASSERTION license.
Tools (2)
Return the next few scheduled Caltrain departures. Args: origin: Station name (e.g. 'San Jose Diridon', 'Palo Alto', 'San Francisco'). Supports common abbreviations like 'SF' for San Francisco, 'SJ' for San Jose. If station is not found, use list_stations() to see all available options. destination: Station name (e.g. 'San Francisco', 'Mountain View', 'Tamien'). Supports common abbreviations like 'SF' for San Francisco, 'SJ' for San Jose. If station is not found, use list_stations() to see all available options. when_iso: Optional ISO-8601 datetime (local time). Default: now. Note: If you get a "Station not found" error, try using the list_stations() tool first to see exact station names, then retry with the correct spelling.
List all available Caltrain stations. This tool is useful when you need to find the exact station names, especially if the next_trains() tool returns a "Station not found" error. Station names are case-insensitive and support some common abbreviations like 'SF' and 'SJ'. Returns a formatted list of all Caltrain stations that can be used as origin or destination in the next_trains() tool.
π Caltrain MCP Server (Because You Love Waiting for Trains)

A Model Context Protocol (MCP) server that promises to tell you exactly when the next Caltrain will arrive... and then be 10 minutes late anyway. Uses real GTFS data, so at least the disappointment is official!
Features (Or: "Why We Built This Thing")
- π "Real-time" train schedules - Get the next departures between any two stations (actual arrival times may vary by +/- infinity)
- π Station lookup - Because apparently 31 stations is too many to memorize π€·ββοΈ
- π Time-specific queries - Plan your commute with surgical precision, then watch it all fall apart
- β¨ Smart search - Type 'sf' instead of the full name because we're all lazy here
- π GTFS-based - We use the same data Caltrain does, so when things go wrong, we can blame them together
Setup (The Fun Part π)
-
Install dependencies (aka "More stuff to break"):
# Install uv if you haven't already (because pip is apparently too mainstream now) curl -LsSf https://astral.sh/uv/install.sh | sh # Install dependencies using uv (fingers crossed it actually works) uv sync -
Get that sweet, sweet GTFS data: The server expects Caltrain GTFS data in the
src/caltrain_mcp/data/caltrain-ca-us/directory. Because apparently we can't just ask the trains nicely where they are.uv run python scripts/fetch_gtfs.pyThis magical script downloads files that contain:
stops.txt- All the places trains pretend to stoptrips.txt- Theoretical journeys through space and timestop_times.txt- When trains are supposed to arrive (spoiler: they don't)calendar.txt- Weekday vs weekend schedules (because trains also need work-life balance)
Usage (Good Luck!)
As an MCP Server (The Real Deal)
This server is designed to be used with MCP clients like Claude Desktop, not run directly by humans (because that would be too easy). Here's how to actually use it:
With Claude Desktop
Add this to your Claude Desktop MCP configuration file:
{
"mcpServers": {
"caltrain": {
"command": "uvx",
"args": ["caltrain-mcp"]
}
}
}
This will automatically install and run the latest version from PyPI.
Then restart Claude Desktop and you'll have access to Caltrain schedules directly in your conversations!
With Other MCP Clients
Any MCP-compatible client can use this server by starting it with:
uvx caltrain-mcp
The server communicates via stdin/stdout using the MCP protocol. It doesn't do anything exciting when run directly - it just sits there waiting for proper MCP messages.
Testing the Server (For Development)
You can test if this thing actually works by importing it directly:
from caltrain_mcp.server import next_trains, list_stations
# Test next trains functionality (prepare for disappointment)
result = await next_trains('San Jose Diridon', 'San Francisco')
print(result) # Spoiler: there are no trains
# Test stations list (all 31 of them, because apparently that's manageable)
stations = await list_stations()
print(stations)
Available Tools (Your New Best Friends)
next_trains(origin, destination, when_iso=None)
Ask politely when the next train will show up. The server will consult its crystal ball (GTFS data) and give you times that are technically accurate.
Parameters:
origin(str): Where you are now (probably regretting your life choices)destination(str): Where you want to be (probably anywhere but here)when_iso(str, optional): When you want to travel (as if time has any meaning in public transit)
Examples:
# Next trains from current time (aka "right now would be nice")
next_trains('San Jose Diridon', 'San Francisco')
# Trains at a specific time (for the optimists who think schedules matter)
next_trains('Palo Alto', 'sf', '2025-05-23T06:00:00')
# Using abbreviations (because typing is hard)
next_trains('diridon', 'sf')
list_stations()
Get a list of all 31 Caltrain stations, because memorizing them is apparently too much to ask.
Returns: A formatted list that will make you realize just how many places this train supposedly goes.
Station Name Recognition (We're Not Mind Readers, But We Try)
The server supports various ways to be lazy about typing station names:
- Full names: "San Jose Diridon Station" (for the perfectionists)
- Short names: "San Francisco" (for the slightly less perfectionist)
- Abbreviations: "sf" β "San Francisco" (for the truly lazy)
- Partial matching: "diridon" matches "San Jose Diridon Station" (for when you can't be bothered)
Available Stations (All 31 Glorious Stops)
The server covers every single Caltrain station because we're completionists:
San Francisco to San Jose (The Main Event):
- San Francisco, 22nd Street, Bayshore, South San Francisco, San Bruno, Millbrae, Broadway, Burlingame, San Mateo, Hayward Park, Hillsdale, Belmont, San Carlos, Redwood City, Menlo Park, Palo Alto, Stanford, California Avenue, San Antonio, Mountain View, Sunnyvale, Lawrence, Santa Clara, College Park, San Jose Diridon
San Jose to Gilroy (The "Why Does This Exist?" Extension):
- Tamien, Capitol, Blossom Hill, Morgan Hill, San Martin, Gilroy
Sample Output (Prepare to Be Amazed)
π Next Caltrain departures from San Jose Diridon Station to San Francisco Caltrain Station on Thursday, May 22, 2025:
β’ Train 153: 17:58:00 β 19:16:00 (to San Francisco)
β’ Train 527: 18:22:00 β 19:22:00 (to San Francisco)
β’ Train 155: 18:28:00 β 19:46:00 (to San Francisco)
β’ Train 429: 18:43:00 β 19:53:00 (to San Francisco)
β’ Train 157: 18:58:00 β 20:16:00 (to San Francisco)
Actual arrival times may vary. Side effects may include existential dread and a deep appreciation for remote work.
Technical Details (For the Nerds)
- GTFS Processing: We automatically handle the relationship between stations and their platforms (because apparently trains are complicated)
- Service Calendar: Respects weekday/weekend schedules (trains also need their beauty rest)
- Data Types: Handles the chaos that is mixed integer/string formats in GTFS files
- Time Parsing: Supports 24+ hour format for those mythical late-night services
- Error Handling: Gracefully fails when you type "Narnia" as a station name
Project Structure (The Organized Chaos)
caltrain-mcp/
βββ .github/workflows/ # GitHub Actions (the CI/CD overlords)
β βββ ci.yml # Main CI pipeline (linting, testing, the works)
β βββ update-gtfs.yml # Automated GTFS data updates
βββ src/caltrain_mcp/ # Main package (because modern Python demands structure)
β βββ data/caltrain-ca-us/ # GTFS data storage (where CSV files go to retire)
β βββ __init__.py # Package initialization (the ceremony of Python)
β βββ __main__.py # Entry point for python -m caltrain_mcp
β βββ server.py # MCP server implementation (where the magic happens)
β βββ gtfs.py # GTFS data processing (aka "CSV wrestling")
βββ scripts/ # Utility scripts (the supporting cast)
β βββ __init__.py # Makes scripts a proper Python package
β βββ fetch_gtfs.py # Downloads the latest disappointment data
β βββ lint.py # Run all CI checks locally (before embarrassment)
βββ tests/ # Test suite (because trust but verify)
β βββ conftest.py # Shared test fixtures (the common ground)
β βββ test_gtfs.py # GTFS functionality tests (8 tests of data wrangling)
β βββ test_server.py # Server functionality tests (4 tests of MCP protocol)
β βββ test_fetch_gtfs.py # Data fetching tests (7 tests of download chaos)
βββ .pre-commit-config.yaml # Pre-commit hooks configuration
βββ pyproject.toml # Modern Python config (because setup.py is so 2020)
βββ README.md # This literary masterpiece
Development & Testing (For When Things Inevitably Break)
Code Quality & CI/CD
This project uses modern Python tooling to keep the code clean and maintainable:
- Ruff: Lightning-fast linting and formatting (because life's too short for slow tools)
- MyPy: Type checking (because guessing types is for amateurs)
- Pytest: Testing framework with coverage reporting
Release Process (Automated Awesomeness)
This project uses automated versioning and publishing:
- Semantic Versioning: Version numbers are automatically determined from commit messages using Conventional Commits
- Automatic Tagging: When you push to
main, semantic-release creates version tags automatically - PyPI Publishing: Tagged releases are automatically built and published to PyPI via GitHub Actions
- Trusted Publishing: Uses OIDC authentication with PyPI (no API tokens needed!)
Making a Release
Just commit using conventional commit format and push to main:
# For bug fixes (patch version bump: 1.0.0 β 1.0.1)
git commit -m "fix: correct station name lookup bug"
# For new features (minor version bump: 1.0.0 β 1.1.0)
git commit -m "feat: add support for weekend schedules"
# For breaking changes (major version bump: 1.0.0 β 2.0.0)
git commit -m "feat!: redesign API structure"
# or
git commit -m "feat: major API changes
BREAKING CHANGE: This changes the function signatures"
The semantic-release workflow will:
- Analyze your commit messages
- Determine the appropriate versio
README truncated. View full README on GitHub.
Alternatives
Related Skills
Browse all skillsUse when building MCP servers or clients that connect AI systems with external tools and data sources. Invoke for MCP protocol compliance, TypeScript/Python SDKs, resource providers, tool functions.
CCXT cryptocurrency exchange library for TypeScript and JavaScript developers (Node.js and browser). Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors. Use when working with crypto exchanges in TypeScript/JavaScript projects, trading bots, arbitrage systems, or portfolio management tools. Includes both REST and WebSocket examples.
.NET/C# backend developer for ASP.NET Core APIs with Entity Framework Core. Builds REST APIs, minimal APIs, gRPC services, authentication with Identity/JWT, authorization, database operations, background services, SignalR real-time features. Activates for: .NET, C#, ASP.NET Core, Entity Framework Core, EF Core, .NET Core, minimal API, Web API, gRPC, authentication .NET, Identity, JWT .NET, authorization, LINQ, async/await C#, background service, IHostedService, SignalR, SQL Server, PostgreSQL .NET, dependency injection, middleware .NET.
Build full-stack applications with Supabase (PostgreSQL, Auth, Storage, Real-time, Edge Functions). Use when implementing authentication, database design with RLS, file storage, real-time features, or serverless functions.
Transform data into compelling narratives using visualization, context, and persuasive structure. Use when presenting analytics to stakeholders, creating data reports, or building executive presentations.
Senior Python developer expertise for writing clean, efficient, and well-documented code. Use when: writing Python code, optimizing Python scripts, reviewing Python code for best practices, debugging Python issues, implementing type hints, or when user mentions Python, PEP 8, or needs help with Python data structures and algorithms.