Get the FREE Ultimate OpenClaw Setup Guide →

renfe_mcp_server

MCP server for Spanish Renfe train schedules and live prices with custom DWR scraper

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio belgrano9-renfe_mcp_server uv --directory /path/to/renfe_mcp run python -m renfe_mcp.server

How to use

Renfe MCP Server exposes a set of MCP tools to query and interact with Renfe data via MCP clients (e.g., Claude Desktop). The server uses the official Renfe GTFS data for train schedules, allows searching trains between two cities on a given date, retrieving real-time-like price information by scraping the Renfe site, and locating stations within a city. Key tools include: search_trains to paginate through available trains, find_station to list stations in a city, and get_train_prices to fetch price options with pagination. The server automatically updates its GTFS data on startup, so you can rely on up-to-date schedules without manual GTFS downloads. Claude Desktop can be configured to launch the MCP server through uv, enabling you to ask questions like “Show me trains from Madrid to Barcelona tomorrow” or “What are the ticket prices for the first 5 trains?”.

How to install

Prerequisites:

  • Python 3.12 or higher
  • uv (recommended) or pip
  • Git

Install and run:

  1. Clone the repository: git clone https://github.com/yourusername/renfe_mcp.git cd renfe_mcp

  2. Create and activate a virtual environment (optional but recommended): python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows

  3. Install dependencies:

    • If a requirements file exists, install with: pip install -r requirements.txt
    • Or install via pyproject/build backend as appropriate for the project configuration.
  4. Run the MCP server (GTFS data downloads automatically): uv run python -m renfe_mcp.server

  5. Optional: test the server by invoking the available MCP tools locally within Python: python -m renfe_mcp.server --help

Note: The repository is configured to use uv for an efficient, async MCP server workflow. Ensure the Python environment has network access for data updates and price scraping.

Additional notes

Tips and reminders:

  • The server auto-downloads the latest GTFS data on startup; you can force an update with the provided update_data module if needed.
  • Price scraping is performed against Renfe's site and may incur slight delays; pagination mirrors the train search to align results.
  • When configuring Claude Desktop, point the MCP client to the uv invocation with the correct directory to your renfe_mcp repository.
  • If you run into data version conflicts, use the update_data tooling to synchronize local GTFS files with the latest official data.
  • The server exposes functions for search_trains, find_station, and get_train_prices; you can chain these calls in MCP clients to build complex queries and workflows.

Related MCP Servers

Sponsor this space

Reach thousands of developers