About 12306 Mcp
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project README12306-MCP
基于 Model Context Protocol (MCP) 的12306购票搜索服务器。提供了简单的API接口,允许大模型利用接口搜索12306购票信息。
功能特点
- 查询12306购票信息
待办事项
- 完成12306其余接口(中转,过站查询等)
安装
git clone https://github.com/xpfyg/12306-mcp-service.git
cd 12306-mcp
go mod init 12306-mcp
go mod tidy
快速开始
- 运行服务器
go run main.go
API 示例
查询车票信息:
{
"from_station": "杭州",
"to_station": "武汉",
"date": "2025-04-30"
}
响应示例:
[
{
"车次": "G1442",
"出发站": "杭州西",
"到达站": "武汉",
"出发时间": "2025-04-26 06:07:00",
"到达时间": "2025-04-26 10:23:00",
"历时": "04:16",
"余票信息": [{
"座位类型": "商务座",
"余票数量": 3,
"价格": 1018
},
{
"座位类型": "一等座",
"余票数量": 10,
"价格": 528
},
{
"座位类型": "二等座",
"余票数量": 21,
"价格": 329
}
]
}
]
在Cursor中使用
要在Cursor IDE中使用此MCP服务:
- 确保12306-MCP服务已在本地运行
- 在Cursor设置中启用MCP功能
- 本地mcp.json添加:
"12306-mcp": {
"url": "http://127.0.0.1:8080/sse"
}
- 连接后即可通过对话框使用以下查询示例:
请帮我查询杭州到武汉明天的高铁票 - Cursor将通过MCP协议调用本服务获取实时车票信息
参考
许可证
MIT License
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.