12306-ticket-purchase

A 12306 ticket-search server based on the Model Context Protocol (MCP), offering a simple API that allows large models to query 12306 ticket information.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "12306-ticket-purchase" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-34447668246a6e5db25e4fbc366ef3dc08a3927d5b51d598d47c606325953039. Verify the upstream source and version against https://skillhub.cn/skills/org-rn88lg3j/12306-ticket-purchase before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

A 12306 ticket-search server based on the Model Context Protocol (MCP), offering a simple API that allows large models to query 12306 ticket information.

0 Downloads

Introduction source: third_party · org-rn88lg3j · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Limits and differences
1 . **API key is necessary** and users must be asked through AskUserQuestion if no key is available 2 ** Ban ** Self-search or compilation of data in the absence of API keys
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: 12306购票搜索服务
description: 基于 Model Context Protocol (MCP) 的12306购票搜索服务器。提供了简单的API接口,允许大模型利用接口搜索12306购票信息。
version: 1.0.0
slug: 12306-ticket-purchase-search
displayName: 12306购票搜索服务
summary: 基于 Model Context Protocol (MCP) 的12306购票搜索服务器。提供了简单的API接口,允许大模型利用接口搜索12306购票信息。
license: MIT

12306购票搜索服务

基于 Model Context Protocol (MCP) 的12306购票搜索服务器。提供了简单的API接口,允许大模型利用接口搜索12306购票信息。


⚠️ 强制要求:API 密钥

此 Skill 必须配置 API 密钥才能使用。

  • 首次使用时,如果 .env 中没有 XBY_APIKEY,必须使用 AskUserQuestion 工具向用户询问 API 密钥
  • 拿到用户提供的密钥后,调用 scripts.config.set_api_key(api_key) 保存,然后继续处理
  • 获取 API 密钥:https://xiaobenyang.com
  • 禁止在缺少 API 密钥时自行搜索或编造数据

工作流程(必须遵守)

你(大模型)是路由层,负责理解用户意图、选择工具、提取参数。代码只负责调用API。

用户输入 → 你选择工具 → 提取该工具需要的参数 → 调用 scripts.tools 中的函数 → 返回结果给用户

步骤

  1. 检查 API 密钥:如果 scripts.config.settings.api_key 为空,使用 AskUserQuestion 询问用户,拿到后调用 scripts.config.set_api_key(key) 保存
  2. 选择工具:根据用户意图从下方工具列表中选择对应的工具函数
  3. 提取参数:根据选中的工具,提取该工具需要的参数
  4. 调用工具:使用关键字参数调用 scripts.tools 中的函数,例如 scripts.tools.search_schools(score='520', province='北京', category='综合')
  5. 返回结果:将工具返回的 raw 数据整理后展示给用户

工具选择规则

根据用户意图选择对应的工具函数:

用户意图 工具函数
获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 "yyyy-MM-dd"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),提供准确的日期输入。 scripts.tools.get_current_date
通过中文城市名查询该城市 所有 火车站的名称及其对应的 station_code,结果是一个包含多个车站信息的列表。 scripts.tools.get_stations_code_in_city
通过中文城市名查询代表该城市的 station_code。此接口主要用于在用户提供城市名作为出发地或到达地时,为接口准备 station_code 参数。 scripts.tools.get_station_code_of_citys
通过具体的中文车站名查询其 station_code 和车站名。此接口主要用于在用户提供具体车站名作为出发地或到达地时,为接口准备 station_code 参数。 scripts.tools.get_station_code_by_names
通过车站的 station_telecode 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 telecode 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。 scripts.tools.get_station_by_telecode
查询12306余票信息。 scripts.tools.get_tickets
查询12306中转余票信息。尚且只支持查询前十条。 scripts.tools.get_interline_tickets
查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。 scripts.tools.get_train_route_stations

如果参数不完整,使用 AskUserQuestion 向用户询问缺失的参数。


工具函数说明


scripts.tools.get_current_date

工具描述:获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 "yyyy-MM-dd"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),提供准确的日期输入。

参数定义

参数名称 参数类型 是否必填 默认值 描述

scripts.tools.get_stations_code_in_city

工具描述:通过中文城市名查询该城市 所有 火车站的名称及其对应的 station_code,结果是一个包含多个车站信息的列表。

参数定义

参数名称 参数类型 是否必填 默认值 描述
city string true 中文城市名称,例如:"北京", "上海"

scripts.tools.get_station_code_of_citys

工具描述:通过中文城市名查询代表该城市的 station_code。此接口主要用于在用户提供城市名作为出发地或到达地时,为接口准备 station_code 参数。

参数定义

参数名称 参数类型 是否必填 默认值 描述
citys string true 要查询的城市,比如"北京"。若要查询多个城市,请用

scripts.tools.get_station_code_by_names

工具描述:通过具体的中文车站名查询其 station_code 和车站名。此接口主要用于在用户提供具体车站名作为出发地或到达地时,为接口准备 station_code 参数。

参数定义

参数名称 参数类型 是否必填 默认值 描述
stationNames string true 具体的中文车站名称,例如:"北京南", "上海虹桥"。若要查询多个站点,请用

