by drfccv
12306 MCP Server 是一个基于 Model Context Protocol (MCP) 的高性能火车票查询后端系统。它通过标准化接口提供官方 12306 的实时数据服务,包括余票查询、车站信息、列车经停站、中转换乘方案等核心功能。
# Add to your Claude Code skills
git clone https://github.com/drfccv/mcp-server-12306Guides for using mcp servers skills like mcp-server-12306.
Last scanned: 5/29/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-05-29T07:57:10.843Z",
"semgrepRan": false,
"npmAuditRan": true,
"pipAuditRan": true
}
MCP Server 12306 是一款基于 Model Context Protocol (MCP) 的高性能火车票查询服务,支持官方 12306 余票、票价、车站、经停、换乘查询以及智能时间工具,适配 AI/自动化/智能助手等场景,开箱即用。
本项目支持两种运行模式:
在此模式下,MCP Server 通过标准输入/输出与客户端通信,无需占用网络端口。
uvx 是 uv 包管理器提供的工具,环境隔离且启动极快。
{
"mcpServers": {
"12306": {
"command": "uvx",
"args": ["mcp-server-12306"]
}
}
}
如果您更习惯使用 pipx:
{
"mcpServers": {
"12306": {
"command": "pipx",
"args": ["run", "--no-cache", "mcp-server-12306"]
}
}
}
适用于开发者调试:
cd mcp-server-12306
uv sync
{
"mcpServers": {
"12306": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-server-12306", "run", "mcp-server-12306"]
}
}
}
在此模式下,Server 启动一个 Web 服务(默认 8000 端口),支持 MCP 的 SSE 和 POST 交互。
# 安装 HTTP 模式(含 FastAPI / uvicorn)
pip install mcp-server-12306[http]
# 启动
mcp-12306
# 1. 克隆并安装依赖
git clone https://github.com/drfccv/mcp-server-12306.git
cd mcp-server-12306
uv sync --extra http
# 2. 启动服务器
uv run python scripts/start_server.py
MCP 客户端配置:
{
"mcpServers": {
"12306": {
"url": "http://localhost:8000/mcp"
}
}
}
# 拉取镜像并运行
docker run -d -p 8000:8000 --name mcp-server-12306 drfccv/mcp-server-12306:latest
| 工具名 | 功能描述 |
|---|---|
query-tickets |
余票/车次/座席/时刻一站式查询 |
query-ticket-price |
实时查询各车次票价信息 |
search-stations |
车站模糊搜索,支持中文/拼音/简拼 |
query-transfer |
中转换乘方案,自动拼接最优路径 |
get-train-route-stations |
查询指定列车经停站及时刻表 |
get-train-no-by-train-code |
车次号转官方唯一编号 |
get-current-time |
当前时间与相对日期,辅助日期选择 |
本项目所有主流程工具的详细功能、实现与使用方法,均已收录于 /docs 目录下:
每个文档包含:
如需二次开发或集成,建议先阅读对应工具的文档。
src/mcp_12306/ # 主源代码
├─ http_server.py # FastAPI HTTP 传输层
├─ stdio_server.py # Stdio 传输层 + CLI 入口
├─ services/ # 业务逻辑
│ ├─ station_service.py # 车站数据服务
│ └─ ticket_service.py # 票务查询核心(stdio/HTTP 共享)
├─ utils/ # 配置与日期工具
│ ├─ config.py
│ └─ date_utils.py
└─ resources/ # 静态资源(车站数据)
scripts/ # 启动与数据更新脚本
├─ start_server.py # HTTP 模式一键启动
└─ update_stations.py # 更新车站数据
MIT License
mcp-server-12306 is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by drfccv. 12306 MCP Server 是一个基于 Model Context Protocol (MCP) 的高性能火车票查询后端系统。它通过标准化接口提供官方 12306 的实时数据服务,包括余票查询、车站信息、列车经停站、中转换乘方案等核心功能。. It has 351 GitHub stars.
Yes. mcp-server-12306 passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/drfccv/mcp-server-12306" and add it to your Claude Code skills directory (see the Installation section above).
mcp-server-12306 is primarily written in Python. It is open-source under drfccv on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mcp-server-12306 against similar tools.
No comments yet. Be the first to share your thoughts!