Content
# 12306-MCP
A ticket search server for 12306 based on the Model Context Protocol (MCP). It provides a simple API interface that allows large models to utilize the interface to search for 12306 ticket information.
## Features
* Query 12306 ticket information
## To-Do
* Complete the remaining 12306 interfaces (transfers, station queries, etc.)
## Installation
```bash
git clone https://github.com/xpfyg/12306-mcp-service.git
cd 12306-mcp
go mod init 12306-mcp
go mod tidy
```
## Quick Start
1. Run the server
```bash
go run main.go
```
## API Example
Query ticket information:
```json
{
"from_station": "Hangzhou",
"to_station": "Wuhan",
"date": "2025-04-30"
}
```
Response example:
```json
[
{
"train_number": "G1442",
"departure_station": "Hangzhou West",
"arrival_station": "Wuhan",
"departure_time": "2025-04-26 06:07:00",
"arrival_time": "2025-04-26 10:23:00",
"duration": "04:16",
"available_tickets": [{
"seat_type": "Business Class",
"available_quantity": 3,
"price": 1018
},
{
"seat_type": "First Class",
"available_quantity": 10,
"price": 528
},
{
"seat_type": "Second Class",
"available_quantity": 21,
"price": 329
}
]
}
]
```
## Using in Cursor
To use this MCP service in Cursor IDE:
1. Ensure the 12306-MCP service is running locally.
2. Enable the MCP feature in Cursor settings.
3. Add the following to your local mcp.json:
```
"12306-mcp": {
"url": "http://127.0.0.1:8080/sse"
}
```
4. After connecting, you can use the following query example in the dialog:
```
Please help me check for high-speed train tickets from Hangzhou to Wuhan for tomorrow.
```
5. Cursor will call this service via the MCP protocol to obtain real-time ticket information.
## References
* [Model Context Protocol](https://github.com/modelcontextprotocol/modelcontextprotocol)
* [MCP Go SDK](https://github.com/mark3labs/mcp-go)
## License
MIT License
You Might Also Like
OpenWebUI
Open WebUI is an extensible web interface for customizable applications.

NextChat
NextChat is a light and fast AI assistant supporting Claude, DeepSeek, GPT4...

cherry-studio
Cherry Studio is a multilingual project for creative collaboration.

LibreChat
LibreChat is an open-source chat platform for seamless communication.

Continue
Continue is an open-source project for seamless server management.

repomix
Repomix packages your codebase into AI-friendly formats for easy use.