Skip to main content
Glama

get-station-by-telecode

Retrieve detailed station information using a 3-letter telecode, including name, pinyin, and city data for 12306 ticket searches.

Instructions

通过车站的 station_telecode 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 telecode 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stationTelecodeYes车站的 `station_telecode` (3位字母编码)

Implementation Reference

  • The handler function that implements the core logic of the 'get-station-by-telecode' tool. It retrieves station details from the STATIONS object using the provided telecode and returns it as JSON text content or an error if not found.
    async ({ stationTelecode }) => {
        if (!STATIONS[stationTelecode]) {
            return {
                content: [{ type: 'text', text: 'Error: Station not found. ' }],
            };
        }
        return {
            content: [
                {
                    type: 'text',
                    text: JSON.stringify(STATIONS[stationTelecode]),
                },
            ],
        };
    }
  • Input schema definition using Zod for the stationTelecode parameter.
        stationTelecode: z
            .string()
            .describe('车站的 `station_telecode` (3位字母编码)'),
    },
  • src/index.ts:914-937 (registration)
    The server.tool registration call that defines and registers the 'get-station-by-telecode' tool with its name, description, input schema, and handler.
    server.tool(
        'get-station-by-telecode',
        '通过车站的 `station_telecode` 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 `telecode` 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。',
        {
            stationTelecode: z
                .string()
                .describe('车站的 `station_telecode` (3位字母编码)'),
        },
        async ({ stationTelecode }) => {
            if (!STATIONS[stationTelecode]) {
                return {
                    content: [{ type: 'text', text: 'Error: Station not found. ' }],
                };
            }
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify(STATIONS[stationTelecode]),
                    },
                ],
            };
        }
    );
  • TypeScript interface defining the StationData structure, which matches the output format returned by the tool from STATIONS[telecode]. Includes array of keys for parsing.
    export type StationData = {
        station_id: string;
        station_name: string;
        station_code: string;
        station_pinyin: string;
        station_short: string;
        station_index: string;
        code: string;
        city: string;
        r1: string;
        r2: string;
    };
    
    export const StationDataKeys: (keyof StationData)[] = [
        'station_id',
        'station_name',
        'station_code',
        'station_pinyin',
        'station_short',
        'station_index',
        'code',
        'city',
        'r1',
        'r2',
    ];
  • Helper function that asynchronously loads the global STATIONS dictionary from the 12306 website by fetching and parsing station data JavaScript file, adding missing stations, which is used by the tool handler.
    async function getStations(): Promise<Record<string, StationData>> {
        const html = await make12306Request<string>(WEB_URL);
        if (html == null) {
            throw new Error('Error: get 12306 web page failed.');
        }
        const match = html.match('.(/script/core/common/station_name.+?.js)');
        if (match == null) {
            throw new Error('Error: get station name js file failed.');
        }
        const stationNameJSFilePath = match[0];
        const stationNameJS = await make12306Request<string>(
            new URL(stationNameJSFilePath, WEB_URL)
        );
        if (stationNameJS == null) {
            throw new Error('Error: get station name js file failed.');
        }
        const rawData = eval(stationNameJS.replace('var station_names =', ''));
        const stationsData = parseStationsData(rawData);
        // 加上缺失的车站信息
        for (const station of MISSING_STATIONS) {
            if (!stationsData[station.station_code]) {
                stationsData[station.station_code] = station;
            }
        }
        return stationsData;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It describes the query behavior and typical use cases, but doesn't disclose important behavioral traits like error handling, response format, authentication requirements, rate limits, or whether it's read-only. The description adds some context about usage patterns but leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with two sentences that each earn their place. The first sentence states the core functionality, the second provides crucial usage context. No wasted words, well-structured, and front-loaded with the primary purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple lookup tool with 100% schema coverage but no annotations and no output schema, the description provides adequate purpose and usage context. However, it doesn't describe the return format or what 'complete station data' includes, which would be helpful given the lack of output schema. The description is complete enough for basic understanding but has gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter completely. The description mentions 'station_telecode' but adds no additional semantic information beyond what's in the schema. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: querying station details by station_telecode, listing specific data fields (name, pinyin, city). It distinguishes from siblings by focusing on telecode lookup rather than name-based or city-based searches. However, it doesn't explicitly name alternative tools for different scenarios.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool ('known telecode', 'special queries/debugging') and when not to use it ('generally less triggered in user conversations'). It doesn't explicitly name alternative tools for different scenarios, but the context is sufficiently clear for an agent to understand appropriate usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Joooook/12306-mcp'

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