ns mcp server

Local 2025-08-31 23:28:47 0

An MCP server that provides access to NS (Dutch Railways) travel information.


NS Logo NS Travel Information Server MCP server

smithery badge npm version

Transform your AI assistant into a Dutch railways expert! This MCP server connects Claude to real-time NS (Nederlandse Spoorwegen) travel information, making it your perfect companion for navigating the Netherlands by train.

Installation

You can install this server in three ways:

1. Using Claude Desktop with NPM Package

Update your Claude configuration file (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "ns-server": {
      "command": "npx",
      "args": [
        "-y",
        "ns-mcp-server"
      ],
      "env": {
        "NS_API_KEY": "your_api_key_here"
      }
    }
  }
}

You can get an API key from NS API Portal

2. Using Smithery

To install NS Travel Information Server automatically via Smithery:

npx -y @smithery/cli install ns-server --client claude

3. From Source

  1. Clone this repository
  2. Install dependencies:
    npm install
  3. Copy the example environment file:
    cp .env.example .env
  4. Add your NS API key to the .env file:
    NS_API_KEY=your_api_key_here

Then update your Claude configuration file:

{
  "mcpServers": {
    "ns-server": {
      "command": "node",
      "args": [
        "/path/to/ns-server/build/index.js"
      ],
      "env": {
        "NS_API_KEY": "your_api_key_here"
      }
    }
  }
}

Make sure to: 1. Replace /path/to/ns-server with the actual path to your installation 2. Add your NS API key in the env section

After updating the configuration, restart Claude Desktop for the changes to take effect.

Real-World Use Cases

  • "Is my usual 8:15 train from Almere to Amsterdam running on time?"
  • "Are there any delays on the Rotterdam-Den Haag route today?"
  • "What's the best alternative route to Utrecht if there's maintenance on the direct line?"
  • "Which train should I take to arrive at my office in Amsterdam Zuid before 9 AM?"
  • "Which route to Amsterdam has the fewest transfers with a stroller?"
  • "What's the earliest train I can take to make my 10 AM meeting in The Hague?"
  • "When's the last train back to Groningen after a night out in Amsterdam?"
  • "Are there any weekend engineering works that might affect my Monday morning class?"
  • "Are there OV-fiets bikes available at Utrecht Centraal for my afternoon meeting?"
  • "Is Eindhoven Strijp-S station wheelchair accessible and what platforms does it have?"
  • "What trains are arriving at Utrecht Centraal in the next hour?"
  • "Has the train from Venlo to Schiphol Airport arrived on time?"
  • "How much does a first-class ticket from Amsterdam to Rotterdam cost?"
  • "What's the price for 2 adults and 1 child traveling to Den Haag?"

? Environment Variables

Variable Description
NS_API_KEY Your NS API key (required)

? Features

This MCP server provides comprehensive access to NS train information through the following endpoints:

Real-time Train Information

  • Departures: Get real-time departure information including platform numbers, delays, and travel notes
  • Arrivals: Access upcoming train arrivals with origin stations, platform changes, and status updates
  • Journey Planning: Find optimal travel routes with transfers and real-time updates
  • Service Updates: Check for disruptions, maintenance work, and engineering activities

Pricing Information

  • Ticket Prices: Get accurate pricing for single and return journeys
  • Travel Classes: Compare prices for first and second class travel
  • Group Pricing: Calculate fares for adults and children
  • Discount Options: Check joint journey discounts and special offers
  • Validity Details: View ticket validity periods and travel conditions

Station Information

  • Station Details: Access comprehensive station information including:
  • Facilities and accessibility features
  • Platform layouts and track information
  • OV-fiets (bike rental) availability
  • Location and approach details

Additional Features

  • Multi-language Support: Information available in Dutch and English
  • Flexible Queries: Search by station name, code, or UIC identifier
  • Time Zones: Proper handling of time zones for international stations
  • Status Updates: Track changes, delays, and cancellations in real-time

License

This project is licensed under the MIT License - see the LICENSE file for details

