mcp sncf
A modular Python wrapper for the SNCF API that integrates with Claude Desktop, enabling intelligent journey planning and train information retrieval across France's railway network.
A modular Python wrapper for the SNCF API that integrates with Claude Desktop, enabling intelligent journey planning and train information retrieval across France's railway network.
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.
The SNCF MCP Server provides a comprehensive interface to the French National Railway's (SNCF) API services, allowing you to:
The structure is organized as follows:
sncf_api/
- The main package for SNCF API interaction__init__.py
- Package initializationconfig.py
- Configuration settingsclient.py
- Base API clientapi.py
- Main API interface combining all modulessearch.py
- Search-related endpointsjourney.py
- Journey planning endpointsstations.py
- Station-related endpointsnetworks.py
- Network and transport mode endpointsdisruptions.py
- Disruption-related endpointsstation_finder.py
- Efficient station lookup by coordinatescsv_station_finder.py
- Station lookup using CSV databasevehicle_journey.py
- Detailed train journey informationsncf_server.py
- MCP server implementation with all tool endpointstrain_stations_europe.csv
- Database of European train stations with coordinatesgit clone https://github.com/yourusername/sncf-mcp-new.git
cd sncf-mcp-new
pip install -r requirements.txt
If the requirements.txt file is missing, install the following packages: requests mcp
pip install requests pandas mcp
Before using this server, you need to obtain an API key from SNCF:
The API key looks like a UUID string (e.g., 01293485-3NS3-3242-23AZ-3241324512
).
To integrate the SNCF MCP tools with Claude Desktop:
%APPDATA%Claudeclaude_desktop_config.json
){
"sncf": {
"command": "py",
"args": [
"c:UsersChristianELHAJJsncf-mcp-newsncf_server.py",
"--api-key={YOUR-API-KEY}"
],
"cwd": "c:UsersChristianELHAJJsncf-mcp-new"
},
Replace path/to/sncf-mcp-new
with the actual path to your installation directory.
Once configured, the following tools will be available to Claude Desktop:
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.
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.
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?
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
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
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
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
The system includes hardcoded coordinates for major French cities to ensure reliability even when the API search fails:
The get_station_details
tool can analyze and categorize the types of transport available at a station:
The station details tool can find points of interest near a station:
This feature is particularly useful for travelers planning their onward journey from a station.
Contributions to improve the SNCF MCP Server are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
This project is licensed under the MIT License - see the LICENSE file for details.
created by Christian delage ([email protected])