train-mcp-server
火车票查询 MCP Server(FastMCP)
用 FastMCP 实现的火车票/高铁车次查询服务,可作为远程 MCP 工具被任意 Agent(如 deepagents、LangGraph、Claude 等)调用。
能力
一个工具函数:query_train_tickets(from_station, to_station, date)
查询两个车站之间某天的车次、时刻、历时、可预订状态、余票情况
数据源: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