Skip to main content
Glama
KallivdH

NS Travel Information Server

by KallivdH

get_current_time_in_rfc3339

Retrieve current server time in RFC3339 format for Amsterdam timezone to use as input for NS railway travel planning tools requiring date-time parameters.

Instructions

Get the current server time (Europe/Amsterdam timezone) in RFC3339 format. This can be used as input for other tools that require date-time parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler implementation for the get_current_time_in_rfc3339 tool. Creates a new Date object, converts it to ISO string (RFC3339), and returns it wrapped with timezone info using ResponseFormatter.
    case 'get_current_time_in_rfc3339': {
      const now = new Date();
      return ResponseFormatter.formatSuccess({
        datetime: now.toISOString(),
        timezone: 'Europe/Amsterdam'
      });
    }
  • Schema definition for the tool, including name, description, and empty input schema (no parameters required). Part of the tools list returned by ListToolsRequestHandler.
    {
      name: 'get_current_time_in_rfc3339',
      description: 'Get the current server time (Europe/Amsterdam timezone) in RFC3339 format. This can be used as input for other tools that require date-time parameters.',
      inputSchema: {
        type: 'object',
        properties: {}
      }
    },
  • Identical handler implementation in the stdio server version of the MCP server.
    case 'get_current_time_in_rfc3339': {
      const now = new Date();
      return ResponseFormatter.formatSuccess({
        datetime: now.toISOString(),
        timezone: 'Europe/Amsterdam'
      });
    }
  • Identical schema definition in the stdio server version of the MCP server.
      name: 'get_current_time_in_rfc3339',
      description: 'Get the current server time (Europe/Amsterdam timezone) in RFC3339 format. This can be used as input for other tools that require date-time parameters.',
      inputSchema: {
        type: 'object',
        properties: {}
      }
    },
  • Registration of the CallToolRequestHandler which dispatches to the specific tool handler based on name.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const rawArgs = request.params.arguments || {};
    
      try {
        switch (request.params.name) {
          case 'get_disruptions': {
            if (!isValidDisruptionsArgs(rawArgs)) {
              throw ResponseFormatter.createMcpError(
                ErrorCode.InvalidParams,
                'Invalid arguments for get_disruptions'
              );
            }
            const data = await this.nsApiService.getDisruptions(rawArgs);
            return ResponseFormatter.formatSuccess(data);
          }
    
          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);
          }
    
          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);
          }
    
          case 'get_ovfiets': {
            if (!isValidOVFietsArgs(rawArgs)) {
              throw ResponseFormatter.createMcpError(
                ErrorCode.InvalidParams,
                'Invalid arguments for get_ovfiets'
              );
            }
            const data = await this.nsApiService.getOVFiets(rawArgs);
            return ResponseFormatter.formatSuccess(data);
          }
    
          case 'get_station_info': {
            if (!isValidStationInfoArgs(rawArgs)) {
              throw ResponseFormatter.createMcpError(
                ErrorCode.InvalidParams,
                'Invalid arguments for get_station_info'
              );
            }
            const data = await this.nsApiService.getStationInfo(rawArgs);
            return ResponseFormatter.formatSuccess(data);
          }
    
          case 'get_current_time_in_rfc3339': {
            const now = new Date();
            return ResponseFormatter.formatSuccess({
              datetime: now.toISOString(),
              timezone: 'Europe/Amsterdam'
            });
          }
    
          case 'get_arrivals': {
            if (!isValidArrivalsArgs(rawArgs)) {
              throw ResponseFormatter.createMcpError(
                ErrorCode.InvalidParams,
                'Invalid arguments for get_arrivals'
              );
            }
            const data = await this.nsApiService.getArrivals(rawArgs);
            return ResponseFormatter.formatSuccess(data);
          }
    
          case 'get_prices': {
            if (!isValidPricesArgs(rawArgs)) {
              throw ResponseFormatter.createMcpError(
                ErrorCode.InvalidParams,
                'Invalid arguments for get_prices'
              );
            }
            const data = await this.nsApiService.getPrices(rawArgs);
            return ResponseFormatter.formatSuccess(data);
          }
    
          default:
            throw ResponseFormatter.createMcpError(
              ErrorCode.MethodNotFound,
              `Unknown tool: ${request.params.name}`
            );
        }
      } catch (error) {
        return ResponseFormatter.formatError(error);
      }
    });

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