12306-mcp

MCP.Pizza Chef: Joooook

Ask about trains between two Chinese cities and you get real timetable results back: departure times, seat classes, and what is still available, without opening the website yourself. It also narrows a long list down, checks which stations a train passes through, and works out connecting journeys when there is no direct service. No account and no paid key are needed. It searches only, so you still buy tickets on 12306 itself. The author describes it as a learning project.

Web/Research

Use This MCP server To

Find trains from Beijing to Shanghai on a specific date Check which seat classes still have tickets left Work out a connecting route when no direct train exists See every station a particular train stops at Compare morning and evening departures without opening the booking site

README

12306-mcp

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购票信息。

如需Skill -> https://github.com/Joooook/12306-skill

🚩Features

功能描述 状态
查询12306购票信息 ✅ 已完成
过滤列车信息 ✅ 已完成
过站查询 ✅ 已完成
中转查询 ✅ 已完成
其余接口,欢迎提feature 🚧 计划内

⚙️Installation

git clone https://github.com/Joooook/12306-mcp.git
npm i

▶️Quick Start

CLI-stdio

npx -y 12306-mcp

CLI-http

npx -y 12306-mcp --port [端口号]

Runtime requirements

The server requires Node.js 18 or newer. The npm run debug command uses MCP Inspector 2.0.0, which requires Node.js 22.19.0 or newer.

MCP sever configuration

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

Docker-stdio

docker build . -t 12306-mcp
docker run --rm -it 12306-mcp npx 12306-mcp

Docker-http

docker build . -t 12306-mcp
docker run -p [your_port]:8080 -d 12306-mcp npx 12306-mcp --port 8080

📚Documentation

  • 服务原理详解 12306-MCP服务的工作原理
  • 架构图 12306-MCP服务的架构图 12306-MCP 服务架构图

👉️Reference

💭Murmurs

本项目仅用于学习,欢迎催更。

🎫Badges

☕️Donate

请我喝杯奶茶吧。

12306-mcp FAQ

Can I use this to buy a ticket?
No. It searches and compares trains only. You still complete the purchase on 12306 yourself.
Do I need an account or a paid key?
No. It reads publicly available timetable and availability information, so there is nothing to sign up for.
Which assistants can use it?
Any app that accepts a small settings block, such as Claude Desktop, Cursor, or Cline.
How hard is setup?
You paste a few lines into your assistant's settings. It needs Node 18 or newer on your computer.
Does it cover trains outside China?
No. It only covers the Chinese national railway service run through 12306.
Can I use this to plan a multi-leg trip?
Yes. It can look up connecting journeys when there is no direct train between the two cities you name.