Mcp Server 12306

by drfccv

350 stars
575 downloads
Not rated
GitHub

About

12306 MCP Server​​ 是一个基于 ​​Model Context Protocol (MCP)​​ 的高性能火车票查询后端系统。它通过标准化接口提供官方 12306 的实时数据服务,包括余票查询、车站信息、列车经停站、中转换乘方案等核心功能。

Details

Author
drfccv
GitHub stars
350
Downloads
575
Categories
Other

- Real-time query of tickets, trains, seats, schedules, and transfers
- Nationwide station management with fuzzy search
- Full support for official stopover and transfer plans
- Real-time fare query for each train
- Smart time tools with timezone and timestamp support
- Dual transport modes: Stdio | Streamable HTTP

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 Mcp Server 12306
    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

Supports two operation modes: Stdio mode (recommended for Claude Desktop) and Streamable HTTP mode (for remote deployment). Stdio mode can be run via uvx or pipx; HTTP mode is started after pip installation with the [http] extra or via Docker. Client configuration for HTTP mode is http://localhost:8000/mcp.

query-tickets

官方12306余票/车次/座席/时刻一站式查询。输入出发站、到达站、日期,返回所有可购车次、时刻、历时、各席别余票等详细信息。支持中文名、三字码。 【智能筛选指南】返回结果通常包含出发/到达城市的所有相关车站(如北京/北京西/北京南)。请根据用户输入语境灵活处理: 1. 用户仅输入城市名(如'九江'):请展示所有相关站点的车次,不要过滤。 2. 用户指定具体车站(如'九江站'):优先展示匹配车站的车次,但若其他同城车站有更优方案(如时间更短、有票),也应作为补充选项提供。 请避免机械地仅通过字符串匹配过滤车次,以免遗漏用户可能感兴趣的出行方案。

query-ticket-price

查询火车票价信息。输入出发站、到达站、日期,返回各车次的票价详情。支持指定车次号过滤。 【智能筛选指南】返回结果通常包含出发/到达城市的所有相关车站(如北京/北京西/北京南)。请根据用户输入语境灵活处理: 1. 用户仅输入城市名(如'九江'):请展示所有相关站点的车次,不要过滤。 2. 用户指定具体车站(如'九江站'):优先展示匹配车站的车次,但若其他同城车站有更优方案(如时间更短、有票),也应作为补充选项提供。 请避免机械地仅通过字符串匹配过滤车次,以免遗漏用户可能感兴趣的出行方案。

search-stations

智能车站搜索。支持中文名、拼音、简拼、三字码(Code)。可用于模糊搜索(如“北京”),也可用于精确获取车站代码(如输入“BJP”返回北京站信息)。

query-transfer

官方中转换乘方案查询。输入出发站、到达站、日期,可选中转站/无座/学生票,自动分页抓取全部中转方案。

get-train-route-stations

列车经停站全表查询。支持输入车次号或官方编号,返回所有经停站、到发时刻、停留时间。

get-train-no-by-train-code

车次号转官方唯一编号(train_no),支持三字码/全名。常用于经停站查询前置转换。

get-current-time

获取当前日期和时间信息,支持相对日期计算。返回当前日期、时间,以及常用的相对日期。

Claude Desktop / Cursor

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

{
    "mcpServers": {
        "mcp server 12306": {
            "12306": {
                "command": "uvx",
                "args": [
                    "mcp-server-12306"
                ]
            }
        }
    }
}

McpServers

{
    "12306": {
        "command": "uvx",
        "args": [
            "mcp-server-12306"
        ]
    }
}

🚄 MCP Server 12306

screenshot
Python
License: MIT

---

✨ 项目简介

MCP Server 12306 是一款基于 Model Context Protocol (MCP) 的高性能火车票查询服务,支持官方 12306 余票、票价、车站、经停、换乘查询以及智能时间工具,适配 AI/自动化/智能助手等场景,开箱即用。

---

🚀 功能亮点

- 实时余票/车次/座席/时刻/换乘一站式查询
- 全国车站信息管理与模糊搜索,支持中文、拼音、简拼、三字码
- 官方经停站、中转换乘方案全支持
- 实时查询各车次票价信息
- 智能时间工具,支持时区和时间戳
- 双传输模式:Stdio(Claude Desktop 推荐)| Streamable HTTP(远程部署)
- MCP 2025-03-26 标准,AI/自动化场景即插即用

---

🛠️ 快速上手

本项目支持两种运行模式:
1. Stdio 模式:适用于 Claude Desktop 等本地 MCP 客户端(推荐)。
2. Streamable HTTP 模式:适用于远程部署或通过 SSE/POST 访问。

---

模式 1:Stdio 模式(Claude Desktop 推荐)

在此模式下,MCP Server 通过标准输入/输出与客户端通信,无需占用网络端口。

方式 A:使用 uvx(推荐)

uvxuv 包管理器提供的工具,环境隔离且启动极快。

{
  "mcpServers": {
    "12306": {
      "command": "uvx",
      "args": ["mcp-server-12306"]
    }
  }
}

方式 B:使用 pipx

如果您更习惯使用 pipx:

{
  "mcpServers": {
    "12306": {
      "command": "pipx",
      "args": ["run", "--no-cache", "mcp-server-12306"]
    }
  }
}

方式 C:本地源码运行

适用于开发者调试:

cd mcp-server-12306
uv sync
{
  "mcpServers": {
    "12306": {
      "command": "uv",
      "args": ["--directory", "/path/to/mcp-server-12306", "run", "mcp-server-12306"]
    }
  }
}

---

模式 2:Streamable HTTP 模式

在此模式下,Server 启动一个 Web 服务(默认 8000 端口),支持 MCP 的 SSE 和 POST 交互。

方式 A:pip 安装后运行

```bash

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.