[
  {
    "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": {
      "properties": {
        "isActive": {
          "description": "Filter to only return active disruptions",
          "type": "boolean"
        },
        "type": {
          "description": "Type of disruptions to return (e.g., MAINTENANCE, DISRUPTION)",
          "enum": [
            "MAINTENANCE",
            "DISRUPTION"
          ],
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "get_disruptions"
  },
  {
    "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": {
      "properties": {
        "dateTime": {
          "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",
          "type": "string"
        },
        "fromStation": {
          "description": "Name or code of departure station",
          "type": "string"
        },
        "searchForArrival": {
          "description": "If true, dateTime is treated as desired arrival time",
          "type": "boolean"
        },
        "toStation": {
          "description": "Name or code of destination station",
          "type": "string"
        }
      },
      "required": [
        "fromStation",
        "toStation"
      ],
      "type": "object"
    },
    "name": "get_travel_advice"
  },
  {
    "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": {
      "oneOf": [
        {
          "required": [
            "station"
          ]
        },
        {
          "required": [
            "uicCode"
          ]
        }
      ],
      "properties": {
        "dateTime": {
          "description": "Format - date-time (as date-time in RFC3339). Only supported for departures at foreign stations. Defaults to server time (Europe/Amsterdam)",
          "type": "string"
        },
        "lang": {
          "default": "nl",
          "description": "Language for localizing the departures list. Only a small subset of text is translated, mainly notes. Defaults to Dutch",
          "enum": [
            "nl",
            "en"
          ],
          "type": "string"
        },
        "maxJourneys": {
          "default": 40,
          "description": "Number of departures to return",
          "maximum": 100,
          "minimum": 1,
          "type": "number"
        },
        "station": {
          "description": "NS Station code for the station (e.g., ASD for Amsterdam Centraal). Required if uicCode is not provided",
          "type": "string"
        },
        "uicCode": {
          "description": "UIC code for the station. Required if station code is not provided",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "get_departures"
  },
  {
    "description": "Get OV-fiets availability at a train station",
    "inputSchema": {
      "properties": {
        "stationCode": {
          "description": "Station code to check OV-fiets availability for (e.g., ASD for Amsterdam Centraal)",
          "type": "string"
        }
      },
      "required": [
        "stationCode"
      ],
      "type": "object"
    },
    "name": "get_ovfiets"
  },
  {
    "description": "Get detailed information about a train station",
    "inputSchema": {
      "properties": {
        "includeNonPlannableStations": {
          "default": false,
          "description": "Include stations where trains do not stop regularly",
          "type": "boolean"
        },
        "limit": {
          "default": 10,
          "description": "Maximum number of results to return",
          "maximum": 50,
          "minimum": 1,
          "type": "number"
        },
        "query": {
          "description": "Station name or code to search for",
          "type": "string"
        }
      },
      "required": [
        "query"
      ],
      "type": "object"
    },
    "name": "get_station_info"
  },
  {
    "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": {
      "properties": {},
      "type": "object"
    },
    "name": "get_current_time_in_rfc3339"
  },
  {
    "description": "Get real-time arrival information for trains at a specific station, including platform numbers, delays, origin stations, and any relevant travel notes. Returns a list of upcoming arrivals with timing, origin, and status information.",
    "inputSchema": {
      "oneOf": [
        {
          "required": [
            "station"
          ]
        },
        {
          "required": [
            "uicCode"
          ]
        }
      ],
      "properties": {
        "dateTime": {
          "description": "Format - date-time (as date-time in RFC3339). Only supported for arrivals at foreign stations. Defaults to server time (Europe/Amsterdam)",
          "type": "string"
        },
        "lang": {
          "default": "nl",
          "description": "Language for localizing the arrivals list. Only a small subset of text is translated, mainly notes. Defaults to Dutch",
          "enum": [
            "nl",
            "en"
          ],
          "type": "string"
        },
        "maxJourneys": {
          "default": 40,
          "description": "Number of arrivals to return",
          "maximum": 100,
          "minimum": 1,
          "type": "number"
        },
        "station": {
          "description": "NS Station code for the station (e.g., ASD for Amsterdam Centraal). Required if uicCode is not provided",
          "type": "string"
        },
        "uicCode": {
          "description": "UIC code for the station. Required if station code is not provided",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "get_arrivals"
  },
  {
    "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": {
      "properties": {
        "adults": {
          "default": 1,
          "description": "Number of adults to return the price for",
          "minimum": 1,
          "type": "integer"
        },
        "children": {
          "default": 0,
          "description": "Number of children to return the price for",
          "minimum": 0,
          "type": "integer"
        },
        "fromStation": {
          "description": "UicCode or station code of the origin station",
          "type": "string"
        },
        "isJointJourney": {
          "default": false,
          "description": "Set to true to return the price including joint journey discount",
          "type": "boolean"
        },
        "plannedArrivalTime": {
          "description": "Format - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.",
          "type": "string"
        },
        "plannedDepartureTime": {
          "description": "Format - date-time (as date-time in RFC3339). Used to find the correct route if multiple routes are possible.",
          "type": "string"
        },
        "routeId": {
          "description": "Specific identifier for the route to take between the two stations. This routeId is returned in the /api/v3/trips call.",
          "type": "string"
        },
        "toStation": {
          "description": "UicCode or station code of the destination station",
          "type": "string"
        },
        "travelClass": {
          "description": "Travel class to return the price for",
          "enum": [
            "FIRST_CLASS",
            "SECOND_CLASS"
          ],
          "type": "string"
        },
        "travelType": {
          "default": "single",
          "description": "Return the price for a single or return trip",
          "enum": [
            "single",
            "return"
          ],
          "type": "string"
        }
      },
      "required": [
        "fromStation",
        "toStation"
      ],
      "type": "object"
    },
    "name": "get_prices"
  }
]