12306 Mcp

by Joooook

1.1k stars
686 downloads
Not rated
GitHub

About

This is a 12306 ticket search server based on the Model Context Protocol (MCP).

Details

Author
Joooook
GitHub stars
1,079
Downloads
686
Categories
Search, Knowledge Base, Other

- Query 12306 ticket information
- Filter train information
- Pass-through station query
- Transfer (connecting) query

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name 12306 Mcp
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Clone the repository and run npm i. Use npx -y 12306-mcp to start with stdio transport, or npx -y 12306-mcp --port [port] for HTTP transport. Docker images can be built and run with similar commands. The MCP server configuration for clients requires setting the command and args as shown in the README.

get-current-date

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

get-stations-code-in-city

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

get-station-code-of-citys

通过中文城市名查询代表该城市的 `station_code`。

get-station-code-by-names

通过具体的中文车站名查询其 `station_code` 和车站名。

get-station-by-telecode

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

get-tickets

查询12306余票信息。

get-interline-tickets

查询12306中转余票信息。尚且只支持查询前十条。

get-train-route-stations

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

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "12306 mcp": {
            "12306-mcp": {
                "command": "npx",
                "args": [
                    "-y",
                    "12306-mcp"
                ]
            }
        }
    }
}

McpServers

{
    "12306-mcp": {
        "command": "npx",
        "args": [
            "-y",
            "12306-mcp"
        ]
    }
}
# <div align="center">12306-mcp</div> <div align="center"> [![](https://img.shields.io/badge/Joooook-blue.svg?logo=github&lable=python&labelColor=497568&color=497568&style=flat-square)](https://github.com/Joooook) [![](https://img.shields.io/badge/Joooook-blue.svg?logo=bilibili&logoColor=white&lable=python&labelColor=af7a82&color=af7a82&style=flat-square)](https://space.bilibili.com/3546386788255839) ![](https://img.shields.io/badge/typescript-blue.svg?logo=typescript&lable=typescript&logoColor=white&labelColor=192c3b&color=192c3b&style=flat-square) ![](https://img.shields.io/github/stars/Joooook/12306-mcp?logo=reverbnation&lable=python&logoColor=white&labelColor=ffc773&color=ffc773&style=flat-square) ![](https://img.shields.io/github/last-commit/Joooook/12306-mcp.svg?style=flat-square) ![](https://img.shields.io/github/license/Joooook/12306-mcp.svg?style=flat-square&color=000000) </div> 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购票信息。 ## <div align="center">🚩Features</div> <div align="center"> | 功能描述 | 状态 | |------------------------------|--------| | 查询12306购票信息 | ✅ 已完成 | | 过滤列车信息 | ✅ 已完成 | | 过站查询 | ✅ 已完成 | | 中转查询 | ✅ 已完成 | | 其余接口,欢迎提feature | 🚧 计划内 | </div> <div align="center"> <img src="https://s2.loli.net/2025/04/15/UjbrG5esaSEmJxN.jpg" width=800px/> </div> <div align="center"> <img src="https://s2.loli.net/2025/04/15/rm1j8zX7sqiyafP.jpg" width=800px/> </div> ## <div align="center">⚙️Installation</div> ~~~bash git clone https://github.com/Joooook/12306-mcp.git npm i ~~~ ## <div align="center">▶️Quick Start</div> ### CLI-stdio ~~~bash npx -y 12306-mcp ~~~ ### CLI-http ~~~bash npx -y 12306-mcp --port [端口号] ~~~ ### MCP sever configuration ~~~json { "mcpServers": { "12306-mcp": { "command": "npx", "args": [ "-y", "12306-mcp" ] } } } ~~~ ### Docker-stdio ~~~bash docker build . -t 12306-mcp docker run --rm -it 12306-mcp npx 12306-mcp ~~~ ### Docker-http ~~~bash docker build . -t 12306-mcp docker run -p [your_port]:8080 -d 12306-mcp npx 12306-mcp --port 8080 ~~~ ## <div align="center">📚Documentation</div> - [服务原理详解](./docs/principle.md) 12306-MCP服务的工作原理 - [架构图](./docs/architecture.md) 12306-MCP服务的架构图 ![12306-MCP 服务架构图](./docs/architecture.png) ## <div align="center">👉️Reference</div> - [modelcontextprotocol/modelcontextprotocol](https://github.com/modelcontextprotocol/modelcontextprotocol) - [modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) ## <div align="center">💭Murmurs</div> 本项目仅用于学习,欢迎催更。 ## <div align="center">🎫Badges</div> <div align="center"> <a href="https://glama.ai/mcp/servers/@Joooook/12306-mcp"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@Joooook/12306-mcp/badge" alt="12306-mcp MCP server" /> </a> [![MseeP.ai Security Assessment Badge](https://mseep.net/pr/joooook-12306-mcp-badge.png)](https://mseep.ai/app/joooook-12306-mcp) </div> ## <div align="center">☕️Donate</div> 请我喝杯奶茶吧。 <div align="center"> <a href="https://afdian.com/item/2a0e0cdcadf911ef9f725254001e7c00"> <img src="https://s2.loli.net/2024/11/29/1JBxzphs7V6WcK9.jpg" width="500px"> </a> </div>
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.