Building a Train Ticket Query MCP Server with Qwen3: A Practical Guide

This article walks through creating a TypeScript‑based train‑ticket MCP Server that leverages the Qwen‑3 14B model and Model Context Protocol, detailing setup, configuration, the provided query and time tools, example interactions, and links to the open‑source repositories.

Ubiquitous Tech
Ubiquitous Tech
Ubiquitous Tech
Building a Train Ticket Query MCP Server with Qwen3: A Practical Guide

Overview

Implemented a TypeScript Studio‑mode Model Context Protocol (MCP) server that enables natural‑language train‑ticket queries using the Qwen‑3 14B model. The server follows the MCP standard to let the LLM call external tools.

Background

MCP, proposed by Anthropic, defines a standard interface for LLMs to invoke tools and data sources. The design was inspired by the open‑source Baidu Maps MCP Server (https://github.com/baidu-maps/mcp).

Prerequisites

Node.js runtime.

Cherry Studio (or any MCP‑compatible client).

Access to Qwen‑3 14B model supporting think and no_think modes.

Installation & Configuration

Clone the repository (https://github.com/wuchubuzai2018/tongchenglvxing-mcp-server) and install dependencies. Add the following MCP client configuration (JSON):

{ "mcpServers": { "tongchenglvxing-mcp-server": { "command": "npx", "args": ["-y", "@wuchubuzai/tongchenglvxing-mcp-server"] } } }

Provided Tools

query_train_tickets_list – Retrieves train‑ticket information from Tongcheng Travel (https://www.ly.com/mergeTrain/huochepiao). Parameters: depStationName (string): departure station or city. arrStationName (string): arrival station or city. depDate (string, format yyyy‑MM‑dd): travel date.

get_current_time – Returns the current system time.

Running the Server

In Cherry Studio set the MCP command path to the absolute location of npx. For other clients place the JSON snippet above into the MCP configuration file.

Example Interaction

Prompt:

使用火车票查询功能,查询系2025年5月3日从哈尔滨到漠河的火车票信息

The model generates a reasoning chain, calls query_train_tickets_list with the supplied parameters, receives a JSON payload containing departure/arrival stations, train numbers, dates, times, seat types, prices, and availability, and then summarizes the result.

Result Format

{ "用户查询出发站": "xxxxxx", "用户查询到达站": "xxxxx", "车次列表": [ { "是否当日到达": "是", "出发火车站是否是经停站": "是经停站", "出发火车站是否是始发站": "是始发站", "车次号": "xxxxx", "出发车站名称": "xxxxx", "出发日期": "xxxx", "出发时间": "xxxx", "到达车站名称": "xxxx", "到达日期": "xxxx", "到达时间": "xxxx", "历时小时分钟": "xxxxx", "座位类型": [ { "类型": "xxxxx", "价格": "xxxx", "余票": "xxxx" } ] } ] }

Technical Notes

The Qwen‑3 14B model supports both think (complex reasoning) and no_think (efficient dialogue) modes, allowing seamless switching during a session. The server runs in Studio mode, meaning it is invoked via local command execution.

References

Anthropic, Model Context Protocol (MCP).

Baidu Maps MCP Server source: https://github.com/baidu-maps/mcp

Train‑ticket MCP Server repository: https://github.com/wuchubuzai2018/tongchenglvxing-mcp-server

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TypeScriptModel Context ProtocolQwen3MCP ServerAI Tool CallingTrain Ticket Query
Ubiquitous Tech
Written by

Ubiquitous Tech

A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.