12306 Train Ticket MCP Server
Lets your AI agent check China 12306 train tickets: seats, prices, stations, stops and transfers.
420 stars on GitHubby drfccvLicense MITUpdated 19 days ago
How to install
This MCP is local: it runs on your computer.
It works in apps installed on your PC (Claude Desktop, Claude Code, Cursor, VS Codeβ¦). Choose your app:
Paste in the terminal:
claude mcp add 12306 -- uvx mcp-server-12306
Ready! Now test it
Restart the app and paste one of these requests in the chat:
Which trains from Beijing to Shanghai tomorrow still have second-class seats?
What is the price for each seat type on train G1 from Beijing South to Shanghai Hongqiao?
What it is
This server connects your agent to the official 12306 public interfaces for Chinese railways. It can look up available tickets, ticket prices, station names, the stops of a train and transfer plans. It also gives the current date and relative dates to help pick a travel day.
What it can do
query-tickets: remaining tickets, trains, seats and timesquery-ticket-price: real-time prices for each train and seat classsearch-stations: fuzzy station search by Chinese name, pinyin or codequery-transfer: transfer plans between stationsget-train-route-stations: all stops and times for a trainget-train-no-by-train-code: train code to official unique numberget-current-time: current time and relative dates
When to use
- βΊWhen you plan a train trip in China and want to compare trains and seats
- βΊWhen you need a transfer plan between two stations with waiting times
- βΊWhen you want to check the stops and times of a specific train
What you need
Skills that pair well
MCP or skill?
The MCP gives the agent the hands. The skill teaches the right way to use them. Together, the result is better and uses fewer tokens.
railway-timetableHelps your agent look up Korean train timetables for KTX and related trains. It is read-only, so it never books, pays for or cancels a ticket.launchHelps your agent take an agreed plan and deliver it step by step, splitting it into tickets, building, checking the result and reporting back.data-quality-auditorHelps your agent check a dataset's health before analysis or training, finding missing values, outliers and hidden issues, with a fix plan.Frequently asked questions
Is it free and open source?
Yes. It uses the MIT license. The README says it is for study, research and technical exchange, not for commercial use.
Does it need an API key?
No key is mentioned. It reads the official public 12306 interfaces.
Can it book tickets?
The README lists only query tools: tickets, prices, stations, transfers, stops and time. It does not list booking.
How is it run?
With uvx mcp-server-12306 in stdio mode, as a Streamable HTTP server with mcp-12306 on port 8000, or with Docker.
How many stations does it know?
The README says more than 3,382 stations nationwide.
Who is responsible for how it is used?
The README says users bear any consequences, such as account bans, and must follow Chinese law and 12306 rules.
If it does not work
- βΊCheck your Python version is between 3.10 and 3.13.
- βΊIf the HTTP port is busy, set SERVER_PORT or map another port in docker run.
- βΊMake sure your machine can reach the official 12306 interfaces.
5 new skills a week. 1 minute to read.