SNCF Train Journey Planner MCP server

Connects to the French National Railway (SNCF) API for planning train journeys, retrieving station information, checking schedules, and monitoring service disruptions across France with intelligent station-finding and fallback mechanisms.
Back to servers
Setup instructions
Provider
Kryzo
Release date
Mar 20, 2025
Language
Python
Stats
2 stars

This Python wrapper for the SNCF API provides an MCP server interface that integrates with Claude Desktop, allowing users to access train information, plan journeys, and monitor disruptions across France's railway network.

Installation

Prerequisites

  • Python 3.6+
  • pip (Python package manager)

Step 1: Clone the Repository

git clone https://github.com/yourusername/sncf-mcp-new.git
cd sncf-mcp-new

Step 2: Install Dependencies

pip install -r requirements.txt

If the requirements.txt file is missing, install the following packages:

pip install requests pandas mcp

Getting an API Key

Before using this server, you need to obtain an API key from SNCF:

  1. Visit the SNCF API Portal
  2. Create an account or log in
  3. Subscribe to the "Navitia" API service
  4. Complete the registration process
  5. Once approved, you'll receive your API key in your account dashboard

The API key looks like a UUID string (e.g., 01293485-3NS3-3242-23AZ-3241324512).

Configuration

Setting Up Claude Desktop

To integrate the SNCF MCP tools with Claude Desktop:

  1. Install Claude Desktop if you haven't already
  2. Open Claude Desktop Configuration:
    • Navigate to the Claude Desktop settings
    • Open the configuration file (usually located at %APPDATA%\Claude\claude_desktop_config.json)
{
 "sncf": {
  "command": "py",
  "args": [
    "c:\\Users\\ChristianELHAJJ\\sncf-mcp-new\\sncf_server.py",
    "--api-key={YOUR-API-KEY}"
  ],
  "cwd": "c:\\Users\\ChristianELHAJJ\\sncf-mcp-new"
},

Replace path/to/sncf-mcp-new with the actual path to your installation directory.

  1. Save the Configuration File and restart Claude Desktop

Available MCP Tools

Once configured, the following tools will be available to Claude Desktop:

Journey Planning

plan_journey_by_city_names

Plan a journey between two cities in France.

Parameters:

  • from_city: Departure city name (e.g., "Paris")
  • to_city: Destination city name (e.g., "Marseille")
  • datetime: Optional departure or arrival time (format: YYYYMMDDTHHMMSS)
  • datetime_represents: "departure" or "arrival" (default: "departure")
  • include_station_details: Whether to include detailed station information

Example prompt for Claude:

Plan a train journey from Paris to Lyon tomorrow morning at 8 AM.

Station Information

get_station_details

Get comprehensive details about train stations in a city.

Parameters:

  • city_name: Name of the city to search for stations
  • station_name: Optional specific station name
  • station_id: Optional direct station ID
  • include_transport_types: Whether to include transport type analysis
  • include_nearby_places: Whether to include nearby places information
  • nearby_distance: Search radius in meters for nearby places
  • nearby_count: Maximum number of nearby places to return

Example prompt for Claude:

What transport options are available at the main train station in Grenoble?

get_station_schedule

Get departure and arrival schedules for a station.

Parameters:

  • city_name: Name of the city to search for stations
  • station_name: Optional specific station name
  • station_id: Optional direct station ID
  • count: Number of departures/arrivals to return
  • datetime: Optional datetime to start from
  • duration: Optional duration in seconds
  • data_freshness: Data freshness level (realtime or base_schedule)

Example prompt for Claude:

Show me the next 5 train departures from Paris Gare de Lyon.

Disruption Monitoring

check_disruptions

Check for current disruptions in the SNCF transport network.

Parameters:

  • coverage: The coverage area (default: "sncf")
  • count: Maximum number of disruptions to return
  • station_id: Optional filter for a specific station
  • line_id: Optional filter for a specific line
  • since: Only disruptions valid after this date
  • until: Only disruptions valid before this date
  • fetch_train_details: Whether to fetch additional details about affected trains

Example prompt for Claude:

Are there any current disruptions affecting trains to Marseille?

Usage Examples

Planning a Journey

You can ask Claude to plan a journey between any two cities in France:

I need to travel from Paris to Nice next Friday at 2 PM. Can you find me a train?

Claude will use the plan_journey_by_city_names tool to:

  1. Find the main stations in both cities
  2. Plan the optimal journey between them
  3. Present you with departure/arrival times, durations, and connection details

Getting Station Information

To get detailed information about a station:

What facilities and transport options are available at Gare de Lyon in Paris?

Claude will use the get_station_details tool to provide:

  1. Basic station information (name, ID, coordinates)
  2. Available transport types (trains, buses, trams)
  3. Nearby places and points of interest

Checking Train Schedules

To check upcoming departures or arrivals:

When are the next trains leaving from Bordeaux to Paris today?

Claude will use the get_station_schedule tool to show:

  1. Upcoming departures from Bordeaux
  2. Destination information
  3. Platform details when available
  4. Real-time status updates

Monitoring Disruptions

To check for service disruptions:

Are there any disruptions affecting the Paris to Lyon route today?

Claude will use the check_disruptions tool to:

  1. Find relevant disruptions
  2. Explain the impact on services
  3. Provide additional details about affected trains

Troubleshooting

Common Issues

"No API key provided"

  • Ensure you've added your SNCF API key to the Claude Desktop configuration
  • Check that the environment variable is correctly referenced in the MCP server configuration

"No stations found for city"

  • Try using a more specific city name
  • For smaller cities, try using the name of a nearby larger city
  • The system has hardcoded coordinates for major French cities which should work reliably

"Failed to connect to SNCF API"

  • Check your internet connection
  • Verify that your API key is valid and not expired
  • The SNCF API may be experiencing downtime; try again later

"Error initializing CSV station finder"

  • Ensure the train_stations_europe.csv file is in the correct location
  • Check file permissions to ensure the file is readable

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "sncf" '{"command":"py","args":["c:\\Users\\ChristianELHAJJ\\sncf-mcp-new\\sncf_server.py","--api-key={YOUR-API-KEY}"],"cwd":"c:\\Users\\ChristianELHAJJ\\sncf-mcp-new"}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later