Data as of

12306 MCP for VS Code: Setup & Config

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

What you can do with 12306 in VS 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.
  • Resolve Chinese city and station names into station codes.

Before you start: 12306 in VS 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 VS Code configuration

  1. Choose VS Code configuration scope

    For 12306 MCP, open Workspace: .vscode/mcp.json. Merge into servers; preserve existing inputs.

  2. Add 12306 MCP to VS Code

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

  3. Check 12306 MCP in VS Code

    12306 MCP: Start in VS Code’s MCP controls; inspect output and trust prompts.

Config file · Workspace: .vscode/mcp.json

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

12306 tools available to VS Code

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

get-current-date

Look for get-current-date among VS Code's agent-mode tools after starting 12306 through the MCP controls.

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

get-stations-code-in-city

Look for get-stations-code-in-city among VS Code's agent-mode tools after starting 12306 through the MCP controls.

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

get-station-code-of-citys

Look for get-station-code-of-citys among VS Code's agent-mode tools after starting 12306 through the MCP controls.

get-station-code-by-names

Look for get-station-code-by-names among VS Code's agent-mode tools after starting 12306 through the MCP controls.

get-station-by-telecode

Look for get-station-by-telecode among VS Code's agent-mode tools after starting 12306 through the MCP controls.

Retrieve station details such as name, pinyin, and city from a telecode.

get-tickets

Look for get-tickets among VS Code's agent-mode tools after starting 12306 through the MCP controls.

Query remaining ticket availability through 12306.

get-interline-tickets

Look for get-interline-tickets among VS Code's agent-mode tools after starting 12306 through the MCP controls.

get-train-route-stations

Look for get-train-route-stations among VS Code's agent-mode tools after starting 12306 through the MCP controls.

12306: full stored tool descriptions

Troubleshooting 12306 in VS Code

  • Make npx 12306-mcp (Node.js/npm) available in the workspace, container, or remote environment hosting 12306 MCP. Start through VS Code's MCP controls; inspect output and trust prompts.
  • 12306 MCP uses stdio here: VS 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 VS Code troubleshooting lives in the /clients/vscode guide.

12306 MCP — details. VS Code guide

Frequently asked questions

For 12306 MCP, edit workspace .vscode/mcp.json. VS Code requires servers rather than mcpServers; preserve the displayed type on each entry.

VS Code's 12306-mcp example uses stdio.

12306 MCP's VS 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 VS 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.

A current-date tool returns the date in Asia/Shanghai time to help resolve phrases such as tomorrow.