Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.1.0
title: Surf Spot Finder โ AI-Powered MCP Agent
emoji: ๐โโ๏ธ
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 5.49.1
app_file: hf_space/app.py
pinned: false
license: mit
tags:
- mcp-in-action-track-customer
- building-mcp-track-consumer
short_description: AI surf agent with autonomous reasoning using MCP protocol
๐โโ๏ธ Surf Spot Finder - AI Agent (MCP in Action)
AI-powered surf spot recommendations with autonomous reasoning and real-time conditions
This project demonstrates MCP in Action with an intelligent agent that autonomously analyzes surf conditions, reasons about optimal spots, and provides natural language explanations of its decision-making process.
๐ฌ Demo Video
Watch the Demo Video to see how the MCP server works in action.
๐ค Agent Capabilities
- ๐ง Autonomous Reasoning: AI agent analyzes wave conditions and makes intelligent recommendations
- ๐ Real-time Conditions: Live wave data from Stormglass API
- ๐ Location Intelligence: Geocoding and distance-based filtering
- ๐ฏ Multi-factor Scoring: Sophisticated evaluation (waves, wind, swell, skill compatibility)
- ๐ฌ Natural Language: LLM-powered explanations and insights
- ๐ก๏ธ Safety-focused: Skill-level appropriate recommendations
๐ง MCP Resources Implementation
Surf spots are exposed as MCP resources following the Model Context Protocol.
Resource
- URI:
surf://spots/database - Content: 22 world-class surf spots with metadata
- Format: JSON
Server Implementation (mcp_server/mcp_server.py)
@server.list_resources()
async def list_resources():
return [Resource(uri="surf://spots/database", name="Surf Spots Database", ...)]
@server.read_resource()
async def read_resource(uri: str):
# Returns surf_spots.json content
Client Usage (tools/spot_finder_tool.py)
- Primary: MCP resource access via read_resource()
- Fallback: File I/O for async context compatibility
Testing MCP Resources
python tests/test_mcp_resources.py
# Expected output:
# โ
Found 1 resource(s)
# โ
Loaded 22 surf spots
# ๐ All tests passed!
๐๏ธ MCP Architecture
MCP Server (mcp_server/)
Tools Available:
find_surf_spots- Main orchestration tool with AI reasoningsurf_llm_agent- LLM-powered analysis and explanationsget_wave_data- Real-time conditions from Stormglassresolve_location- Geocoding and coordinate resolutioncalculate_distance- Distance calculations
HF Space Consumer (hf_space/)
- Gradio Interface: User-friendly web UI
- MCP Client: Communicates with MCP server
- Real-time Demo: Live surf recommendations
๐ Quick Start
Local Development
# Clone repository
git clone <repo-url>
cd surf-spot-finder-mcp
# Install dependencies
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Set API keys (optional - works with fallback)
export STORMGLASS_API_KEY=your_key
export OPENAI_API_KEY=your_key # For enhanced LLM reasoning
# Quick demo
python scripts/run_local_demo.py
๐ How It Works
- User Input: Location + preferences (skill level, board type)
- Location Resolution: Convert address to coordinates
- Spot Discovery: Find nearby surf spots from curated database
- Condition Analysis: Get real-time wave data via Stormglass
- AI Evaluation: Sophisticated scoring algorithm + LLM reasoning
- Intelligent Ranking: Sort by compatibility with user preferences
- Natural Language Output: AI-generated explanations and insights
๐ Evaluation Algorithm
Real-Time Data Sources (Automatic Priority):
- ๐ฅ Stormglass API โ ๐ฅ Open-Meteo (free fallback)
- ๐ฅ OpenAI โ ๐ฅ Anthropic โ ๐ฅ OpenRouter โ ๐ Rule-based
Multi-Factor Scoring System (0-100 scale):
Wave Conditions (35%):
- Optimal range matching (spot preferences vs. current height)
- Skill-level safety adjustments (beginners capped at 2m)
- Progressive scoring curve with diminishing returns
Wind Analysis (25%):
- Speed compatibility (offshore preferred, onshore penalized)
- Direction optimization (side-offshore = ideal)
- Thermal wind pattern recognition
Swell Direction (25%):
- Angular matching to spot's optimal swell window
- Bathymetry considerations for wave refraction
- Seasonal swell pattern analysis
Skill Compatibility (15%):
- Break type vs. experience level
- Hazard assessment (rocks, currents, crowds)
- Progression opportunity scoring
AI Reasoning Layer:
- Autonomous pattern recognition across multiple conditions
- Natural language explanations of decision-making process
- Local knowledge integration and safety recommendations
- Session timing optimization with weather forecasting
๐บ๏ธ Surf Spot Database
Demo Dataset (Current Implementation)
22 World-Class Spots carefully selected for demonstration:
๐ช๐ธ Spain (8 spots)
- Tarifa, El Palmar, La Barrosa, Sotogrande, Barbate, Cabo Trafalgar, Marbella, Mundaka
๐บ๐ธ California, USA (4 spots)
- Malibu - Surfrider Beach, Venice Beach, Manhattan Beach, Redondo Beach
๐ต๐น Portugal (4 spots)
- Ericeira - Ribeira d'Ilhas, Carcavelos, Guincho, Peniche - Supertubos
๐ International (6 spots)
- Hossegor (France), Pipeline (Hawaii), Bells Beach (Australia), Supertubes (South Africa)
Production Scaling Architecture
Current: JSON File (mcp_server/data/surf_spots.json)
- โ Perfect for demo and development
- โ Easy to understand and modify
- โ No external dependencies
Production Deployment Options:
- PostgreSQL/PostGIS: Geospatial queries and advanced filtering
- MongoDB: Flexible schema for evolving spot characteristics
- Redis Cache: Fast lookup with geographic indexing
- API Integration: Real-time spot data from surf databases
Scalability Path:
JSON (22 spots) โ Database (1000s spots) โ API Federation (global coverage)
The current JSON approach demonstrates the algorithm and architecture while keeping the demo accessible and maintainable for hackathon evaluation.
๐งช Testing
Run Tests
# Test MCP resources
python tests/test_mcp_resources.py
# Test complete workflow
python tests/test_workflow.py
# Run unit tests (if pytest installed)
cd mcp_server
pytest tests/
Test Dependencies
The project includes comprehensive tests for:
- MCP Resources: Resource listing and reading
- MCP Tools: Individual tool functionality
- LLM Integration: AI reasoning components
- API Integration: External service connections
๐ง Configuration
API Keys (All Optional - Intelligent Fallbacks Included):
Wave Data Sources:
STORMGLASS_API_KEY: Premium marine data โ Falls back to Open-Meteo (free)
AI Reasoning Providers (Priority Order):
OPENAI_API_KEY: GPT-4 analysis (1st choice)ANTHROPIC_API_KEY: Claude reasoning (2nd choice)OPENROUTER_API_KEY: Multi-model access (3rd choice)- No API key: Rule-based analysis (always works)
๐ฏ MCP Hackathon Submission
Track: MCP in Action - Customer
Category: Demonstrates autonomous AI agent behavior
Key Features for Judging:
- โ Agent Reasoning: LLM-powered autonomous decision making
- โ Real-world Impact: Practical surf recommendations with safety focus
- โ MCP Protocol: Proper resource and tool architecture
- โ User Experience: Intuitive Gradio interface
- โ Documentation: Comprehensive setup and usage docs
๐ Innovation Highlights
- Autonomous Agent Behavior: AI reasons about conditions and explains decisions
- Multi-modal Intelligence: Combines real-time data, spatial analysis, and LLM reasoning
- MCP Resources: Proper implementation of Model Context Protocol primitives
- Safety-first Approach: Skill-level appropriate recommendations prevent dangerous situations
- Flexible Architecture: Direct mode with intelligent fallbacks for reliability
๐ Project Structure
surf-spot-finder-mcp/
โโโ mcp_server/ # MCP Server Implementation
โ โโโ mcp_server.py # MCP resource handlers (list_resources, read_resource)
โ โโโ tools/ # MCP Tools
โ โ โโโ spot_finder_tool.py # Main orchestration (uses MCP resources)
โ โ โโโ llm_agent_tool.py # AI reasoning & analysis
โ โ โโโ surf_eval_tool.py # Multi-factor scoring algorithm
โ โ โโโ stormglass_tool.py # Wave data API integration
โ โ โโโ location_tool.py # Geocoding & coordinates
โ โ โโโ marine_data_tool.py # Fallback weather data
โ โโโ data/ # Surf spots database
โ โ โโโ surf_spots.json # 22 world-class surf spots (exposed via MCP)
โ โโโ utils/ # Utility functions
โ โโโ tests/ # Unit & integration tests
โ
โโโ hf_space/ # Gradio UI
โ โโโ app.py # Main interface with enhanced UX
โ โโโ mcp_client.py # Direct Mode client
โ โโโ requirements.txt # HF Space dependencies
โ
โโโ scripts/ # Utility scripts
โ โโโ run_local_demo.py # Quick demo launcher
โ โโโ print_tree.py # Repository structure visualization
โ
โโโ tests/ # Root-level integration tests
โ โโโ test_mcp_resources.py # MCP resources validation
โ โโโ test_workflow.py # End-to-end workflow testing
โ
โโโ requirements.txt # Project dependencies
โโโ README.md # This documentation
๐ค Contributing
Built for the Hugging Face MCP Hackathon. Contributions welcome!
๐ License
MIT License - See LICENSE file for details.
๐โโ๏ธ Find your perfect wave with AI-powered intelligence!
๐ฎ Future Enhancements
- Modal Serverless Deployment: Planned for production-scale deployment
- Global Spot Database: Integration with surf databases for worldwide coverage
- Forecast Integration: Multi-day weather predictions and session planning
- Community Features: User ratings, photos, and local tips