AquibFaiyaz

๐Ÿš„ RailInfo MCP Server

Community AquibFaiyaz
Updated

๐Ÿš„ RailInfo MCP Server

An integration-ready Model Context Protocol (MCP) server providing real-time Indian Railways information. It gives AI models (like ChatGPT or Claude) the ability to fetch live train running status, localized station schedules, and upcoming train arrivals/departures with high accuracy.

๐ŸŒŸ Features

1. Live Train Status (get_live_train_status)

Get the current running status of any Indian Railways train.

  • Flexible Date Resolution: Supports querying by keywords like "today", "yesterday", or specific dates (e.g., "03-June-2026").
  • Target Station Focus: Query a train relative to a specific station (e.g., "When will 12357 reach Varanasi (BSB)?").
    • Remaining Track Distance: Calculates track distance remaining and number of stops to go.
    • Physical GPS Distance: Calculates straight-line physical distance to the station using the Haversine formula based on active GPS coordinates.
    • Remaining Stops Table: Lists upcoming stops with expected arrival time, platform, delay, and current status.

2. Live Station Departures (get_trains_at_station)

Get all trains arriving or departing at a station in the next 2 or 4 hours (matching NTES departures board).

  • Hybrid Search Algorithm: Merges static scheduled timetables with active live trains operating within a 120 km radius of the station. This ensures delayed or rescheduled trains are never missed.
  • Multi-Instance Handling: Disambiguates between yesterday's delayed train and today's on-time train running concurrently.

๐Ÿ› ๏ธ Configuration

The server reads configuration from a .env file at the root.

Create a .env file (copied from .env.example):

CACHE_TIME=60
RAIL_API_BASE_URL=https://api.example.com
  • CACHE_TIME: Cache TTL in seconds for API responses.
  • RAIL_API_BASE_URL: The base URL for the rail status API source.

๐Ÿš€ Installation & Build

  1. Install Dependencies:

    npm install
    
  2. Build the Server:

    npm run build
    

๐Ÿ”Œ MCP Client Integration

To integrate this server with Claude Desktop or other MCP clients, add it to your configuration file (e.g., ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "railinfo-mcp": {
      "command": "node",
      "args": ["/path/to/your/project/railinfo-mcp/dist/server.js"],
      "env": {
        "RAIL_API_BASE_URL": "https://api.example.com",
        "CACHE_TIME": "60"
      }
    }
  }
}

(Make sure to replace /path/to/your/project/railinfo-mcp/dist/server.js with the actual absolute path to the compiled dist/server.js file on your system).

๐Ÿ—ฃ๏ธ Sample Prompts

Ask your AI assistant questions using the following formats:

Live Train Status

  • ๐Ÿ“Œ "Where is train 12357 today?"
  • ๐Ÿ“Œ "What is the running status of train 12301 yesterday?"
  • ๐Ÿ“Œ "Give me the live status of train 12424 starting on 03-June-2026."

Localized Station Focus

  • ๐Ÿ“Œ "When will train 12357 reach Varanasi (BSB)?"
  • ๐Ÿ“Œ "How far is train 12260 from Sealdah (SDAH) and what is the expected arrival time?"
  • ๐Ÿ“Œ "Is train 12301 running late for Howrah (HWH)?"

Upcoming Trains at Station (Live Station)

  • ๐Ÿ“Œ "Show me upcoming trains at New Delhi (NDLS) in the next 2 hours."
  • ๐Ÿ“Œ "What trains are arriving or departing Patna Junction (PNBE) in the next 4 hours?"
  • ๐Ÿ“Œ "Which trains are at BSB right now or coming soon?"

MCP Server ยท Populars

MCP Server ยท New

    jackccrawford

    Geniuz

    Your AI remembers now. Geniuz stores everything in a local database locally on Mac, Windows, Linux, Raspberry Pi. No cloud. No account. No API keys. Nothing leaves your machine. It's open source; you can read every line of code.

    Community jackccrawford
    ggui-ai

    ggui

    The universal interface layer between AI agents and humans. Generate rich UIs on demand via MCP.

    Community ggui-ai
    aanno

    CocoIndex Code MCP Server

    An RAG for code development, implemented as MCP server with cocoindex

    Community aanno
    timescale

    Tiger Linear MCP Server

    A wrapper around the Linear API for internal LLMs

    Community timescale
    choplin

    MCP Gemini CLI

    MCP Server

    Community choplin