12306 MCP Server

v0.3.1Search & Data Extractionstable

A high-performance FastAPI backend for train ticket queries in China, supporting real-time ticket availability, station information, transfers, and train schedules through the Model Context Protocol for AI assistants and automation.

12306mcp-server
Share:
329
Stars
0
Downloads
0
Weekly
0/5

What is 12306 MCP Server?

12306 MCP Server is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to high-performance fastapi backend for train ticket queries in china, supporting real-time ticket availability, station information, transfers, and train schedules through the model context protocol for...

A high-performance FastAPI backend for train ticket queries in China, supporting real-time ticket availability, station information, transfers, and train schedules through the Model Context Protocol for AI assistants and automation.

This server falls under the Search & Data Extraction category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • A high-performance FastAPI backend for train ticket queries

Use Cases

Query real-time train ticket availability in China
Check train schedules and station information
drfccv

Maintainer

LicenseMIT License
Languagepython
Versionv0.3.1
UpdatedMay 17, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y mcp-server-12306

PIP

pip install mcp-server-12306

Manual Installation

npx -y mcp-server-12306

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use 12306 MCP Server

The 12306 MCP Server exposes China's national rail ticketing system to AI assistants through seven structured tools covering real-time ticket availability queries, fare lookup, fuzzy station search in Chinese and pinyin, transfer routing, and live timetable data. Built on a high-performance FastAPI backend, it connects to the 12306.cn data infrastructure and returns structured results that an AI can reason over, making it straightforward to ask natural language questions like 'find me seats from Beijing to Shanghai this Friday' and get actionable answers. It is indispensable for travelers, travel assistants, and automation scripts that need programmatic access to Chinese high-speed rail schedules.

Prerequisites

  • Python 3.10+ and pip, or uvx/pipx for zero-install execution
  • An MCP-compatible client such as Claude Desktop
  • Internet access to reach 12306.cn data endpoints (no personal 12306 account required for queries)
1

Install via pip or use uvx for zero-setup

The package is published on PyPI as mcp-server-12306. Use uvx for a self-contained, no-virtual-environment approach, or install with pip into your current environment.

pip install mcp-server-12306
# or run directly without installing:
uvx mcp-server-12306
2

Add the server to your MCP client configuration

Edit claude_desktop_config.json to launch mcp-server-12306 via uvx (recommended) or pipx. The server requires no environment variables for basic ticket queries.

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

Alternatively run the HTTP server mode

For multi-client access or remote use, run the server in HTTP mode with Docker. It listens on port 8000 and exposes SSE and POST MCP endpoints.

docker run -d -p 8000:8000 --name mcp-server-12306 drfccv/mcp-server-12306:latest
4

Configure for HTTP mode in the MCP client

If you started the Docker container, point your MCP client at the local HTTP endpoint instead of running a subprocess.

{
  "mcpServers": {
    "12306": {
      "url": "http://localhost:8000/mcp"
    }
  }
}
5

Restart the client and run a station search

Reload Claude Desktop. The 12306 server exposes: query_tickets, query_ticket_price, search_stations, get_station_info, query_transfer, get_train_route_stations, and get_current_time. Try a station search to confirm connectivity.

12306 MCP Server Examples

Client configuration

Claude Desktop config using uvx to run mcp-server-12306 without a manual install step.

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

Prompts to try

Example prompts that use the 12306 MCP Server's ticket query and station lookup tools.

- "Find available train tickets from Beijing to Shanghai this Friday, showing seat types and prices."
- "What G-train options are there from Guangzhou South to Shenzhen North tomorrow morning?"
- "Search for the station code for '上海虹桥' (Shanghai Hongqiao)."
- "Plan a transfer route from Chengdu to Xi'an with the fewest stops."
- "List all stops on train G7 from Beijing to Tianjin with departure times."

Troubleshooting 12306 MCP Server

query_tickets returns empty results for a valid route

Confirm station names are correct using search_stations first — the tool supports fuzzy matching in Chinese characters, pinyin, or abbreviations. Date format must match what 12306 expects; use get_current_time to confirm date handling.

uvx: command not found

Install uv first with: pip install uv or curl -LsSf https://astral.sh/uv/install.sh | sh. Alternatively use the pipx variant: set command to pipx and args to ["run", "--no-cache", "mcp-server-12306"].

Connection refused when using the Docker HTTP mode

Ensure Docker is running and port 8000 is not already in use. Verify the container started correctly with: docker logs mcp-server-12306. The HTTP endpoint should be http://localhost:8000/mcp.

Frequently Asked Questions about 12306 MCP Server

What is 12306 MCP Server?

12306 MCP Server is a Model Context Protocol (MCP) server that high-performance fastapi backend for train ticket queries in china, supporting real-time ticket availability, station information, transfers, and train schedules through the model context protocol for ai assistants and automation. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install 12306 MCP Server?

Install via npm with the command: npx -y mcp-server-12306. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).

Which AI clients work with 12306 MCP Server?

12306 MCP Server works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is 12306 MCP Server free to use?

Yes, 12306 MCP Server is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Search & Data Extraction MCP Servers

Explore all search & data extraction servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

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

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use 12306 MCP Server?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides