12306

v1.0.0Search & Data Extractionstable

获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 'yyyy-MM-dd'。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。

12306mcpmcp-servertrain-tickets
Share:
890
Stars
0
Downloads
0
Weekly
0/5

What is 12306?

12306 is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 获取当前日期,以上海时区(asia/shanghai, utc+8)为准,返回格式为 'yyyy-mm-dd'。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。

获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 'yyyy-MM-dd'。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。

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

Features

  • get-current-date
  • get-stations-code-in-city
  • get-station-code-of-citys
  • get-station-code-by-names
  • get-station-by-telecode

Use Cases

Query Chinese train schedules and availability
Get current date in Shanghai timezone
Joooook

Maintainer

LicenseMIT License
Languagejavascript
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y 12306-mcp

Manual Installation

npx -y 12306-mcp

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

12306-mcp is a Node.js MCP server that wraps China's official 12306 railway ticketing system, giving AI assistants the ability to search train schedules, check seat availability, look up station codes by city, query routes with transfers, and filter results by train type or seat class. It handles date interpretation in the Asia/Shanghai timezone (UTC+8) so that natural language like 'tomorrow' or 'next Wednesday' resolves correctly to the right date. Chinese travelers and developers use it to let Claude or other AI models answer questions about high-speed rail and regular train tickets without manually navigating the 12306 website.

Prerequisites

  • Node.js 18+ and npm installed (for npx usage)
  • An MCP-compatible client such as Claude Desktop or Cursor
  • Internet access to reach the 12306 API (no account or API key required)
1

Test the server with npx (no install required)

Run the server directly with npx to verify it starts correctly. The server communicates over stdio by default.

npx -y 12306-mcp
2

Add the server to your MCP client configuration

Edit your Claude Desktop (or other MCP client) configuration file to add 12306-mcp as a server. No environment variables are required.

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

Restart your MCP client

Restart Claude Desktop or your chosen client to load the new server configuration.

4

Query train schedules in natural language

Ask the AI to search for trains between two cities. The server will resolve city names to station codes and query availability from 12306.

5

(Optional) Run in HTTP mode for network access

Start the server on a specific port to expose it over HTTP, useful for accessing from multiple clients or a remote machine.

npx -y 12306-mcp --port 8080

12306 Examples

Client configuration (Claude Desktop)

Minimal Claude Desktop configuration for 12306-mcp with no API keys required:

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

Prompts to try

Ask about Chinese train schedules using natural language:

- "Search for high-speed trains from Beijing to Shanghai tomorrow morning"
- "What trains are available from Guangzhou to Shenzhen this Saturday afternoon?"
- "Find transfer options from Chengdu to Hangzhou with the shortest total travel time"
- "What is the station code for trains departing from Wuhan?"
- "Show me all G-class (high-speed) trains between Nanjing and Suzhou next Monday"

Troubleshooting 12306

Server returns no results for a city search

Ensure you are using the Chinese city name (e.g., '北京' or 'Beijing'). The server maps city names to internal 12306 station codes — ambiguous or misspelled city names may return empty results.

Date queries resolve to the wrong day

The server uses Asia/Shanghai timezone (UTC+8) for all date resolution. If your Claude Desktop is in a different timezone, relative dates like 'tomorrow' will still be calculated in Shanghai time. Specify an explicit date (YYYY-MM-DD) to avoid ambiguity.

Network timeout or connection refused errors

The server queries the 12306 API directly. If you are outside mainland China, access to 12306 may be restricted. Try using a VPN with a Chinese exit node, or run the server on a Chinese cloud server.

Frequently Asked Questions about 12306

What is 12306?

12306 is a Model Context Protocol (MCP) server that 获取当前日期,以上海时区(asia/shanghai, utc+8)为准,返回格式为 'yyyy-mm-dd'。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。 It connects AI assistants to external tools and data sources through a standardized interface.

How do I install 12306?

Install via npm with the command: npx -y 12306-mcp. 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?

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

Is 12306 free to use?

Yes, 12306 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": { "command": "npx", "args": ["-y", "12306-mcp"] } } }

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

Read the full setup guide →

Ready to use 12306?

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