indian-rail-mcp
indian-rail-mcp
インド鉄道のデータを公式ソースから取得する、型付きTypeScriptライブラリおよびMCPサーバー。
APIキー不要。サードパーティのデータベンダー不要。消えてしまうnpm中間業者も不要。
NTES — | 列車時刻表、リアルタイム運行情報、編成位置、駅間列車検索、ライブ駅掲示板 |
IRCTC — | PNRステータス、車両別・座席レベルの空席情報 |
存在理由
人気のあったirctc-connectパッケージは非推奨となりました。作者はこれをrailkitに改名し、サインアップとAPIキーの背後に移しました。また、依存していた無料バックエンド(bookmytrain.vercel.app、easy-rail.onrender.com)は現在404と500を返します。そのエコシステムでまだ動作しているものは、サードパーティサイトのマークアップから取得した認証情報を使って、そのサイトをスクレイピングするものばかりです。
このライブラリは、インド鉄道が実際に運営しているソースに直接アクセスします。
Related MCP server: Indian Railway MCP
インストール
npm install indian-rail-mcpNode 20+が必要です。実行時依存はcheerioのみです。
ライブラリ
import {
getTrainInfo,
trackTrain,
searchTrainsBetweenStations,
getLiveStation,
getSeatAvailability,
checkPnrStatus
} from "indian-rail-mcp";
// Full schedule and route
const info = await getTrainInfo("12951");
// -> { trainName: "NDLS TEJAS RAJ", type: "RAJDHANI", runsOn: "Daily",
// classes: ["1A","2A","3A"], route: [ { stationCode: "MMCT", departure: "17:00", ... }, ... ] }
// Where is it right now (defaults to the journey in progress)
const live = await trackTrain("12626");
// -> { journeyDate, summary: "Arrived at BUTI BORI(BTBR) at 13:27 26-Aug",
// stops: [...], coachPosition: [ { position: 0, coach: "ENG", classCode: "ENG" }, ... ] }
// Direct trains between two stations — code or full name
await searchTrainsBetweenStations("CAN", "PAY");
await searchTrainsBetweenStations("NEW DELHI", "MMCT");
// Next couple of hours at a station, with delay and platform
await getLiveStation("NDLS");
// Reservation chart: per-coach vacancy, plus berth detail when a class is given
await getSeatAvailability({ trainNumber: "12951", boardingStation: "MMCT", travelClass: "3A" });駅はコードまたは正式名称のどちらでも受け付けます — NDLSもNEW DELHIも動作し、NTES独自の8,700駅カタログに対して解決されます。日付はDD-MM-YYYY、DD-MMM-YYYY、YYYY-MM-DDのいずれかを受け付けます。
エラー
すべての失敗は型付きのRailErrorです:
クラス |
| 意味 |
|
| 不正な駅・列車番号・日付 — ネットワーク呼び出し前にローカルで検出 |
|
| NTESが |
|
| IRCTCが |
|
| ネットワーク障害または解析不能なレスポンス |
ERR000について: NTESは、不正な入力に対しても実際の障害に対しても同じ汎用のERR000ページを返します。そのため、このライブラリはNTESを呼び出す前に駅コードをカタログに対して検証し、自分のタイプミスが「鉄道サービスが停止しています」と報告されることは決してありません。NtesErrorは、障害であると断定するのではなく、両方の可能性を意図的に示しています。
MCPサーバー
6つのツール:getTrainInfo、trackTrain、searchTrainBetweenStations、getLiveStation、getSeatAvailability、checkPnrStatus。
import { createRailMcpServer } from "indian-rail-mcp/mcp";
const server = createRailMcpServer({ allowPnr: true });
await server.connect(yourTransport);Vercelへのデプロイ
vercel deployvercel.jsonは関数を**bom1(ムンバイ)**に固定します — 両方のアップストリームがインドにあり、これは見た目以上に価値があります:ウォームリクエストは約124msで実行されるのに対し、コールドでは約885msです。また、インドのegress IPからのインド向けトラフィックは、NTESの前にあるF5 WAFをトリップする可能性がはるかに低くなります。
環境変数:
変数 | 目的 |
|
|
| IPごとのリクエスト上限。デフォルト30。 |
任意のMCPクライアントをStreamable HTTPトランスポートを使用してhttps://<your-deployment>/api/mcpに向けます。
PNRと個人データ
checkPnrStatusは乗客の個人データ — 氏名、年齢、性別、車両、座席 — を返します。
RAIL_API_KEYが設定され一致しない限り無効です。フェイルクローズドです。ライブラリはPNRレスポンスをログ記録、キャッシュ、永続化することは一切ありません。
意図的にバッチ処理や列挙のヘルパーはありません。設計上、1回の呼び出しにつき1つのPNRです。
これを公開デプロイする場合は、その状態を維持してください。PNRスクレイパーを構築しないでください。
データソースと規約
すべてのデータはIndian Railwaysの所有物であり、**Centre for Railway Information Systems (CRIS)**によって提供されています。このプロジェクトはIndian Railways、CRIS、IRCTCとは提携・承認・支援関係にありません。
デプロイ前にこれを読んでください:
NTES利用規約は、抽出データのダウンロードを個人利用に限り許可しており、事前の書面による許可なしに「いかなるソフトウェアプログラム」を使用してサイトから体系的にデータベースを構築したり、そのページを「公的または私的な電子検索システムまたはサービス」に含めたりしてはならないと規定しています。また、鉄道データは「商業目的に使用すべきではない」とも規定しています。
CRISはリクエストに応じてその許可を与えます:「本ウェブサイトに掲載されている資料は、メールを送信して適切な許可を得た上で、無料で複製することができます。」 送信準備が整ったリクエストは
PERMISSION-REQUEST.mdにあります。このプロジェクトの許可ステータス:リクエスト済み、保留中。
IRCTCの規約はより厳格であり、PNRデータは個人データです。
データの正確性はベストエフォートであり、保証されません — NTES自身の免責事項も同じことを述べています。安全に関わる用途には依存せず、鉄道会社に直接確認してください。
良き市民でありましょう:デフォルト設定は安定したものをキャッシュし、IPごとにレート制限し、単一のアップストリームセッションを再利用します。これらを削除しないでください。
開発
npm install
npm test # parser regression tests against recorded fixtures — no network
npm run smoke # live end-to-end check against NTES and IRCTC
npm run test:mcp # drives the MCP handler locally: handshake, tools, auth, rate limit
npm run fixtures # re-record fixtures when upstream markup changes
npm run buildtest/fixtures/内のフィクスチャは記録されたHTML/JSONです。CRISがマークアップを変更すると、ツールが静かに空の結果を返す代わりに、npm testが特定のアサーションで失敗します。
ライセンス
MIT — LICENSEを参照してください。ライセンスはこのソースコードのみを対象としており、基盤となる鉄道データは対象外です。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables real-time Indian Railways information retrieval, including live train running status, station schedules, and upcoming arrivals/departures.
- FlicenseNot gradedqualityDmaintenanceEnables searching and tracking Indian Railways trains, checking seat availability, live status, delays, and station/train codes.26
- FlicenseNot gradedqualityBmaintenanceProvides transit concierge tools for Indian Railways, including live train status, platform numbers, delay alerts, food options, and cab services, with offline fallback support.
- FlicenseNot gradedqualityDmaintenanceEnables checking railway seat availability, berth types, and pricing for Indian trains through natural language queries.
Related MCP Connectors
iRail MCP — Belgian rail (SNCB/NMBS) real-time via the community iRail API
Real-time BART departures, trip planning, fares, stations, and advisories.
Real-time transit stops, routes, arrivals, vehicle positions, and schedules via OneBusAway APIs.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mahi-v-v/indian-rail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server