renfe_mcp_server
Verified Safeby SaberMaple1
Overview
Provides real-time information on Spanish Renfe train schedules and live prices using a DWR scraper.
Installation
python -m renfe_mcp.serverEnvironment Variables
- RENFE_ENABLE_AUTH
- RENFE_API_KEY
- RENFE_API_KEY_HASH
- RENFE_RATE_LIMIT_ENABLED
- RENFE_MAX_REQUESTS_PER_MINUTE
- RENFE_MAX_REQUESTS_PER_HOUR
- RENFE_MAX_PRICE_REQUESTS_PER_MINUTE
- RENFE_MAX_PRICE_REQUESTS_PER_HOUR
- RENFE_LOG_SECURITY_EVENTS
- RENFE_LOG_SENSITIVE_DATA
- RENFE_LOG_LEVEL
- RENFE_SESSION_TIMEOUT
- RENFE_DEV_MODE
- RENFE_GTFS_DATA_DIR
Security Notes
The project demonstrates a very strong emphasis on security, particularly for web scraping and API server vulnerabilities. Key strengths include: - **SSRF Prevention**: Extensive URL validation (domain whitelisting, HTTPS enforcement, local IP blocking, limited redirects) is implemented in `scraper.py` and `update_data.py` to prevent Server-Side Request Forgery. - **Zip Slip Prevention**: The `safe_extract_zip` function in `update_data.py` is robust, preventing path traversal, absolute path usage, filtering disallowed file extensions, and enforcing size limits (for individual files and total extraction) to mitigate zip bombs. - **Authentication**: Supports API key authentication with secure hashing (`SHA-256`) and constant-time comparison (`secrets.compare_digest`) to prevent timing attacks. - **Rate Limiting**: A token-bucket rate limiter is implemented per client, with separate, stricter limits for resource-intensive price scraping requests. - **Security Logging**: A dedicated security logger is in place, capable of redacting sensitive data (e.g., API keys, passwords) and hashing identifiers (e.g., origin/destination names) before logging, enhancing privacy and incident response capabilities. - **Configuration Validation**: Uses Pydantic for typed and validated configuration, and clearly flags 'dev_mode' as insecure for production. No 'eval' or other easily exploitable code patterns were identified that lack clear justification. The security posture is exceptionally strong for an open-source project.
Similar Servers
scrapegraph-mcp
Provides a Model Context Protocol (MCP) server that integrates with ScrapeGraph AI, enabling language models to perform advanced AI-powered web scraping and structured data extraction across single pages, multiple pages, and search results.
openrouter-deep-research-mcp
A multi-agent AI research server implementing the Model Context Protocol for deep, iterative, and multimodal investigations, with features like dynamic planning, parallel execution, ensemble synthesis, and knowledge base management.
scrapi-mcp
Serves as a Model Context Protocol (MCP) server that utilizes the ScrAPI service to scrape web pages and return their content in either HTML or Markdown format.
mcp-mercado-livre
This server scrapes product data, including prices and availability, from Mercado Livre for integration with Model Context Protocol (MCP) tools.