Server profile

12306 MCP

12306 MCP lets assistants search Chinese railway ticket availability and train routes. It includes station-code lookups, direct and transfer ticket queries, and Shanghai-time date resolution for conversational travel planning.

Server facts

12306 MCP

Project

Author
Joooook
License
MIT

Tech

Runtime / language
nodeTypeScript
Transports
stdio
Remote available
No
Authentication
Not specified

Activity

GitHub stars
2,391
Last commit
Data as of

Tags

  • 12306
  • Rail Travel
  • Station Lookup
  • Train Tickets
  • Typescript

Overview

12306 MCP exposes railway ticket-search functions to MCP-compatible language models. Its documented features include searching ticket information, filtering train results, checking stops, and finding transfer options. The supplied tool inventory adds station-name and station-code resolution so an assistant can turn a user's Chinese city or station name into the identifiers required by later searches. Separate lookups return all stations in a city, a representative city code, or detailed station information from a telecode. A date tool uses the Shanghai timezone to help interpret relative travel dates before a ticket query is submitted.

Direct ticket availability and interline availability are distinct operations. The transfer-query description notes that only the first ten results are currently supported. For a specified train and interval, another tool returns calling stations together with arrival, departure, and dwell information. This makes the project useful for comparing services and understanding an itinerary, but the provided interface is about searching rather than a documented booking or payment workflow. The README identifies the project as intended for learning and lists additional interfaces as future work. Users can launch the TypeScript server with npx over standard input/output, choose an HTTP port, or build a Docker image for either mode. The example MCP client configuration does not specify credentials or environment variables.

Install & configure

Requirements

  • Node.js and npx
  • An MCP-compatible client
Documented launch / install command
npx -y 12306-mcp

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.

Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Desktop configuration
{
  "mcpServers": {
    "12306-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "12306-mcp"
      ],
      "env": {}
    }
  }
}

Read the Claude Desktop setup guide

Config file · Project: .cursor/mcp.json

User: ~/.cursor/mcp.json

The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.

Cursor configuration
{
  "mcpServers": {
    "12306-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "12306-mcp"
      ],
      "env": {}
    }
  }
}

Read the Cursor setup guide

Config file · Workspace: .vscode/mcp.json

For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.

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

Read the VS Code setup guide

Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json

Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json

Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.

Windsurf configuration
{
  "mcpServers": {
    "12306-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "12306-mcp"
      ],
      "env": {}
    }
  }
}

Read the Windsurf setup guide

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

The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.

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

Read the Claude Code setup guide

Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.

Tools

Source: repository tool metadata. Tool descriptions are a documented snapshot, not a live capability check.

ToolWhat it does
get-current-dateReturn the current Shanghai-time date for resolving relative travel dates.
get-stations-code-in-cityList all train stations and their codes for a Chinese city name.
get-station-code-of-citysResolve Chinese city names to representative station codes.
get-station-code-by-namesResolve specific Chinese station names into station names and codes.
get-station-by-telecodeRetrieve station details such as name, pinyin, and city from a telecode.
get-ticketsQuery remaining ticket availability through 12306.
get-interline-ticketsQuery transfer-ticket availability, currently limited to the first ten results.
get-train-route-stationsInspect a train's stops, arrival and departure times, and dwell durations within an interval.

Names, permissions, and defaults can change. Check the current upstream documentation before granting access.

Use cases

  • Find direct train-ticket availability for a travel request.
  • Compare available transfer itineraries.
  • Resolve Chinese city and station names into station codes.
  • Inspect a train's intermediate stops and timetable details.

Strengths

  • Combines ticket searches with station-code resolution.
  • Supports direct and transfer queries.
  • Includes timezone-aware date resolution and detailed stop queries.

Limitations

  • The transfer query is limited to the first ten results.
  • Booking and payment operations are not documented.
  • The README frames the project as a learning tool.

Frequently asked questions

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

Yes. get-interline-tickets searches transfer availability, with a documented limit of the first ten results.

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

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

Independent listing, not an affiliation or security review. Grant the least access needed and verify the upstream instructions before running code.

Related MCP servers