train-mcp-server
列車チケット照会 MCP Server(FastMCP)
FastMCP で実装された列車・新幹線の運行情報照会サービス。リモート MCP ツールとして任意の Agent(deepagents、LangGraph、Claude など)から呼び出せます。
機能
1 つのツール関数:query_train_tickets(from_station, to_station, date)
2 駅間の指定日の列車番号、時刻、所要時間、予約可否、空席状況を照会
データソース:12306 公開照会インターフェース(実データ)。インターフェースが風制御された場合は自動的にシミュレーションデータに切り替え、出所を明記。デモが常に実行可能な状態を保証
Related MCP server: THSRC MCP Server
ローカル実行
pip install -r requirements.txt
python server.py # 启动 streamable-http 服务,默认 http://127.0.0.1:8000MCP クライアント設定(ローカル連携テスト):
{
"mcpServers": {
"train": {
"url": "http://127.0.0.1:8000/mcp/",
"transport": "streamable_http"
}
}
}魔搭 MCP 広場へのデプロイ(重要な手順)
このリポジトリを GitHub にプッシュ
modelscope.cn/mcp を開いてログイン → 「MCP 作成」 をクリック
作成タイプは 「GitHub クイック作成」 を選択。ホスティングタイプは 「ホスティング可能」 を選択
英語/中国語の名前、ソースアドレス(GitHub リポジトリ URL)を入力し、プラットフォームの指示に従って設定を補完
送信後、プラットフォームがアクセスアドレスを生成:
https://mcp.api-inference.modelscope.net/<あなたのID>/sseまたは/mcp(長期有効に設定可能)そのアドレスを Agent プロジェクトの MCP 設定に記入すれば完了
ヒント:プラットフォームはホスティングプロジェクトに対して起動方法の要件があります(通常は Python + HTTP サービスの起動が必要)。デプロイに失敗した場合は、プラットフォームの指示に従ってエントリポイントを調整してください(例:
runスクリプトや環境変数の提供)。
データソースについて
12306 には公式の公開 API はありません。本プロジェクトはその公開照会インターフェース(kyfw.12306.cn/otn/leftTicket)を使用しており、ログイン不要で照会可能。個人の学習研究のみを目的としています
インターフェースには風制御があります(偶発的に 302 が発生)。コードではセッション cookie + シミュレーションデータによるフォールバックを実装
より安定したデータが必要な場合は、
_fetch_12306をサードパーティのデータソースに置き換えてください(プラグイン可能)
ディレクトリ
server.py— FastMCP サービスのメインプログラムtest_client.py— ローカル連携テストスクリプト(ツール関数の直接呼び出し + MCP プロトコル経由のテスト)requirements.txt— 依存関係
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
- AlicenseAqualityBmaintenanceA high-performance FastAPI backend for train ticket queries in China, supporting real-time ticket availability, station information, transfers, and train schedules through the Model Context Protocol for AI assistants and automation.7359MIT
- Alicense-qualityDmaintenanceEnables real-time Taiwan High Speed Rail (THSRC) information queries including timetables, station details, train status, and seat availability. Supports multiple languages and integrates with TDX API for up-to-date rail service data.492MIT
- Alicense-qualityDmaintenanceEnables searching for train tickets on China's 12306 railway system, including ticket availability queries, train filtering, station stopover information, and transfer route planning.9,8472MIT
- Flicense-qualityBmaintenanceEnables real-time Indian Railways information retrieval, including live train running status, station schedules, and upcoming arrivals/departures.
Related MCP Connectors
TravelMind: 8 MCP tools for travel (12306 trains, flights, hotels, geocode, planning, policy).
Provide access to Chinese stock market data including historical prices, real-time data, news, and…
China & Asia travel eSIM specialist. 200+ countries. No-VPN internet in China.
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/CallwaterSword/train-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server