# mcp-server-12306

Brings seven tools to query Chinese railway schedules, ticket prices, transfers and stations via the 12306 public API.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 426 repo stars
- Author: drfccv
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/drfccv/mcp-server-12306
- Updated: 2026-09-30
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/mcp-server-12306

## What it does

The server exposes ticket availability search with train-number filtering, real-time pricing for all seat classes (business through standing), station lookup by name or code (including pinyin and abbreviations), transfer routing, per-train stop schedules, train-number-to-ID resolution, and timezone-aware current time. It runs in stdio mode (local standard I/O) or HTTP mode (web server on port 8000 for remote access). Requires Python 3.10 or later; install via `uvx`, `pip`, or the Docker image `drfccv/mcp-server-12306`.

Station data loads from `station_name.js` bundled in the package. HTTP mode adds endpoints: `/health` reports loaded stations and active sessions, `/schema/tools` serves tool JSON schemas, `/` lists version and endpoints. Configure via environment variables (`SERVER_HOST`, `SERVER_PORT`, `LOG_LEVEL`) or a `.env` file.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add mcp-server-12306 -- uvx mcp-server-12306
```
uvx runs the command named after the package; if the README names another one, use uvx --from mcp-server-12306 <command>

### Codex

**Platform CLI**
```bash
codex mcp add mcp-server-12306 -- uvx mcp-server-12306
```
uvx runs the command named after the package; if the README names another one, use uvx --from mcp-server-12306 <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mcp-server-12306": {
            "command": "uvx",
            "args": [
                "mcp-server-12306"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from mcp-server-12306 <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mcp-server-12306": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "mcp-server-12306"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from mcp-server-12306 <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add mcp-server-12306 uvx mcp-server-12306
```
uvx runs the command named after the package; if the README names another one, use uvx --from mcp-server-12306 <command>

## When to use it
- query remaining seats on a train between two Chinese cities
- fetch ticket prices for all service classes
- look up a station by Chinese name or three-letter code
- calculate transfer routes using the official 12306 API
- retrieve the full stop schedule of a specific train

## Example prompts
- Show available tickets from Beijing to Shanghai tomorrow
- What does business class cost on train G123 from Guangzhou to Shenzhen on May 15?
- Find the station with code BJP

## Similar
- [12306](https://affpapa.org/en/nevibecode/skills/12306.md) — skill · 645 installs
- [hot-topics](https://affpapa.org/en/nevibecode/skills/hot-topics.md) — skill · 2100 installs
- [Zendesk](https://affpapa.org/en/nevibecode/skills/zendesk.md) — skill · ★ 239 repo stars
- [rollinggo-hotel-booking](https://affpapa.org/en/nevibecode/skills/rollinggo-hotel-booking.md) — skill · 6 installs
- [weather-query](https://affpapa.org/en/nevibecode/skills/weather-query.md) — skill · 828 installs
- [Kiwi.com](https://affpapa.org/en/nevibecode/mcp/kiwicom.md) — MCP server · 2194 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
