railinfo-mcp

railinfo-mcp

Enables real-time Indian Railways information retrieval, including live train running status, station schedules, and upcoming arrivals/departures.

Category
访问服务器

README

🚄 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, station schedules, route maps, crossings, and upcoming train arrivals/departures with high accuracy.


🌟 Features & Tools

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.

3. Train Crossings & Radar (get_train_crossings_and_radar)

Get a "radar view" along a train's active route.

  • Oncoming Crossings: Lists oncoming trains scheduled to pass by on opposing tracks.
  • Section Traffic (Radar): Identifies other trains running directly ahead or behind in the same block section. Helpful for predicting signal-related delays.

4. Trains Between Stations (get_trains_between_stations)

Find all upcoming trains running from a source station (e.g., ALJN) to a destination station (e.g., NDLS).

  • Live Schedule Aggregator: Fetches live departure/arrival times, delay status, and platform numbers at both stations.

5. Train Timetable (get_train_timetable)

Fetch the complete scheduled route/timetable of any train.

  • Full Stops List: Lists every single scheduled stop along the route, showing scheduled arrival/departure times, distance (km), platform number, and live expected arrival/departure times if running.

6. Train Route Map (get_train_route_map)

Get the precise geographic coordinates of a train's entire route.

  • Station Coordinates: Look up latitude/longitude for every stop on the train's route.
  • Map Integration: Generates clickable Google Maps links for every station to plot or visualize the path.

7. Trains Approaching Station (Radar) (get_trains_approaching_station)

Get active, live trains physically approaching a station within a specified radius (default 50 km, max 100 km).

  • Spatial Tracking: Tracks live coordinates of active trains approaching the station.
  • Smart Filter: Automatically ignores trains that have already departed or are moving away from the station.

🛠️ 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
    
  3. Running the Server (Locally):

    • Stdio Mode (Standard MCP):
      npx tsx src/server.ts
      
    • SSE Mode (HTTP Server):
      npx tsx src/http-server.ts
      
    • Streamable Mode (SSE HTTP Server):
      npx tsx src/http-streamable.ts
      

🐳 Docker Deployment

The repository includes a multi-stage Dockerfile and .dockerignore for production deployment.

  1. Build Docker Image:

    docker build -t railinfo-mcp .
    
  2. Run Container:

    docker run -d --name railinfo-mcp -p 3000:3000 --env-file .env railinfo-mcp
    

🔌 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):

Stdio Transport (Local Node Execution)

{
  "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"
      }
    }
  }
}

SSE Transport (HTTP Proxy)

If running the server in SSE mode on a VPS under a domain, connect via:

{
  "mcpServers": {
    "railinfo-mcp-sse": {
      "url": "https://your-domain.com/mcp"
    }
  }
}

🗣️ Sample Prompts

Ask your AI assistant questions using the following formats:

Live Train Status & Coordinates

  • 📌 "Where is train 12302 today?"
  • 📌 "When will train 12357 reach Prayagraj Jn (PRYJ)?"
  • 📌 "Get the route map coordinates for train 12951 starting today."

Train Radar & Crossings

  • 📌 "What trains are crossing or running ahead of train 12302?"

Timetable & Route Lookups

  • 📌 "Show me the full schedule and route timetable of train 12302."

Station boards & Train Search

  • 📌 "Show me upcoming trains at New Delhi (NDLS) in the next 2 hours."
  • 📌 "Find trains running between Kanpur Central (CNB) and New Delhi (NDLS) starting in the next 4 hours."

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选