12306
This is a 12306 ticket search server based on the Model Context Protocol (MCP).
claude mcp add --transport stdio joooook-12306-mcp npx -y 12306-mcp
How to use
12306-mcp is a Model Context Protocol (MCP) server that provides a simple API for searching 12306 train tickets. Built around the MCP ecosystem, it exposes functionality to query ticket availability, filter train data, and perform common travel planning queries (such as transfer searches and stopover filtering) through a unified MCP interface. Clients can interact with the server via the CLI (stdio) or HTTP endpoints, allowing large language models or other MCP clients to leverage live ticket information in a structured way. The project emphasizes lightweight, fast search capabilities tailored to the 12306 ecosystem, enabling developers to plug in ticket data retrieval into their workflows with minimal setup.
Usage options include the CLI experience, which can run directly in your shell, and the HTTP mode, which exposes an API suitable for integration with other services. The repository documents how to start the server in stdio mode (CLI) or in HTTP mode, and provides an MCP configuration snippet to register the server under an MCP runtime. Typical capabilities involve querying availability, filtering trains by time or station, and performing overstation or transfer-based queries to help models choose viable itineraries.
How to install
Prerequisites:
- Node.js and npm (or a Node.js-compatible runtime)
- Internet access to fetch the MCP package
Install and run locally:
# 1) Install dependencies and run the MCP server using npx (as documented in the repo)
# This will fetch the 12306-mcp package and start the server in stdio mode by default
npx -y 12306-mcp
To run via HTTP (if the package supports a port flag):
npx -y 12306-mcp --port 8080
If you prefer to pin a version or clone the repo directly:
# 1) Clone the repository
git clone https://github.com/Joooook/12306-mcp.git
cd 12306-mcp
# 2) Install dependencies
npm install
# 3) Start the server (stdio mode by default)
npm start
Configuration via MCP runtime (example shown in the docs):
{
"mcpServers": {
"12306-mcp": {
"command": "npx",
"args": ["-y", "12306-mcp"]
}
}
}
Additional notes
Notes and tips:
- The server focuses on 12306 ticket search capabilities; ensure you have network access to fetch live data if the backend relies on external APIs.
- If you encounter port conflicts, run in HTTP mode on an available port (e.g., --port 8080) and update your MCP runtime configuration accordingly.
- In MCP configurations, the server is registered as a named entry (e.g., 12306-mcp). You can add additional environment variables or flags if the underlying package supports them (check the repository docs for environment variable names).
- Common issues often relate to network access or API rate limits; consider adding retry logic or backoff strategies in your client when integrating with a model.
- For Docker usage, follow the Docker commands in the README to build and run in container environments.
Related MCP Servers
any-chat-completions
MCP Server for using any LLM as a Tool
bitbucket
Bitbucket MCP - A Model Context Protocol (MCP) server for integrating with Bitbucket Cloud and Server APIs
time
⏰ Time MCP Server: Giving LLMs Time Awareness Capabilities
unity-editor
An MCP server and client for LLMs to interact with Unity Projects
website-publisher
AI Website builder and publisher MCP. Quickly publish and deploy your AI generated code as real website URL. Support html, css, js, python etc.
xgmem
Global Memory MCP server, that manage all projects data.