MCP ExplorerExplorer

12306 Mcp Service

@xpfygon 10 months ago
1 MIT
FreeCommunity
AI Systems
# 12306 Ticket Purchase Search Server Based on Model Context Protocol (MCP) This server provides a simple API interface that allows large models to utilize the interface to search for 12306 ticket purchase information.

Overview

What is 12306 Mcp Service

12306-mcp-service is a ticket search server based on the Model Context Protocol (MCP). It provides a simple API interface that allows large models to utilize the interface for searching ticket information from the 12306 railway ticketing system.

Use cases

Use cases include querying train tickets for specific routes and dates, integrating with travel applications to provide users with ticket availability, and utilizing the service in development environments like Cursor IDE for real-time ticket queries.

How to use

To use 12306-mcp-service, clone the repository from GitHub, navigate to the project directory, initialize the Go module, and run the server using the command ‘go run main.go’. You can then make API requests to query ticket information.

Key features

Key features include querying ticket information from the 12306 system, with a straightforward API that returns details such as train number, departure and arrival stations, departure and arrival times, duration, and available ticket information.

Where to use

12306-mcp-service can be used in applications related to travel planning, ticket booking systems, and any software that requires real-time access to train ticket information in China.

Content

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

快速开始

  1. 运行服务器
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服务:

  1. 确保12306-MCP服务已在本地运行
  2. 在Cursor设置中启用MCP功能
  3. 本地mcp.json添加:
    "12306-mcp": {
      "url": "http://127.0.0.1:8080/sse"
    }
  1. 连接后即可通过对话框使用以下查询示例:
    请帮我查询杭州到武汉明天的高铁票
    
  2. Cursor将通过MCP协议调用本服务获取实时车票信息

参考

许可证

MIT License

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers