home / mcp / sncf mcp server

SNCF MCP Server

This project provides a modular Python wrapper for the SNCF API, with an MCP server interface that integrates seamlessly with Claude Desktop for intelligent journey planning and train information retrieval across France.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kryzo-mcp-sncf": {
      "command": "py",
      "args": [
        "c:\\Users\\ChristianELHAJJ\\sncf-mcp-new\\sncf_server.py",
        "--api-key={YOUR-API-KEY}"
      ],
      "env": {
        "YOUR_API_KEY": "{YOUR-API-KEY}"
      }
    }
  }
}

You run an MCP server that exposes SNCF Navitia API capabilities to your clients, letting you plan journeys, fetch station data, view schedules, monitor disruptions, and discover nearby places with a single, cohesive interface. This server is designed for easy integration with MCP clients and Claude Desktop, providing reliable French rail information through a clean, extensible Python package.

How to use

You interact with the SNCF MCP Server through an MCP client. Start the local MCP server using the provided Python entry point and API key. The server exposes tools for journey planning, station details, schedules, and disruptions. In your client, configure the SNCF MCP connection as a local stdio server so you can send requests and receive structured responses.

How to install

Prerequisites: Python 3.6 or newer and a working internet connection.

Step 1: Install Python dependencies (from the project directory). You may already have a requirements file; if not, install the core packages manually.

Step 2: Run the MCP server locally using the example command that starts the Python server script with your API key.

Configuration and usage notes

To connect Claude Desktop to the SNCF MCP Server, start the server process and provide your API key when prompted. The server will listen for MCP requests from Claude Desktop and return structured results for journeys, station information, schedules, and disruptions.

Security and keys

Keep your SNCF API key secure. Do not expose it in public configurations. Use a placeholder in examples and replace it with your actual key only in trusted environments.

Troubleshooting

Common issues include missing API keys, network connectivity problems, and failures to locate stations. Verify the API key, ensure internet access, and confirm that the SNCF Navitia API is reachable from your environment. If a station search fails, try using hardcoded coordinates for major cities that the server includes for reliability.

If you see errors related to CSV station data, ensure the train_stations_europe.csv file is present and readable in the expected location.

Advanced features

Hardcoded coordinates provide reliable fallbacks for major French cities. The server can analyze transport types at stations (long-distance trains, regional trains, local transit) and locate nearby places of interest to help with onward travel.

Usage examples

Plan a journey from Paris to Toulouse for tomorrow afternoon and fetch station details for the departure city.

Notes

This MCP server is designed to integrate with Claude Desktop and other MCP clients, offering a robust set of endpoints for SNCF data without requiring you to interact with low-level API calls.

Code snippet: starting the MCP server locally

py sncf_server.py --api-key={YOUR-API-KEY}

Available tools

plan_journey_by_city_names

Plan a journey between two French cities, automatically selecting stations and returning departure/arrival times and connections.

get_station_details

Retrieve comprehensive details about stations, including transport types, nearby places, coordinates, and accessibility.

get_station_schedule

Fetch upcoming departures and arrivals for a specified station with options for counts, datetime, and data freshness.

check_disruptions

Check current disruptions affecting specific routes, lines, or stations and provide details on impacts.