Data as of

12306 MCP for Claude Code: Setup & Config

12306 MCP lets Claude Code search Chinese railway ticket availability and train routes.

What you can do with 12306 in Claude Code

A focused 12306 search interface with station resolution, transfer queries, and stop-by-stop details.

  • Find direct train-ticket availability for a travel request.
  • Inspect a train's intermediate stops and timetable details.

Before you start: 12306 in Claude Code

  • Node.js and npx
  • An MCP-compatible client

Uses the README's CLI-stdio example. HTTP operation is documented with a --port argument, and Docker build/run examples cover both modes. No required environment variables or minimum Node.js version are stated.

12306 Claude Code configuration

  1. Choose Claude Code configuration scope

    For 12306 MCP, open Project scope: .mcp.json at the repository root. Project JSON: merge into mcpServers; user scope: use the CLI.

  2. Add 12306 MCP to Claude Code

    Use the 12306-mcp entry below in mcpServers. Keep 12306 MCP's documented stdio connection fields and your other Claude Code entries.

  3. Check 12306 MCP in Claude Code

    12306 MCP: Inspect claude mcp list and /mcp status.

Config file · Project scope: .mcp.json at the repository root

JSON
{
  "mcpServers": {
    "12306-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "12306-mcp"
      ],
      "env": {}
    }
  }
}

CLI (POSIX shell)
claude mcp add-json --scope project '12306-mcp' '{"type":"stdio","command":"npx","args":["-y","12306-mcp"],"env":{}}'

12306 tools available to Claude Code

12306's stored tool list documents 8 tools; compare it with Claude Code's connected tool list, because the stored list is not a live check.

get-current-date

For 12306's get-current-date, review the permission request and arguments in Claude Code before approval.

Return the current Shanghai-time date for resolving relative travel dates.

get-stations-code-in-city

For 12306's get-stations-code-in-city, review the permission request and arguments in Claude Code before approval.

List all train stations and their codes for a Chinese city name.

get-station-code-of-citys

For 12306's get-station-code-of-citys, review the permission request and arguments in Claude Code before approval.

get-station-code-by-names

For 12306's get-station-code-by-names, review the permission request and arguments in Claude Code before approval.

get-station-by-telecode

For 12306's get-station-by-telecode, review the permission request and arguments in Claude Code before approval.

get-tickets

For 12306's get-tickets, review the permission request and arguments in Claude Code before approval.

get-interline-tickets

For 12306's get-interline-tickets, review the permission request and arguments in Claude Code before approval.

Query transfer-ticket availability, currently limited to the first ten results.

get-train-route-stations

For 12306's get-train-route-stations, review the permission request and arguments in Claude Code before approval.

Inspect a train's stops, arrival and departure times, and dwell durations within an interval.

12306: full stored tool descriptions

Troubleshooting 12306 in Claude Code

  • If 12306 MCP fails to start, check npx 12306-mcp (Node.js/npm), the working directory, and Claude Code's selected scope; inspect claude mcp list and /mcp.
  • 12306 MCP uses stdio here: Claude Code must keep the configured process running; protocol output belongs on stdout and diagnostics on stderr.
  • Known limitation: The transfer query is limited to the first ten results.
  • Known limitation: Booking and payment operations are not documented.
  • Known limitation: The README frames the project as a learning tool.
  • General Claude Code troubleshooting lives in the /clients/claude-code guide.

12306 MCP — details. Claude Code guide

Frequently asked questions

Register 12306 MCP with the displayed claude mcp add-json --scope project command, or merge the JSON into .mcp.json at the repository root.

Claude Code's 12306-mcp example uses stdio.

12306 MCP's Claude Code configuration invokes npx 12306-mcp (Node.js/npm).

12306 MCP's stored list contains 8 tools, including get-current-date, get-stations-code-in-city, get-station-code-of-citys. Compare those names with Claude Code's connected tool list; the stored list is not a live check.

The supplied README and tools describe searches and timetable lookups, not ticket booking or payment.

Yes. The route-station tool returns stops and arrival, departure, and dwell information for a selected interval.