Skip to main content
Glama
KallivdH

NS Travel Information Server

by KallivdH

get_departures

Retrieve real-time train departure information from Dutch railway stations, including platform numbers, delays, and route details for upcoming journeys.

Instructions

Get real-time departure information for trains from a specific station, including platform numbers, delays, route details, and any relevant travel notes. Returns a list of upcoming departures with timing, destination, and status information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stationNoNS Station code for the station (e.g., ASD for Amsterdam Centraal). Required if uicCode is not provided
uicCodeNoUIC code for the station. Required if station code is not provided
dateTimeNoFormat - date-time (as date-time in RFC3339). Only supported for departures at foreign stations. Defaults to server time (Europe/Amsterdam)
maxJourneysNoNumber of departures to return
langNoLanguage for localizing the departures list. Only a small subset of text is translated, mainly notes. Defaults to Dutchnl

Implementation Reference

  • Core handler function that executes the get_departures tool logic by calling the NS API departures endpoint with provided arguments.
    async getDepartures(args: GetDeparturesArgs): Promise<DeparturesResponse> {
      this.ensureApiKeyConfigured();
      const response = await this.axiosInstance.get<DeparturesResponse>(
        NSApiService.ENDPOINTS.DEPARTURES,
        {
          params: {
            station: args.station,
            dateTime: args.dateTime,
            maxJourneys: args.maxJourneys,
            lang: args.lang
          },
        }
      );
      return response.data;
    }
  • Type definition and validation function for GetDeparturesArgs input schema.
    export interface GetDeparturesArgs {
      station: string;
      dateTime?: string;
      maxJourneys?: number;
      lang?: string;
    }
    
    export function isValidDeparturesArgs(args: unknown): args is GetDeparturesArgs {
      if (!args || typeof args !== "object") {
        return false;
      }
    
      const typedArgs = args as Record<string, unknown>;
    
      // Required station field
      if (typeof typedArgs.station !== "string") {
        return false;
      }
    
      // Optional fields
      if (typedArgs.dateTime !== undefined && typeof typedArgs.dateTime !== "string") {
        return false;
      }
    
      if (typedArgs.maxJourneys !== undefined && typeof typedArgs.maxJourneys !== "number") {
        return false;
      }
    
      if (typedArgs.lang !== undefined && typeof typedArgs.lang !== "string") {
        return false;
      }
    
      return true;
    }
  • src/index.ts:97-133 (registration)
    Tool registration in MCP stdio server including name, description, and input schema.
    {
      name: 'get_departures',
      description: 'Get real-time departure information for trains from a specific station, including platform numbers, delays, route details, and any relevant travel notes. Returns a list of upcoming departures with timing, destination, and status information.',
      inputSchema: {
        type: 'object',
        properties: {
          station: {
            type: 'string',
            description: 'NS Station code for the station (e.g., ASD for Amsterdam Centraal). Required if uicCode is not provided',
          },
          uicCode: {
            type: 'string',
            description: 'UIC code for the station. Required if station code is not provided',
          },
          dateTime: {
            type: 'string',
            description: 'Format - date-time (as date-time in RFC3339). Only supported for departures at foreign stations. Defaults to server time (Europe/Amsterdam)',
          },
          maxJourneys: {
            type: 'number',
            description: 'Number of departures to return',
            minimum: 1,
            maximum: 100,
            default: 40
          },
          lang: {
            type: 'string',
            description: 'Language for localizing the departures list. Only a small subset of text is translated, mainly notes. Defaults to Dutch',
            enum: ['nl', 'en'],
            default: 'nl'
          }
        },
        oneOf: [
          { required: ['station'] },
          { required: ['uicCode'] }
        ]
      }
  • src/index.ts:309-318 (registration)
    Dispatch handler in MCP stdio server that validates args and calls the core getDepartures function.
    case 'get_departures': {
      if (!isValidDeparturesArgs(rawArgs)) {
        throw ResponseFormatter.createMcpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for get_departures'
        );
      }
      const data = await this.nsApiService.getDepartures(rawArgs);
      return ResponseFormatter.formatSuccess(data);
    }
  • Dispatch handler in MCP HTTP server that validates args and calls the core getDepartures function.
    case 'get_departures': {
      if (!isValidDeparturesArgs(rawArgs)) {
        throw ResponseFormatter.createMcpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for get_departures'
        );
      }
      const data = await this.nsApiService.getDepartures(rawArgs);
      return ResponseFormatter.formatSuccess(data);
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool returns real-time information with a list of upcoming departures, including timing, destination, and status, which covers basic behavior. However, it lacks details on rate limits, authentication needs, error handling, or data freshness, which are important for a real-time API tool.

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 front-loaded with the core purpose in the first sentence, followed by additional details in a second sentence. Every sentence adds value without redundancy, and it is appropriately sized for a tool with 5 parameters and no annotations.

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

Completeness4/5

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

Given the complexity (real-time data fetching with 5 parameters) and lack of annotations or output schema, the description provides a good overview of what the tool does and returns. However, it could be more complete by mentioning potential limitations (e.g., data availability for foreign stations) or response structure details, which would help compensate for the missing output schema.

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 all parameters thoroughly. The description does not add any parameter-specific semantics beyond what the schema provides (e.g., it doesn't explain station code formats or date-time usage further). Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Get real-time departure information') and resource ('trains from a specific station'), distinguishing it from siblings like get_arrivals (arrivals vs. departures) and get_station_info (station metadata vs. departure data). It specifies the scope includes platform numbers, delays, route details, and travel notes.

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 implies usage context by specifying 'real-time departure information for trains from a specific station,' which distinguishes it from tools like get_disruptions (general disruptions) or get_travel_advice (route planning). However, it does not explicitly state when not to use it or name alternatives, such as clarifying that get_arrivals is for incoming trains.

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/KallivdH/ns-mcp-server'

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