You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Python library for programmatic access to Indian Railways data, with a CLI and an MCP server that lets AI assistants (Claude, etc.) search trains, check availability, look up PNR status, and get live running status.
MCP Server
pip install "rail[mcp]"# Run the MCP server on STDIO (for Claude Desktop)
rail-mcp
# Run over HTTP with streaming
rail-mcp-http # serves at http://127.0.0.1:8000/mcp/
Claude Desktop Configuration
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
Specific train — optional, auto-detected if omitted
sort_by_price
bool
Sort by fare (true) or availability status (false)
Quick Start
pip install rail
# Or with pipx (recommended for CLI-only use)
pipx install rail
rail --help
CLI Usage
Search trains
# All trains between New Delhi and Mumbai Central on 1 June
rail trains NDLS BCT 2025-06-01
# Filter by class and quota
rail trains NDLS BCT 2025-06-01 --class SL --quota GN
# Sort by duration, show top 5
rail trains NDLS MAS 2025-06-15 --class 3A --sort DUR --top 5
# JSON output
rail trains NDLS BCT 2025-06-01 --json
# Clone and install
git clone https://github.com/securitylamb/rail.git
cd rail
uv sync --all-extras
# Run tests
uv run pytest -v
# Lint and format
uv run ruff check .
uv run ruff format .# Regenerate station enum from CSV
uv run python scripts/generate_station_enum.py
# Run MCP server locally
uv run rail-mcp
Adding Stations
Edit data/stations.csv (columns: code,name,city,state), then regenerate:
uv run python scripts/generate_station_enum.py
License
MIT
About
A Python library for Indian Railways train search via NTES and IRCTC