12306 MCP Server
The 12306 MCP Server is a high-performance railway ticket inquiry service that interfaces with China's official 12306 railway system via the Model Context Protocol (MCP).
Query Train Tickets (
query-tickets): Search real-time train availability between stations for a given date, returning schedules, durations, and seat availability across all seat classes.Query Ticket Prices (
query-ticket-price): Retrieve detailed fare information for trains between two stations, with optional filtering by train number and passenger type (adult/student).Search Train Stations (
search-stations): Intelligently search for stations using Chinese characters, pinyin, abbreviated pinyin, or three-letter station codes — supports fuzzy search.Query Transfer/Connecting Routes (
query-transfer): Find optimal transfer plans between two stations, with options to specify a transfer station, seat preferences, and student tickets.Get Train Route & Stops (
get-train-route-stations): Retrieve the full list of stops for a specific train, including arrival/departure times and dwell times at each station.Convert Train Code to Official ID (
get-train-no-by-train-code): Convert a human-readable train number (e.g., G1) to the official unique internal identifier, typically needed before querying route stops.Get Current Time (
get-current-time): Retrieve the current date/time with timezone support and relative date calculations, useful for assisting with date input.
Supports both Stdio mode (for local clients like Claude Desktop) and Streamable HTTP mode (for remote/Docker deployment), implementing the MCP 2025-03-26 standard for seamless AI and automation integration.
Provides containerized deployment of the 12306 MCP Server with pre-built images available on Docker Hub, allowing for isolated and portable execution across different environments
Supports configuration through environment variables using .env files, allowing customization of server settings
Implements an async high-performance API server using FastAPI, enabling real-time train ticket queries with SSE streaming protocol support
Supports installation via Git repository cloning, enabling access to the latest code and version control features
Hosts the source code repository, enabling collaboration, issue tracking and access to the codebase
Includes testing infrastructure for verifying functionality of the 12306 train ticket querying components
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@12306 MCP Servercheck tickets from Beijing to Shanghai for tomorrow"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🚄 MCP Server 12306
基于 Model Context Protocol (MCP) 的 12306 火车票查询服务
支持 余票 / 票价 / 车站 / 经停 / 换乘 / 时间 六大查询能力,开箱即用,适配 AI 助手、自动化脚本、智能终端等场景。
📑 目录
Related MCP server: 12306 Train Ticket Search MCP Server
✨ 功能特性
类别 | 能力 |
🎫 余票查询 | 余票 / 车次 / 座席 / 时刻一站式查询,支持按车次过滤 |
💰 票价查询 | 实时查询各车次各席别票价(商务座 → 无座全覆盖) |
🏙️ 车站搜索 | 全国 3382+ 车站,支持中文 / 拼音 / 简拼 / 三字码模糊搜索 |
🔄 中转换乘 | 官方换乘方案自动分页抓取,返回完整路径与等待时间 |
🛤️ 经停查询 | 查询指定列车全部经停站与到发时刻 |
🕐 时间工具 | 获取任意时区当前时间、相对日期计算,辅助选择出行日期 |
🔌 双传输模式 | Stdio(本地)| Streamable HTTP(远程),同一核心实例共享 |
🔄 协议自动协商 | 基于 MCP SDK v2,自动兼容握手时代(2025-11-25)与现代协议(2026-07-28) |
🚀 快速开始
环境要求
依赖 | 要求 |
Python |
|
包管理器 |
|
网络 | 可访问 12306 官方接口 |
💡 推荐使用
uv:环境隔离、安装快、锁文件管理依赖版本。
方式一:Stdio 模式(本地客户端推荐)
MCP Server 通过标准输入/输出与客户端通信,不占用网络端口,适合 Claude Desktop、Cursor 等本地 MCP 客户端。
安装:
# uvx(推荐,环境隔离)
uvx mcp-server-12306
# 或 pip / pipx
pip install mcp-server-12306客户端配置(如 claude_desktop_config.json):
{
"mcpServers": {
"12306": {
"command": "uvx",
"args": ["mcp-server-12306"]
}
}
}pipx:
{
"mcpServers": {
"12306": {
"command": "pipx",
"args": ["run", "--no-cache", "mcp-server-12306"]
}
}
}本地源码(开发者调试):
git clone https://github.com/drfccv/mcp-server-12306.git
cd mcp-server-12306
uv sync{
"mcpServers": {
"12306": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-server-12306", "run", "mcp-server-12306"]
}
}
}方式二:Streamable HTTP 模式(远程部署)
Server 启动 Web 服务(默认
8000端口),通过 MCP Streamable HTTP 协议通信:POST发送 JSON-RPC、GET订阅流式响应、DELETE结束会话。
启动:
# 安装后直接启动
mcp-12306
# 或本地源码启动
uv run python scripts/start_server.py客户端配置:
{
"mcpServers": {
"12306": {
"url": "http://localhost:8000/mcp"
}
}
}内置 HTTP 端点:
端点 | 方法 | 说明 |
| POST / GET / DELETE | MCP Streamable HTTP 协议入口 |
| GET | 健康检查(含已加载车站数、活跃会话数) |
| GET | 全部工具 JSON Schema |
| GET | 服务信息(版本、协议版本、端点) |
方式三:Docker 部署
# 拉取镜像并运行(默认端口 8000)
docker run -d -p 8000:8000 --name mcp-server-12306 drfccv/mcp-server-12306:latest
# 自定义端口
docker run -d -p 8080:8000 \
-e SERVER_HOST=0.0.0.0 \
-e SERVER_PORT=8000 \
--name mcp-server-12306 \
drfccv/mcp-server-12306:latest🛠️ 工具一览
工具名 | 功能 | 必填参数 |
| 余票 / 车次 / 座席 / 时刻一站式查询 |
|
| 实时查询车次票价 |
|
| 车站模糊搜索(中文 / 拼音 / 简拼 / 三字码) |
|
| 中转换乘方案查询 |
|
| 查询列车经停站及时刻表 |
|
| 车次号 → 官方唯一编号 |
|
| 当前时间与相对日期(辅助选日期) | 无 |
📖 每个工具的参数说明、返回示例、调用示例详见 📚 详细文档。
⚙️ 配置项
通过环境变量或项目根目录 .env 文件配置:
环境变量 | 默认值 | 说明 |
|
| HTTP 监听地址 |
|
| HTTP 监听端口 |
|
| 调试模式 |
|
| 日志级别( |
# 示例:.env
SERVER_HOST=127.0.0.1
SERVER_PORT=8000
LOG_LEVEL=INFO🏗️ 项目结构
mcp-server-12306/
├── src/mcp_12306/ # 主包
│ ├── server.py # 核心 Server(工具注册与分发,双传输共享)
│ ├── stdio_server.py # Stdio 传输层 + CLI 入口
│ ├── http_server.py # Streamable HTTP 传输层 + HTTP 端点
│ ├── services/ # 业务逻辑
│ │ ├── station_service.py # 车站数据服务(加载/搜索/编码转换)
│ │ └── ticket_service.py # 票务查询核心(7 个工具实现)
│ ├── utils/ # 配置与日期工具
│ │ ├── config.py # pydantic-settings 配置
│ │ └── date_utils.py # 日期校验工具
│ └── resources/ # 静态资源(车站数据 station_name.js)
├── scripts/ # 运维脚本
│ ├── start_server.py # HTTP 模式一键启动(环境自检)
│ └── update_stations.py # 更新车站数据
├── docs/ # 工具详细文档
├── pyproject.toml # 项目元数据 / 依赖 / 构建配置
├── Dockerfile # 多阶段构建(python:3.12-alpine)
├── server.json # MCP 注册表元数据
└── uv.lock # 依赖锁文件🧑💻 开发指南
# 1. 克隆并初始化
git clone https://github.com/drfccv/mcp-server-12306.git
cd mcp-server-12306
uv sync
# 2. 类型检查(mypy,严格模式)
uv run mypy src scripts
# 3. 代码格式化
uv run black src scripts
uv run isort src scripts
# 4. 构建与发布
uv run python -m build
uv run twine upload dist/*架构要点:
server.py是传输无关的核心模块——工具注册(TOOL_HANDLERS)与业务分发(call_tool)都在此,stdio 与 HTTP 复用同一实例,保证两种模式行为完全一致。工具 Schema 单一来源于
ticket_service.MCP_TOOLS,HTTP 的/schema/tools端点与 MCP 工具列表同源。网络请求统一走
_request_with_retry(自动重试 + init 会话保持),业务错误与网络错误分离处理。
📚 详细文档
文档 | 内容 |
余票 / 车次 / 座席 / 时刻一站式查询 | |
实时票价查询 | |
车站智能搜索 | |
中转换乘方案 | |
列车经停站查询 | |
当前时间与相对日期 |
每份文档均包含:功能说明、实现方法、请求参数、返回示例与典型调用方式。
⚠️ 免责声明
本项目仅供学习、研究与技术交流,严禁用于任何商业用途。
本项目不存储、不篡改、不传播任何 12306 官方数据,仅作为官方公开接口的智能聚合与转发。
使用本项目造成的任何后果(包括但不限于账号封禁、数据异常、法律风险等)均由使用者本人承担,项目作者不承担任何责任。
请遵守中国法律法规及 12306 官方相关规定,合理合规使用。
📄 License
⭐ 如果这个项目对你有帮助,欢迎 Star 支持!
Available Tools
7 toolsget-current-timeC
获取当前日期和时间信息,支持相对日期计算。返回当前日期、时间,以及常用的相对日期。
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | 时区 | Asia/Shanghai |
| format | No | 日期格式 | YYYY-MM-DD |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool returns '当前日期、时间,以及常用的相对日期' (current date, time, and commonly used relative dates), which gives some output context. However, it lacks details on rate limits, error conditions, authentication needs, or whether the operation is read-only (implied but not stated). For a tool with zero annotation coverage, this is insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and front-loaded, stating the core purpose in the first clause. The second clause adds useful context about relative date calculation. There's no wasted language, though it could be slightly more structured (e.g., separating core functionality from additional features).
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's low complexity (2 optional parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and hints at output content, but lacks details on return format, error handling, or examples. Without annotations or output schema, more completeness would be beneficial, especially for behavioral aspects.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds no specific parameter semantics beyond what the input schema provides. The schema has 100% description coverage with clear explanations for both parameters ('timezone' and 'format'), including defaults. The description's mention of '相对日期计算' (relative date calculation) might relate to parameters but doesn't clarify how. With high schema coverage, the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '获取当前日期和时间信息' (get current date and time information). It specifies the verb ('获取') and resource ('当前日期和时间信息'), and mentions additional functionality ('支持相对日期计算' - supports relative date calculation). However, it doesn't explicitly differentiate from sibling tools, which are all train-related, making the distinction obvious but not stated.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, constraints, or scenarios where this tool is preferred over other time/date tools (though none exist among the siblings). The phrase '支持相对日期计算' (supports relative date calculation) hints at a use case but doesn't provide explicit when/when-not guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-train-no-by-train-codeB
车次号转官方唯一编号(train_no),支持三字码/全名。常用于经停站查询前置转换。
| Name | Required | Description | Default |
|---|---|---|---|
| train_code | Yes | 车次号 | |
| from_station | Yes | 出发站 | |
| to_station | Yes | 到达站 | |
| train_date | Yes | 出发日期,格式:YYYY-MM-DD |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool supports conversion for three-character codes and full names, which adds some context beyond the schema. However, it lacks critical behavioral details such as error handling (e.g., what happens with invalid codes), response format, or any rate limits or authentication needs for a conversion tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is highly concise and front-loaded, consisting of two sentences that efficiently convey the core purpose and usage context without any wasted words. Every sentence earns its place by adding value beyond the tool name.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has 4 required parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., the structure of train_no), error conditions, or prerequisites for successful conversion. For a conversion tool with no structured output documentation, this leaves significant gaps for an AI agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all four parameters (train_code, from_station, to_station, train_date) with descriptions. The description adds marginal value by implying that train_code can be a three-character code or full name, but doesn't provide additional semantics like examples or constraints beyond what's in the schema. Baseline 3 is appropriate when the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: converting train codes to official train numbers (train_no), specifying it supports both three-character codes and full names. It distinguishes this as a 'pre-conversion' step for station queries, which helps differentiate it from direct query tools. However, it doesn't explicitly contrast with all sibling tools like get-train-route-stations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides implied usage context by mentioning this is 'commonly used as a pre-conversion step for station stop queries,' which suggests when to use it (before querying stations). However, it doesn't explicitly state when NOT to use it or name specific alternatives among sibling tools like get-train-route-stations or query-tickets.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-train-route-stationsA
列车经停站全表查询。支持输入车次号或官方编号,返回所有经停站、到发时刻、停留时间。
| Name | Required | Description | Default |
|---|---|---|---|
| train_no | Yes | 车次编码或车次号 | |
| from_station | Yes | 出发站 | |
| to_station | Yes | 到达站 | |
| train_date | Yes | 出发日期,格式:YYYY-MM-DD |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It describes the query behavior and return data, but lacks details on permissions, rate limits, error handling, or data freshness. For a read operation with no annotation coverage, this is a significant gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded and concise with two sentences that efficiently convey purpose, inputs, and outputs. Every sentence adds value without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, no output schema, and 100% schema coverage, the description adequately covers the query purpose but lacks behavioral context and output details. It is minimally viable but incomplete for a tool with four required parameters.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all four parameters. The description adds minimal value by mentioning '车次号或官方编号' which aligns with train_no, but does not provide additional context beyond what the schema specifies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('查询', '返回') and resources ('列车经停站全表', '所有经停站、到发时刻、停留时间'). It distinguishes itself from siblings by focusing on route station details rather than time, pricing, tickets, transfers, or station searches.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by specifying inputs ('车次号或官方编号') and outputs, but does not explicitly state when to use this tool versus alternatives like query-tickets or query-transfer. No exclusions or prerequisites are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
query-ticket-priceA
查询火车票价信息。输入出发站、到达站、日期,返回各车次的票价详情。支持指定车次号过滤。
【智能筛选指南】返回结果通常包含出发/到达城市的所有相关车站(如北京/北京西/北京南)。请根据用户输入语境灵活处理:
用户仅输入城市名(如'九江'):请展示所有相关站点的车次,不要过滤。
用户指定具体车站(如'九江站'):优先展示匹配车站的车次,但若其他同城车站有更优方案(如时间更短、有票),也应作为补充选项提供。 请避免机械地仅通过字符串匹配过滤车次,以免遗漏用户可能感兴趣的出行方案。
| Name | Required | Description | Default |
|---|---|---|---|
| from_station | Yes | 出发站 | |
| to_station | Yes | 到达站 | |
| train_date | Yes | 出发日期 | |
| train_code | No | 车次号(可选) | |
| purpose_codes | No | 乘客类型 (ADULT=成人, 0X=学生) | ADULT |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden. It discloses important behavioral traits: the tool returns fare details for all relevant stations when given a city name, prioritizes matching stations when specified but includes alternatives with better options, and warns against overly strict filtering. However, it doesn't mention rate limits, authentication needs, or error conditions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a clear purpose statement followed by detailed usage guidelines. Every sentence adds value, though the guidelines section is somewhat lengthy. It's front-loaded with the core functionality, making it easy to understand quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 5 parameters, no annotations, and no output schema, the description does a good job explaining the tool's behavior and usage. It covers input interpretation, filtering logic, and result handling. However, it doesn't describe the output format (what '票价详情' includes) or potential error cases, leaving some gaps for a tool with this complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds meaningful context beyond the schema: it explains how 'from_station' and 'to_station' parameters should be interpreted (city vs. station names), mentions the optional 'train_code' filtering capability, and implies how results are structured. This provides valuable semantic guidance not captured in the schema alone.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '查询火车票价信息' (query train ticket price information) with specific inputs (departure station, arrival station, date) and outputs (fare details for each train). It distinguishes from siblings like 'query-tickets' (likely broader ticket search) and 'query-transfer' (transfer options) by focusing specifically on pricing details.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit usage guidelines in the '智能筛选指南' section, detailing when to use different filtering approaches based on user input (city name vs. specific station). It also mentions supporting train code filtering, which helps differentiate from other tools like 'query-tickets' that might not have this feature.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
query-ticketsA
官方12306余票/车次/座席/时刻一站式查询。输入出发站、到达站、日期,返回所有可购车次、时刻、历时、各席别余票等详细信息。支持中文名、三字码。
【智能筛选指南】返回结果通常包含出发/到达城市的所有相关车站(如北京/北京西/北京南)。请根据用户输入语境灵活处理:
用户仅输入城市名(如'九江'):请展示所有相关站点的车次,不要过滤。
用户指定具体车站(如'九江站'):优先展示匹配车站的车次,但若其他同城车站有更优方案(如时间更短、有票),也应作为补充选项提供。 请避免机械地仅通过字符串匹配过滤车次,以免遗漏用户可能感兴趣的出行方案。
| Name | Required | Description | Default |
|---|---|---|---|
| from_station | Yes | 出发车站名称 | |
| to_station | Yes | 到达车站名称 | |
| train_date | Yes | 出发日期,格式:YYYY-MM-DD |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns '所有可购车次、时刻、历时、各席别余票等详细信息' (all purchasable train numbers, schedules, durations, seat availability details), supports Chinese names and three-letter codes, and explains how results are filtered based on station specificity. However, it doesn't mention rate limits, authentication needs, or error handling, leaving some gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by a detailed usage guide. Every sentence earns its place by adding critical context, though it could be slightly more concise by integrating the filtering guidelines more tightly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 3 parameters with full schema coverage, no annotations, and no output schema, the description does well by explaining the return format ('返回所有可购车次、时刻、历时、各席别余票等详细信息') and usage nuances. However, it lacks details on output structure (e.g., pagination, error responses), which would be helpful since there's no output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds significant value by explaining parameter semantics beyond the schema: it clarifies that inputs can be '中文名、三字码' (Chinese names, three-letter codes) and provides context on how station names are interpreted (city vs. specific station), which isn't in the schema. This elevates the score above baseline.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '官方12306余票/车次/座席/时刻一站式查询' (official 12306 ticket availability/train numbers/seats/schedule one-stop query). It specifies the exact resource (train tickets) and verb (query), and distinguishes it from siblings like query-ticket-price (price only) and query-transfer (transfer options).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool vs. alternatives through the '智能筛选指南' (intelligent filtering guide). It details how to handle different input scenarios (city names vs. specific stations) and advises against mechanical filtering, which implicitly suggests this is the primary tool for comprehensive train schedule and availability queries rather than more specialized siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
query-transferA
官方中转换乘方案查询。输入出发站、到达站、日期,可选中转站/无座/学生票,自动分页抓取全部中转方案。
| Name | Required | Description | Default |
|---|---|---|---|
| from_station | Yes | 出发站 | |
| to_station | Yes | 到达站 | |
| train_date | Yes | 出发日期,格式:YYYY-MM-DD | |
| middle_station | No | 指定中转站(可选) | |
| isShowWZ | No | 是否显示无座车次(Y/N) | N |
| purpose_codes | No | 乘客类型(00=普通,0X=学生) | 00 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It usefully describes that the tool '自动分页抓取全部中转方案' (automatically paginates and fetches all transfer solutions), which adds important behavioral context about pagination and completeness. However, it doesn't mention potential limitations like rate limits, authentication requirements, or error conditions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is perfectly concise - a single sentence that front-loads the core purpose and efficiently lists key parameters and behavioral characteristics. Every word earns its place with no redundancy or unnecessary elaboration.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a query tool with 6 parameters, 100% schema coverage, but no annotations and no output schema, the description provides adequate but minimal context. It covers the core purpose and key behavioral trait (automatic pagination), but doesn't address what the output looks like, potential error cases, or system limitations that would be helpful for an AI agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already documents all 6 parameters thoroughly. The description adds minimal value beyond the schema - it mentions the three required parameters (出发站, 到达站, 日期) and the optional filters (中转站/无座/学生票), but doesn't provide additional semantic context about parameter interactions or usage nuances.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('查询' - query, '抓取' - fetch) and resources ('中转换乘方案' - transfer solutions). It distinguishes itself from sibling tools like 'query-tickets' (direct tickets) and 'query-ticket-price' (price queries) by focusing specifically on transfer/connection solutions between stations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool: when users need transfer solutions between stations with optional filters. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools (e.g., use 'query-tickets' for direct tickets without transfers).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search-stationsA
智能车站搜索。支持中文名、拼音、简拼、三字码(Code)。可用于模糊搜索(如“北京”),也可用于精确获取车站代码(如输入“BJP”返回北京站信息)。
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 车站搜索关键词,支持:车站名称、拼音、简拼等 | |
| limit | No | 返回结果的最大数量 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the search functionality and input types, but lacks details about response format, error handling, performance characteristics, or any limitations beyond the query examples. The description doesn't contradict any annotations (none exist), but could provide more complete behavioral context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is efficiently structured in two sentences: the first establishes the core functionality and supported input types, the second provides concrete usage examples. Every element serves a purpose with no wasted words, making it easy to parse while conveying essential information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a search tool with no annotations and no output schema, the description provides adequate but incomplete context. It covers the purpose and usage well, but lacks information about what the search returns (station details, codes, locations?), how results are ordered, or any limitations beyond the parameter constraints. Given the tool's relative simplicity and good schema coverage, this is minimally adequate but could be more complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, so the schema already fully documents both parameters. The description mentions the types of queries supported (Chinese name, pinyin, abbreviation, code) which aligns with the schema's description of the query parameter, but doesn't add significant semantic value beyond what the structured schema provides. The baseline of 3 is appropriate given the comprehensive schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose as '智能车站搜索' (intelligent station search) and specifies the types of inputs it supports (Chinese name, pinyin, abbreviation, three-letter code). It distinguishes itself from siblings by focusing on station search rather than train or ticket operations. However, it doesn't explicitly contrast with specific sibling tools like 'get-train-route-stations' which might also involve station data.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear usage context with examples for both fuzzy search (e.g., '北京') and exact code lookup (e.g., 'BJP'), helping users understand when to apply different query strategies. It implicitly suggests this tool is for station information retrieval, but doesn't explicitly state when to use alternatives like 'query-tickets' or 'get-train-route-stations' for related but different purposes.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
7 tool updates
v0.3.0- First observed
get-current-time - First observed
get-train-no-by-train-code - First observed
get-train-route-stations - First observed
query-ticket-price - First observed
query-tickets - First observed
query-transfer - First observed
search-stations
TDQS
Each tool has a clearly distinct purpose with no overlap: get-current-time provides time/date info, get-train-no-by-train-code converts train codes, get-train-route-stations shows station stops, query-ticket-price gives pricing, query-tickets shows availability, query-transfer finds connections, and search-stations locates stations. The descriptions clearly differentiate their functions.
All tools follow a consistent verb_noun or verb-noun-noun pattern using snake_case (e.g., get-current-time, query-ticket-price, search-stations). There are no deviations in naming style, making the set predictable and readable.
With 7 tools, this server is well-scoped for a 12306 train service domain. Each tool serves a specific, non-redundant function, covering core operations like time lookup, code conversion, station search, route details, pricing, ticket availability, and transfers, which is appropriate for this use case.
The tool set provides comprehensive coverage for querying train information, including time, routes, prices, tickets, transfers, and stations. Minor gaps might include operations like booking tickets or managing user accounts, but these are likely outside the server's intended query-focused scope, and agents can work effectively with the provided tools.
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 Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
TravelMind: 8 MCP tools for travel (12306 trains, flights, hotels, geocode, planning, policy).
MCP server for China Railway 12306 ticket availability: schedules and seats by Chinese station name.
21Search and compare flight offers through a cache-aware Streamable HTTP MCP server for AI agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceA Model Context Protocol server that allows large language models to search for and analyze Chinese railway (12306) tickets through a simple API interface.88,31318MIT
- AlicenseNot gradedqualityDmaintenanceEnables searching for train tickets on China's 12306 railway system, including ticket availability queries, train filtering, station stopover information, and transfer route planning.8,3132MIT
- AlicenseBqualityDmaintenance12306 ticket purchase search server based on Model Context Protocol (MCP). It provides a simple API interface, allowing large models to search for 12306 ticket purchasing information through the interface.81Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables querying train and high-speed rail schedules, durations, and seat availability between Chinese stations using 12306 data, with automatic fallback to simulated data when the API is rate-limited.-
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/drfccv/mcp-server-12306'
If you have feedback or need assistance with the MCP directory API, please join our Discord server