Skip to main content
Glama
KallivdH

NS Travel Information Server

by KallivdH

get_ovfiets

Check real-time availability of OV-fiets rental bikes at Dutch train stations to plan your onward journey from the station.

Instructions

Get OV-fiets availability at a train station

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stationCodeYesStation code to check OV-fiets availability for (e.g., ASD for Amsterdam Centraal)

Implementation Reference

  • The core handler function that executes the tool logic by querying the NS Places API (/places-api/v2/ovfiets) for OV-fiets bike availability at the given station code.
    async getOVFiets(args: GetOVFietsArgs): Promise<OVFietsResponse> {
      this.ensureApiKeyConfigured();
      const response = await this.axiosInstance.get<OVFietsResponse>(
        NSApiService.ENDPOINTS.OVFIETS,
        {
          params: {
            station_code: args.stationCode
          }
        }
      );
      return response.data;
    }
  • TypeScript interface defining the input arguments (stationCode: string) and type guard function for validating get_ovfiets tool inputs.
    export interface GetOVFietsArgs {
      stationCode: string;
    }
    
    export function isValidOVFietsArgs(args: unknown): args is GetOVFietsArgs {
      if (!args || typeof args !== "object") {
        return false;
      }
    
      const typedArgs = args as Record<string, unknown>;
      return typeof typedArgs.stationCode === "string";
    }
  • src/index.ts:136-147 (registration)
    Tool registration in the stdio server (src/index.ts), including name, description, and input schema advertised to MCP clients.
    name: 'get_ovfiets',
    description: 'Get OV-fiets availability at a train station',
    inputSchema: {
      type: 'object',
      properties: {
        stationCode: {
          type: 'string',
          description: 'Station code to check OV-fiets availability for (e.g., ASD for Amsterdam Centraal)',
        }
      },
      required: ['stationCode']
    }
  • Tool registration in the HTTP server (src/http-server.ts), including name, description, and input schema advertised to MCP clients.
      name: 'get_ovfiets',
      description: 'Get OV-fiets availability at a train station',
      inputSchema: {
        type: 'object',
        properties: {
          stationCode: {
            type: 'string',
            description: 'Station code to check OV-fiets availability for (e.g., ASD for Amsterdam Centraal)',
          }
        },
        required: ['stationCode']
      }
    },
  • Dispatch handler in HTTP server that validates args and calls the NSApiService.getOVFiets method.
    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);
    }

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