Skip to main content
Glama
KallivdH

NS Travel Information Server

by KallivdH

get_prices

Retrieve domestic train journey pricing with options for travel classes, ticket types, discounts, and passenger counts. Provides detailed fare information including conditions and validity.

Instructions

Get price information for domestic train journeys, including different travel classes, ticket types, and discounts. Returns detailed pricing information with conditions and validity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromStationYesUicCode or station code of the origin station
toStationYesUicCode or station code of the destination station
travelClassNoTravel class to return the price for
travelTypeNoReturn the price for a single or return tripsingle
isJointJourneyNoSet to true to return the price including joint journey discount
adultsNoNumber of adults to return the price for
childrenNoNumber of children to return the price for
routeIdNoSpecific identifier for the route to take between the two stations. This routeId is returned in the /api/v3/trips call.
plannedDepartureTimeNoFormat - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.
plannedArrivalTimeNoFormat - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.

Implementation Reference

  • Core handler function that executes the get_prices tool logic by calling the NS API prices endpoint with axios and returning the response data.
    async getPrices(args: GetPricesArgs): Promise<PricesResponse> {
      this.ensureApiKeyConfigured();
      const response = await this.axiosInstance.get<PricesResponse>(
        NSApiService.ENDPOINTS.PRICES,
        {
          params: {
            fromStation: args.fromStation,
            toStation: args.toStation,
            travelClass: args.travelClass,
            travelType: args.travelType,
            isJointJourney: args.isJointJourney,
            adults: args.adults,
            children: args.children,
            routeId: args.routeId,
            plannedDepartureTime: args.plannedDepartureTime,
            plannedArrivalTime: args.plannedArrivalTime
          },
        }
      );
      return response.data;
    }
  • Type definitions for GetPricesArgs input interface, PricesResponse output, and isValidPricesArgs type guard for input validation.
    export interface PricesResponse {
      payload: {
        prices: Price[];
      };
    }
    
    export interface GetPricesArgs {
      fromStation?: string;
      toStation?: string;
      travelClass?: 'FIRST_CLASS' | 'SECOND_CLASS';
      travelType?: 'single' | 'return';
      isJointJourney?: boolean;
      adults?: number;
      children?: number;
      routeId?: string;
      plannedDepartureTime?: string;
      plannedArrivalTime?: string;
    }
    
    export function isValidPricesArgs(args: unknown): args is GetPricesArgs {
      if (!args || typeof args !== "object") {
        return false;
      }
    
      const typedArgs = args as Record<string, unknown>;
    
      // Check station fields: should be undefined or string
      if (typedArgs.fromStation !== undefined && typeof typedArgs.fromStation !== "string") {
        return false;
      }
      if (typedArgs.toStation !== undefined && typeof typedArgs.toStation !== "string") {
        return false;
      }
    
      // Check travelClass: should be undefined or one of the allowed values
      if (typedArgs.travelClass !== undefined && 
          !["FIRST_CLASS", "SECOND_CLASS"].includes(typedArgs.travelClass as string)) {
        return false;
      }
    
      // Check travelType: should be undefined or one of the allowed values
      if (typedArgs.travelType !== undefined && 
          !["single", "return"].includes(typedArgs.travelType as string)) {
        return false;
      }
    
      // Check isJointJourney: should be undefined or boolean
      if (typedArgs.isJointJourney !== undefined && typeof typedArgs.isJointJourney !== "boolean") {
        return false;
      }
    
      // Check adults: should be undefined or integer
      if (typedArgs.adults !== undefined && 
          (typeof typedArgs.adults !== "number" || !Number.isInteger(typedArgs.adults))) {
        return false;
      }
    
      // Check children: should be undefined or integer
      if (typedArgs.children !== undefined && 
          (typeof typedArgs.children !== "number" || !Number.isInteger(typedArgs.children))) {
        return false;
      }
    
      // Check routeId: should be undefined or string
      if (typedArgs.routeId !== undefined && typeof typedArgs.routeId !== "string") {
        return false;
      }
    
      // Check time fields: should be undefined or string
      if (typedArgs.plannedDepartureTime !== undefined && typeof typedArgs.plannedDepartureTime !== "string") {
        return false;
      }
      if (typedArgs.plannedArrivalTime !== undefined && typeof typedArgs.plannedArrivalTime !== "string") {
        return false;
      }
    
      return true;
    }
  • src/index.ts:222-277 (registration)
    Tool registration in listTools handler for the stdio MCP server, defining name, description, and inputSchema for get_prices.
    name: 'get_prices',
    description: 'Get price information for domestic train journeys, including different travel classes, ticket types, and discounts. Returns detailed pricing information with conditions and validity.',
    inputSchema: {
      type: 'object',
      properties: {
        fromStation: {
          type: 'string',
          description: 'UicCode or station code of the origin station',
        },
        toStation: {
          type: 'string',
          description: 'UicCode or station code of the destination station',
        },
        travelClass: {
          type: 'string',
          description: 'Travel class to return the price for',
          enum: ['FIRST_CLASS', 'SECOND_CLASS']
        },
        travelType: {
          type: 'string',
          description: 'Return the price for a single or return trip',
          enum: ['single', 'return'],
          default: 'single'
        },
        isJointJourney: {
          type: 'boolean',
          description: 'Set to true to return the price including joint journey discount',
          default: false
        },
        adults: {
          type: 'integer',
          description: 'Number of adults to return the price for',
          minimum: 1,
          default: 1
        },
        children: {
          type: 'integer',
          description: 'Number of children to return the price for',
          minimum: 0,
          default: 0
        },
        routeId: {
          type: 'string',
          description: 'Specific identifier for the route to take between the two stations. This routeId is returned in the /api/v3/trips call.'
        },
        plannedDepartureTime: {
          type: 'string',
          description: 'Format - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.'
        },
        plannedArrivalTime: {
          type: 'string',
          description: 'Format - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.'
        }
      },
      required: ['fromStation', 'toStation']
    }
  • src/index.ts:361-370 (registration)
    CallTool handler case for get_prices in stdio MCP server: validates args and delegates to NSApiService.getPrices.
    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);
    }
  • Tool registration in listTools handler for the HTTP MCP server, defining name, description, and inputSchema for get_prices.
      name: 'get_prices',
      description: 'Get price information for domestic train journeys, including different travel classes, ticket types, and discounts. Returns detailed pricing information with conditions and validity.',
      inputSchema: {
        type: 'object',
        properties: {
          fromStation: {
            type: 'string',
            description: 'UicCode or station code of the origin station',
          },
          toStation: {
            type: 'string',
            description: 'UicCode or station code of the destination station',
          },
          travelClass: {
            type: 'string',
            description: 'Travel class to return the price for',
            enum: ['FIRST_CLASS', 'SECOND_CLASS']
          },
          travelType: {
            type: 'string',
            description: 'Return the price for a single or return trip',
            enum: ['single', 'return'],
            default: 'single'
          },
          isJointJourney: {
            type: 'boolean',
            description: 'Set to true to return the price including joint journey discount',
            default: false
          },
          adults: {
            type: 'integer',
            description: 'Number of adults to return the price for',
            minimum: 1,
            default: 1
          },
          children: {
            type: 'integer',
            description: 'Number of children to return the price for',
            minimum: 0,
            default: 0
          },
          routeId: {
            type: 'string',
            description: 'Specific identifier for the route to take between the two stations. This routeId is returned in the /api/v3/trips call.'
          },
          plannedDepartureTime: {
            type: 'string',
            description: 'Format - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.'
          },
          plannedArrivalTime: {
            type: 'string',
            description: 'Format - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.'
          }
        },
        required: ['fromStation', 'toStation']
      }
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'Returns detailed pricing information with conditions and validity,' which gives some indication of output behavior. However, it doesn't address important behavioral aspects like whether this is a read-only operation, potential rate limits, authentication requirements, error conditions, or what happens when parameters are invalid. For a 10-parameter tool with no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences that cover purpose and return value. There's no wasted language, and it's appropriately sized for the tool's complexity. While it could be slightly more detailed given the lack of annotations, what's present is well-organized and front-loaded with the core functionality.

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

Completeness2/5

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

For a 10-parameter tool with no annotations and no output schema, the description is incomplete. It doesn't explain the relationship between parameters (e.g., how routeId interacts with station parameters), doesn't mention error conditions or validation rules, and provides minimal guidance on the return format beyond 'detailed pricing information.' Given the complexity and lack of structured metadata, the description should do more to help an agent understand how to use this tool effectively.

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?

The description mentions 'different travel classes, ticket types, and discounts' which maps to some parameters (travelClass, travelType, isJointJourney). However, with 100% schema description coverage, the schema already documents all 10 parameters thoroughly. The description adds minimal value beyond what's already in the parameter descriptions, providing only high-level context without additional syntax or format details.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get price information for domestic train journeys' with specific details about what's included (travel classes, ticket types, discounts). It distinguishes from sibling tools like get_arrivals or get_departures by focusing on pricing rather than schedules or status. However, it doesn't explicitly differentiate from potential pricing-related siblings that might exist in other contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. While sibling tools like get_travel_advice might include pricing information, there's no explicit comparison or context about when this specific pricing tool is preferred. The description mentions what the tool returns but not when it should be selected over other available tools.

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