scripts.tools.get_station_by_telecode

工具描述:通过车站的 station_telecode 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 telecode 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。

参数定义

参数名称 参数类型 是否必填 默认值 描述
stationTelecode string true 车站的 station_telecode (3位字母编码)

scripts.tools.get_tickets

工具描述:查询12306余票信息。

参数定义

参数名称 参数类型 是否必填 默认值 描述
date string true 查询日期,格式为 "yyyy-MM-dd"。如果用户提供的是相对日期(如“明天”),请务必先调用 get-current-date 接口获取当前日期,并计算出目标日期。
fromStation string true 出发地的 station_code 。必须是通过 get-station-code-by-names 或 get-station-code-of-citys 接口查询得到的编码,严禁直接使用中文地名。
toStation string true 到达地的 station_code 。必须是通过 get-station-code-by-names 或 get-station-code-of-citys 接口查询得到的编码,严禁直接使用中文地名。
trainFilterFlags string false "" 车次筛选条件,默认为空,即不筛选。支持多个标志同时筛选。例如用户说“高铁票”,则应使用 "G"。可选标志:[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]
earliestStartTime number false 0.0 最早出发时间(0-24),默认为0。
latestStartTime number false 24.0 最迟出发时间(0-24),默认为24。
sortFlag string false "" 排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]
sortReverse boolean false false 是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。
limitedNum number false 0.0 返回的余票数量限制,默认为0,即不限制。
format string false "text" 返回结果格式,默认为text,建议使用text与csv。可选标志:[text, csv, json]

scripts.tools.get_interline_tickets

工具描述:查询12306中转余票信息。尚且只支持查询前十条。

参数定义

参数名称 参数类型 是否必填 默认值 描述
date string true 查询日期,格式为 "yyyy-MM-dd"。如果用户提供的是相对日期(如“明天”),请务必先调用 get-current-date 接口获取当前日期,并计算出目标日期。
fromStation string true 出发地的 station_code 。必须是通过 get-station-code-by-names 或 get-station-code-of-citys 接口查询得到的编码,严禁直接使用中文地名。
toStation string true 出发地的 station_code 。必须是通过 get-station-code-by-names 或 get-station-code-of-citys 接口查询得到的编码,严禁直接使用中文地名。
middleStation string false "" 中转地的 station_code ,可选。必须是通过 get-station-code-by-names 或 get-station-code-of-citys 接口查询得到的编码,严禁直接使用中文地名。
showWZ boolean false false 是否显示无座车,默认不显示无座车。
trainFilterFlags string false "" 车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]
earliestStartTime number false 0.0 最早出发时间(0-24),默认为0。
latestStartTime number false 24.0 最迟出发时间(0-24),默认为24。
sortFlag string false "" 排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]
sortReverse boolean false false 是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。
limitedNum number false 10.0 返回的中转余票数量限制,默认为10。
format string false "text" 返回结果格式,默认为text,建议使用text。可选标志:[text, json]

scripts.tools.get_train_route_stations

工具描述:查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。

参数定义

参数名称 参数类型 是否必填 默认值 描述
trainCode string true 要查询的车次 train_code,例如"G1033"。
departDate string true 列车出发的日期 (格式: yyyy-MM-dd)。如果用户提供的是相对日期,请务必先调用 get-current-date 解析。
format string false "text" 返回结果格式,默认为text,建议使用text。可选标志:[text, json]


返回值处理

工具函数返回 dict 对象:

  • result["raw"] - API 原始返回数据(JSON),直接将此数据整理后展示给用户
  • result["success"] - 是否成功(True/False)
  • result["message"] - 状态消息

项目结构

./
├── scripts/
│   ├── __init__.py
│   ├── config.py       # 配置管理 + set_api_key()
│   ├── call_api.py      # API 客户端 + call_api()
│   └── tools.py         # 工具函数(直接调用)
├── requirements.txt
└── SKILL.md

注意事项

  1. API 密钥是必需的,无密钥时必须通过 AskUserQuestion 询问用户
  2. 禁止在缺少 API 密钥时自行搜索或编造数据

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供12306购票搜索服务,满足用户明确的出行购票需求,实用价值高。
  • 功能覆盖全面,包括余票查询、中转查询、车次经停站查询等核心场景。
Trigger Precision95/100

Highlights

  • description 清晰准确地描述了 Skill 的核心功能和使用场景。
  • 触发词精准,边界清晰,用户能明确理解 Skill 的用途。
Structure and Standards95/100

Highlights

  • 文档结构清晰完整,包含工作流程、工具选择规则、详细的工具函数说明和参数定义。
  • 提供了项目结构说明和返回值处理规范,便于理解和使用。
Execution Reliability90/100

Highlights

  • 工具来源明确,参数定义详细且类型正确。
  • 覆盖了 API 密钥缺失等主要异常情况,并提供了明确的处理流程。
  • 不可逆操作(设置 API 密钥)有用户确认机制。
Evidence Verifiability (mean of the first four)91/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • xiaobenyang.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.