Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchTrainStations

Find train stations by entering a keyword, such as '北京西', to quickly locate relevant station information for planning trips or transfers.

Instructions

Search for train stations by keyword.

Input Schema

NameRequiredDescriptionDefault
queryYesKeyword to search for train stations (e.g. 北京西)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "query": { "description": "Keyword to search for train stations (e.g. 北京西)", "type": "string" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • The MCP tool handler function for 'searchTrainStations' that invokes the service method and handles response/error formatting.
    }, async ({ query }) => { try { const trainStations = await flightService.searchTrainStations(query); return { content: [ { type: "text", text: JSON.stringify(trainStations, null, 2) } ] }; } catch (error) { console.error('Error searching train stations:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; }
  • Zod input schema defining the 'query' parameter as a string for the searchTrainStations tool.
    query: z.string().describe("Keyword to search for train stations (e.g. 北京西)"),
  • dist/index.js:271-292 (registration)
    Registration of the 'searchTrainStations' MCP tool with server.tool, including name, description, schema, and handler.
    server.tool("searchTrainStations", "Search for train stations by keyword.", { query: z.string().describe("Keyword to search for train stations (e.g. 北京西)"), }, async ({ query }) => { try { const trainStations = await flightService.searchTrainStations(query); return { content: [ { type: "text", text: JSON.stringify(trainStations, null, 2) } ] }; } catch (error) { console.error('Error searching train stations:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
  • Helper method in OpenAlService class that performs the actual API request for searching train stations.
    async searchTrainStations(query) { return this.makeRequest('searchTrainStations', { query }); }
  • Core helper method in OpenAlService for making POST requests to the backend API endpoints, used by searchTrainStations.
    async makeRequest(endpoint, params) { const url = new URL(config.api.baseUrl); const request_body = { endpoint: endpoint, params: params }; const response = await fetch(url.toString(), { method: 'post', headers: { 'X-VARIFLIGHT-KEY': config.api.apiKey || '', 'Content-Type': 'application/json', }, body: JSON.stringify(request_body), }); if (!response.ok) { throw new Error(`API request failed: ${response.status} ${response.statusText}`); } return response.json(); }

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/variflight/tripmatch-mcp'

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