Skip to main content
Glama
KallivdH

NS Travel Information Server

by KallivdH

get_travel_advice

Plan train journeys between Dutch stations with real-time routes, transfers, platform details, and crowding information. Optimize trips for departure or arrival times.

Instructions

Get detailed travel routes between two train stations, including transfers, real-time updates, platform information, and journey duration. Can plan trips for immediate departure or for a specific future time, with options to optimize for arrival time. Returns multiple route options with status and crowding information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromStationYesName or code of departure station
toStationYesName or code of destination station
dateTimeNoFormat - date-time (as date-time in RFC3339). Datetime that the user want to depart from his origin or or arrive at his destination
searchForArrivalNoIf true, dateTime is treated as desired arrival time

Implementation Reference

  • Core handler function that executes the tool logic by querying the NS API trips endpoint with user-provided station and datetime parameters.
    async getTravelAdvice(args: GetTravelAdviceArgs): Promise<TravelAdvice[]> {
      this.ensureApiKeyConfigured();
      const response = await this.axiosInstance.get<TravelAdvice[]>(
        NSApiService.ENDPOINTS.TRIPS,
        {
          params: {
            fromStation: args.fromStation,
            toStation: args.toStation,
            dateTime: args.dateTime,
            searchForArrival: args.searchForArrival,
          },
        }
      );
      return response.data;
    }
  • Type definitions and validation function for the input arguments of get_travel_advice.
    export interface GetTravelAdviceArgs {
      fromStation: string;     // Departure station
      toStation: string;       // Destination station
      dateTime?: string;       // Optional departure/arrival time
      searchForArrival?: boolean;  // If true, dateTime is treated as arrival time
    }
    
    /**
     * Type guard for travel advice arguments
     */
    export function isValidTravelAdviceArgs(args: unknown): args is GetTravelAdviceArgs {
      if (!args || typeof args !== "object") {
        return false;
      }
    
      const typedArgs = args as Record<string, unknown>;
    
      // Required fields
      if (typeof typedArgs.fromStation !== "string" || typeof typedArgs.toStation !== "string") {
        return false;
      }
    
      // Optional fields
      if (typedArgs.dateTime !== undefined && typeof typedArgs.dateTime !== "string") {
        return false;
      }
    
      if (typedArgs.searchForArrival !== undefined && typeof typedArgs.searchForArrival !== "boolean") {
        return false;
      }
    
      return true;
    }
  • src/index.ts:72-96 (registration)
    Tool metadata registration (name, description, inputSchema) in the MCP server's listTools response.
      name: 'get_travel_advice',
      description: 'Get detailed travel routes between two train stations, including transfers, real-time updates, platform information, and journey duration. Can plan trips for immediate departure or for a specific future time, with options to optimize for arrival time. Returns multiple route options with status and crowding information.',
      inputSchema: {
        type: 'object',
        properties: {
          fromStation: {
            type: 'string',
            description: 'Name or code of departure station',
          },
          toStation: {
            type: 'string',
            description: 'Name or code of destination station',
          },
          dateTime: {
            type: 'string',
            description: 'Format - date-time (as date-time in RFC3339). Datetime that the user want to depart from his origin or or arrive at his destination',
          },
          searchForArrival: {
            type: 'boolean',
            description: 'If true, dateTime is treated as desired arrival time',
          },
        },
        required: ['fromStation', 'toStation'],
      },
    },
  • src/index.ts:298-307 (registration)
    Tool dispatch in MCP callTool handler: argument validation and invocation of the NSApiService handler.
    case 'get_travel_advice': {
      if (!isValidTravelAdviceArgs(rawArgs)) {
        throw ResponseFormatter.createMcpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for get_travel_advice'
        );
      }
      const data = await this.nsApiService.getTravelAdvice(rawArgs);
      return ResponseFormatter.formatSuccess(data);
    }
  • Identical tool metadata registration in the HTTP MCP server.
            };
    
            // Connect the transport to the server
            await this.server.connect(transport);
          } else {
            res.status(400).json({ error: 'Invalid or missing session ID' });
            return;
          }
    
          // Handle the request through the transport
          await transport.handleRequest(req, res, req.body);
        } catch (error) {
          console.error('MCP endpoint error:', error);
          if (!res.headersSent) {
            res.status(500).json({ error: 'Internal server error' });
          }
        }
      });
    
      // MCP GET endpoint - establishes SSE stream for existing sessions
      this.app.get('/mcp', async (req: Request, res: Response) => {
        const sessionId = req.headers['mcp-session-id'] as string | undefined;
    
        if (!sessionId || !this.transports.has(sessionId)) {
          res.status(400).send('Invalid or missing session ID');
          return;
        }
    
        try {
          const transport = this.transports.get(sessionId)!;
          await transport.handleRequest(req, res);
        } catch (error) {
          console.error('SSE connection error:', error);
          if (!res.headersSent) {
            res.status(500).send('Error establishing SSE connection');
          }
        }
      });
    
      // MCP DELETE endpoint - terminates sessions
      this.app.delete('/mcp', async (req: Request, res: Response) => {
        const sessionId = req.headers['mcp-session-id'] as string | undefined;
    
        if (!sessionId || !this.transports.has(sessionId)) {
          res.status(400).send('Invalid or missing session ID');
          return;
        }
    
        try {
          const transport = this.transports.get(sessionId)!;
          await transport.handleRequest(req, res);
        } catch (error) {
          console.error('Session termination error:', error);
          if (!res.headersSent) {
            res.status(500).send('Error processing session termination');
          }
        }
      });
    }
    
    private setupErrorHandling(): void {
      this.server.onerror = (error) => {
        console.error('[MCP Error]', error);
      };
    
      process.on('SIGINT', async () => {
        console.log('Shutting down server...');
        await this.server.close();
        process.exit(0);
      });
    
      process.on('SIGTERM', async () => {
        console.log('Shutting down server...');
        await this.server.close();
        process.exit(0);
      });
    }
    
    private setupHandlers(): void {
      this.setupToolHandlers();
    }
    
    private setupToolHandlers(): void {
      this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [
          {
            name: 'get_disruptions',
            description: 'Get comprehensive information about current and planned disruptions on the Dutch railway network. Returns details about maintenance work, unexpected disruptions, alternative transport options, impact on travel times, and relevant advice. Can filter for active disruptions and specific disruption types.',
            inputSchema: {
              type: 'object',
              properties: {
                isActive: {
                  type: 'boolean',
                  description: 'Filter to only return active disruptions',
                },
                type: {
                  type: 'string',
                  description: 'Type of disruptions to return (e.g., MAINTENANCE, DISRUPTION)',
                  enum: ['MAINTENANCE', 'DISRUPTION']
                },
              },
            },
          },
          {
            name: 'get_travel_advice',
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: returns multiple route options, includes status and crowding information, supports real-time updates, and handles both departure and arrival time optimization. However, it doesn't mention rate limits, authentication requirements, error conditions, or pagination behavior for the returned routes.

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 efficiently structured in two sentences: the first establishes core functionality, the second adds important contextual details about timing and output. Every phrase adds value with zero redundant information, making it appropriately sized and front-loaded.

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?

For a 4-parameter tool with no annotations and no output schema, the description does well by explaining what the tool returns (multiple route options with status/crowding info) and key behavioral aspects. However, it doesn't fully compensate for the lack of output schema by detailing the structure of returned data or error handling, leaving some gaps in completeness.

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 4 parameters thoroughly. The description adds marginal value by mentioning 'immediate departure or specific future time' and 'optimize for arrival time,' which helps contextualize the dateTime and searchForArrival parameters, but doesn't provide syntax or format details beyond what the schema provides.

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 verb ('Get detailed travel routes') and resource ('between two train stations'), specifying the scope includes transfers, real-time updates, platform info, and journey duration. It distinguishes from siblings like get_arrivals/get_departures (which focus on single stations) and get_disruptions (which doesn't provide routes).

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 for when to use this tool ('plan trips for immediate departure or for a specific future time') and mentions optimization options. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools, though the differentiation is implied through the detailed functionality described.

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