Skip to main content
Glama
CallwaterSword

train-mcp-server

Train Ticket Query MCP Server (FastMCP)

A train/high-speed rail query service implemented with FastMCP, which can be called as a remote MCP tool by any Agent (such as deepagents, LangGraph, Claude, etc.).

Capabilities

One tool function: query_train_tickets(from_station, to_station, date)

  • Query the train numbers, schedules, durations, booking availability, and remaining tickets between two stations on a given day

  • Data source: 12306 public query interface (real data); automatically switches to simulated data when the interface is blocked, with the source clearly marked, ensuring the pipeline can be demonstrated at any time

Related MCP server: THSRC MCP Server

Local Run

pip install -r requirements.txt
python server.py        # 启动 streamable-http 服务,默认 http://127.0.0.1:8000

MCP client configuration (local debugging):

{
  "mcpServers": {
    "train": {
      "url": "http://127.0.0.1:8000/mcp/",
      "transport": "streamable_http"
    }
  }
}

Deploy to ModelScope MCP Plaza (Key Steps)

  1. Push this repository to GitHub

  2. Open modelscope.cn/mcp → Log in → Click "Create MCP"

  3. Select "GitHub Quick Create" as the creation type; select "Hosted Deployment" as the hosting type

  4. Fill in the English/Chinese name, source URL (GitHub repository URL), and complete the configuration as prompted by the platform

  5. After submission, the platform generates an access URL: https://mcp.api-inference.modelscope.net/<your ID>/sse or /mcp (can be set to be valid indefinitely)

  6. Fill this URL back into the MCP configuration of the Agent project

Tip: The platform has startup method requirements for hosted projects (usually requires Python + starting an HTTP service). If deployment fails, adjust the entry point as prompted by the platform (e.g., provide a run script or environment variable).

Data Source Description

  • 12306 has no official open API. This project uses its public query interface (kyfw.12306.cn/otn/leftTicket) for querying without login, for personal learning and research only

  • The interface has anti-bot measures (occasional 302 redirects). The code includes session cookies + simulated data as a fallback

  • If more stable data is needed, you can replace _fetch_12306 with a third-party data source (pluggable)

Directory

  • server.py — FastMCP service main program

  • test_client.py — Local debugging script (directly calls tool functions + tests via MCP protocol)

  • requirements.txt — Dependencies

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    B
    maintenance
    A high-performance FastAPI backend for train ticket queries in China, supporting real-time ticket availability, station information, transfers, and train schedules through the Model Context Protocol for AI assistants and automation.
    7
    359
    MIT
  • A
    license
    -
    quality
    D
    maintenance
    Enables real-time Taiwan High Speed Rail (THSRC) information queries including timetables, station details, train status, and seat availability. Supports multiple languages and integrates with TDX API for up-to-date rail service data.
    49
    2
    MIT
  • F
    license
    -
    quality
    B
    maintenance
    Enables real-time Indian Railways information retrieval, including live train running status, station schedules, and upcoming arrivals/departures.

View all related MCP servers

Related MCP Connectors

  • TravelMind: 8 MCP tools for travel (12306 trains, flights, hotels, geocode, planning, policy).

  • Provide access to Chinese stock market data including historical prices, real-time data, news, and…

  • China & Asia travel eSIM specialist. 200+ countries. No-VPN internet in China.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CallwaterSword/train-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server