[](https://github.com/Joooook)
[](https://space.bilibili.com/3546386788255839)




A 12306 ticket search server based on the Model Context Protocol (MCP). The server provides a simple API interface that allows users to search for 12306 tickets.
基于 Model Context Protocol (MCP) 的12306购票搜索服务器。提供了简单的API接口,允许大模型利用接口搜索12306购票信息。
?Features
| 功能描述 | 状态 |
|------------------------------|--------|
| 查询12306购票信息 | ✅ 已完成 |
| 过滤列车信息 | ✅ 已完成 |
| 过站查询 | ✅ 已完成 |
| 中转查询 | ? 计划内 |
| 其余接口,欢迎提feature | ? 计划内 |
⚙️Installation
git clone https://github.com/Joooook/12306-mcp.git
npm i
▶️Quick Start
CLI
npm run build
node ./build/index.js
MCP sever configuration
{
"mcpServers": {
"12306-mcp": {
"command": "npx",
"args": [
"-y",
"12306-mcp"
]
}
}
}
?️Reference
?Murmurs
本项目仅用于学习,欢迎催更。
☕️Donate
请我喝杯奶茶吧。
[
{
"description": "通过城市名查询该城市所有车站的station_code,结果为列表。",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"city": {
"description": "中文城市名称",
"type": "string"
}
},
"required": [
"city"
],
"type": "object"
},
"name": "get-stations-code-in-city"
},
{
"description": "通过城市名查询该城市对应的station_code,结果是唯一的。",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"city": {
"description": "中文城市名称",
"type": "string"
}
},
"required": [
"city"
],
"type": "object"
},
"name": "get-station-code-of-city"
},
{
"description": "通过车站名查询station_code,结果是唯一的。",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"stationName": {
"description": "中文车站名称",
"type": "string"
}
},
"required": [
"stationName"
],
"type": "object"
},
"name": "get-station-code-by-name"
},
{
"description": "通过station_telecode查询车站信息,结果是唯一的。",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"stationTelecode": {
"description": "车站的station_telecode",
"type": "string"
}
},
"required": [
"stationTelecode"
],
"type": "object"
},
"name": "get-station-by-telecode"
},
{
"description": "查询12306余票信息。",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"date": {
"description": "日期( 格式: yyyy-mm-dd )",
"maxLength": 10,
"minLength": 10,
"type": "string"
},
"fromStation": {
"description": "出发车站的station_code 或 出发城市的station_code",
"type": "string"
},
"toStation": {
"description": "到达车站的station_code 或 出发城市的station_code",
"type": "string"
},
"trainFilterFlags": {
"default": "",
"description": "车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]",
"maxLength": 8,
"pattern": "^[GDZTKOFS]*$",
"type": "string"
}
},
"required": [
"date",
"fromStation",
"toStation"
],
"type": "object"
},
"name": "get-tickets"
},
{
"description": "查询列车途径车站信息。",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"departDate": {
"description": "列车出发日期( 格式: yyyy-mm-dd )",
"maxLength": 10,
"minLength": 10,
"type": "string"
},
"fromStationTelecode": {
"description": "出发车站的station_telecode_code,而非城市的station_code.",
"type": "string"
},
"toStationTelecode": {
"description": "到达车站的station_telecode_code,而非城市的station_code.",
"type": "string"
},
"trainNo": {
"description": "实际车次编号train_no,例如240000G10336.",
"type": "string"
}
},
"required": [
"trainNo",
"fromStationTelecode",
"toStationTelecode",
"departDate"
],
"type": "object"
},
"name": "get-train-route-stations"
}
]