DM

drfccv/mcp-server-12306

Developer tools

This page was translated automatically. Technical details may differ from the original. View the original

415 stars 59 forks Quality 82 Trend 28MIT

The 12306 MCP Server is a high-performance train ticket query backend system based on the Model Context Protocol (MCP). It provides the official 12306 real-time data service through standardized interfaces, including core functions such as ticket availability inquiries, station information, train stops, and transfer solutions.

Overview

MCP Server 12306 is a high-performance train ticket inquiry service based on Model Context Protocol (MCP). It supports official 12306 ticket availability, ticket prices, stations, stops, transfer inquiries, and intelligent time tools. It is compatible with AI, automation, and intelligent assistant scenarios, ready to use out of the box. - Real-time one-stop search for remaining tickets/train numbers/seats/times/transfers - National station information management and fuzzy search, supports Chinese, Pinyin, Simplified Pinyin, and three-character codes - Full support for official stops and transfer solutions - Real-time fare information for each train - Intelligent time tool supporting time zones and timestamps - Dual transmission modes: Stdio (Claude Desktop recommended) | Streamable HTTP (remote deployment) - MCP 2025-03-26 standard, plug-and-play for AI/automation scenarios This project supports two runtime modes: 1. : Suitable for local MCP clients such as Claude Desktop (recommended). 2. : Suitable for remote deployment or access via SSE/POST. In this mode, the MCP Server communicates with clients through standard input/output, without occupying network ports. In this mode, the Server starts a web service (default port 8000) that supports MCP SSE and POST interactions. All detailed functions, implementations, and usage methods of the main process tools for this project are included in the /docs directory: Each document includes: - Tool description - Implementation methods - Request parameters and return examples - Typical call patterns - This project is for learning, research, and technical exchange only; any commercial use is strictly prohibited. - This project does not store, alter, or disseminate any official 12306 data; it only serves as intelligent aggregation and forwarding of official public interfaces. - Any consequences arising from using this project (including but not limited to account bans, data anomalies, legal risks, etc.) are the responsibility of the user; the project author assumes no responsibility. - Please comply with Chinese laws and regulations and the official 12306 rules, and use reasonably and compliantly.

Overview (machine translated)

Model Context Protocol (MCP)-based 12306 Train Ticket Inquiry Service

Supports six major query functions: remaining ticket / fare / station / stopover / transfer / time, ready to use out of the box, suitable for AI assistants, automated scripts, smart terminals, and other scenarios.


📑 Table of Contents

  • ✨ Functional characteristics
  • 🚀 Start quickly
  • Environmental requirements
  • Method 1: Stdio Mode (recommended for local clients)
  • Method 2: Streamable HTTP Mode (Remote Deployment)
  • Method 3: Docker deployment
  • 🛠️ Tool overview
  • ⚙️ Configuration item
  • 🏗️ Project structure
  • 🧑 💻 Development guide
  • 📚 Detailed documentation
  • ⚠️ Disclaimer
  • 📄 License

✨ Functional Features

Category Ability
🎫 Remaining Ticket Inquiry One-stop search for remaining tickets / train number / seat / time, supports filtering by train number
💰 Fare Inquiry Real-time view of fares for each train and seat type (business class → non-seat, full coverage)
🏙️ Station Search 3,382+ stations nationwide, supports Chinese / Pinyin / Simplified Pinyin / three-character code fuzzy search
🔄 Transfer in Transit The official transfer plan automatically paginates and captures the route, returning the full route and waiting time
🛤️ Stop Inquiry Check all stops and arrival and departure times of designated trains
🕐 Time Tool Retrieves the current time and relative date for any time zone, assisting in selecting travel dates
🔌 Dual Transmission Mode Stdio (local) | Streamable HTTP (remote), sharing the same core instance
🔄 Protocol Auto-Negotiation Based on MCP SDK v2, automatically compatible with the Handshake Era (2025-11-25) and Modern Protocols (2026-07-28)

🚀 Get Started Quickly

Environmental Requirements

Depend Request
Python >= 3.10, 💡 推荐使用 uv’: Environment isolation, fast installation, file management dependency version.

MCP Server communicates with clients through standard input/output, does not occupy network ports, and is suitable for local MCP clients such as Claude Desktop and Cursor.

Installation:

Client Configuration (e.g., claude_desktop_config.json):

Other installation methods (click to expand)

pipx:

Local source code (developer debugging):

Method 2: Streamable HTTP Mode (Remote Deployment)

This page was translated automatically. Technical details may differ from the original.

Install

uvx mcp-server-12306
New to MCP? Start with the mcpskill.org guide →

Configuration

{ "mcpServers": { "12306": { "command": "uvx", "args": ["mcp-server-12306"] } } }