get-station-by-telecode
Retrieve detailed station information using the 3-letter telecode, including name, pinyin, and city data for Chinese railway queries and debugging purposes.
Instructions
通过车站的 station_telecode 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 telecode 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stationTelecode | Yes | 车站的 `station_telecode` (3位字母编码) |
Implementation Reference
- src/index.ts:670-681 (handler)The handler function executes the tool logic: checks if the station exists in the preloaded STATIONS map by telecode and returns the full station details as JSON or an error.async ({ stationTelecode }) => { if (!STATIONS[stationTelecode]) { return { content: [{ type: 'text', text: 'Error: Station not found. ' }], }; } return { content: [ { type: 'text', text: JSON.stringify(STATIONS[stationTelecode]) }, ], }; }
- src/index.ts:665-669 (schema)Zod schema defining the input parameter 'stationTelecode' as a string with description.{ stationTelecode: z .string() .describe('车站的 `station_telecode` (3位字母编码)'), },
- src/index.ts:662-682 (registration)Registration of the tool using server.tool(), including name, description, schema, and inline handler function.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]) }, ], }; } );
- src/index.ts:40-40 (helper)Preloaded global STATIONS map (keyed by station_code/telecode) populated by getStations() function, directly used in the handler.const STATIONS: Record<string, StationData> = await getStations(); //以Code为键
- src/types.ts:136-147 (schema)TypeScript type definition for StationData, which structures the output data returned by the tool.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; };