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: 12306 Train Ticket Search 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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

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
    378
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables searching Turkish high-speed train (YHT) tickets via TCDD API. Supports real-time availability, station name resolution, date formatting, and passenger count.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables real-time flight and train ticket queries, dynamic trip tracking, and knowledge-based Q&A about rail and aviation policies.
    -

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