A newer version of the Gradio SDK is available: 6.15.2
FastMCP to Gradio MCP Conversion Summary
This document summarizes the conversion of the FastMCP weather server to a Gradio MCP application.
What Was Done
New Files Created
mcp_open_meteo/gradio_app.py - Main Gradio MCP application
- 5 tools with
@gr.mcp.tool()decorator - 2 resources with
@gr.mcp.resource()decorator - 6 prompts with
@gr.mcp.prompt()decorator - Web UI with 5 tabs (Search, Weather, Forecast, Alerts, About)
- ~800 lines of code
- 5 tools with
docs/gradio-app-guide.md - Comprehensive usage guide
- Quick start instructions
- Feature overview
- Architecture explanation
- Claude Desktop configuration
- Troubleshooting guide
Files Modified
pyproject.toml
- Added
gradio>=4.0.0andgradio[mcp]>=4.0.0dependencies - Added
gradio-weather = "mcp_open_meteo.gradio_app:main"script entry point
- Added
mcp_open_meteo/main.py
- Added support for
--gradioflag to choose between implementations - Allows
uv run python -m mcp_open_meteo --gradioto launch Gradio app
- Added support for
CLAUDE.md (Updated)
- Added Gradio MCP app to quick start (with recommendation)
- Updated architecture overview to show both implementations
- Updated "Key Files" table to include gradio_app.py
- Added "Using with Claude Desktop" section
- Updated verification checklist
Files Not Changed (Shared Logic)
These remain unchanged and are used by both implementations:
api_client.py- Async HTTP client for Open-Meteo APIslocation_resolver.py- Location geocoding logicmodels.py- Pydantic data modelsconstants.py- WMO code mappingsconfig.py- Static configuration
Key Features of the Gradio Implementation
Web Interface (5 Tabs)
- π Search Locations - Find locations and view their coordinates
- π€οΈ Current Weather - Get current conditions with emoji formatting
- π Weather Forecast - View multi-day forecasts with adjustable days slider
- β οΈ Weather Alerts - Check for severe weather warnings
- βΉοΈ About MCP - Configuration guide for Claude Desktop integration
MCP Integration
- All 5 tools available as MCP tools with JSON responses
- 2 URI-based resources (weather://current/{location}, weather://forecast/{location})
- 6 AI-assistance prompt templates
- Automatic MCP endpoint at
/gradio_api/mcp/ - Works seamlessly with Claude Desktop, Cursor, Cline
Response Formats
- Web UI: Markdown with emoji for readability
- MCP Clients: JSON strings for structured data
Usage
Launch Gradio App
# Primary recommended way
uv run gradio-weather
# Alternative way
uv run python -m mcp_open_meteo --gradio
This starts:
- Web UI at
http://localhost:7860 - MCP server at
http://localhost:7860/gradio_api/mcp/
Configure Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"weather": {
"url": "http://localhost:7860/gradio_api/mcp/"
}
}
}
Then restart Claude Desktop to use all weather tools!
Implementation Details
All 5 Tools Converted
- β
search_locations_tool- Search locations by name - β
get_current_weather- Get current conditions - β
get_weather_forecast- Get daily forecast - β
get_hourly_forecast- Get hourly forecast - β
get_weather_alerts- Check for alerts
All 2 Resources Converted
- β
weather://current/{location}- Current weather resource - β
weather://forecast/{location}- Forecast resource
All 6 Prompts Converted
- β
weather-analysis- Comprehensive analysis template - β
travel-advisory- Travel comparison template - β
severe-weather-monitor- Severe weather monitoring template - β
outdoor-activity-planner- Activity planning template - β
weather-comparison- Multi-location comparison template - β
seasonal-insights- Seasonal patterns template
Comparison: Gradio vs FastMCP
| Aspect | Gradio MCP | FastMCP |
|---|---|---|
| User Interface | Web UI with 5 tabs | No UI (MCP Inspector separate) |
| Start Command | uv run gradio-weather |
uv run mcp-open-meteo |
| Testing UI | Built-in web interface | Separate MCP Inspector tool |
| Tools | 5 JSON-formatted tools | 5 Pydantic-formatted tools |
| Resources | 2 URI resources | 2 URI resources |
| Prompts | 6 templates | 6 templates |
| Port | 7860 | Stdio/5000+ |
| Best For | Development + demos | Production + CLI use |
| Dependencies | Includes Gradio | Lightweight MCP only |
Migration Path
If moving from FastMCP to Gradio MCP:
- Run
uv run gradio-weatherinstead ofuv run mcp-open-meteo - Update Claude Desktop config to point to
http://localhost:7860/gradio_api/mcp/ - All tools, resources, and prompts work identically
- Web interface is a bonus for manual testing
File Structure
mcp_open_meteo/
βββ gradio_app.py β NEW: Gradio MCP application
βββ server.py (FastMCP server - still available)
βββ tools.py (Shared logic)
βββ resources.py (FastMCP resources - parallel in gradio_app.py)
βββ prompts.py (FastMCP prompts - parallel in gradio_app.py)
βββ api_client.py (Shared)
βββ location_resolver.py (Shared)
βββ models.py (Shared)
βββ constants.py (Shared)
βββ config.py (Shared)
βββ __main__.py (Updated to support --gradio)
docs/
βββ gradio-app-guide.md β NEW: Comprehensive guide
CLAUDE.md (Updated with Gradio info)
pyproject.toml (Updated with Gradio deps)
Testing Checklist
β
All tools return JSON strings for MCP compatibility
β
All resources use proper URI templates
β
All prompts return formatted strings
β
Web UI has proper error handling
β
MCP endpoint is properly exposed
β
Dependencies installed via uv sync
β
Code follows existing style (PEP 8, 88 chars)
β
Async/await properly used throughout
β
Type hints present on all functions
β
Docstrings include Args sections for MCP discovery
Next Steps
- Test locally:
uv run gradio-weatherand openhttp://localhost:7860 - Configure Claude: Add MCP config and restart
- Test MCP: Ask Claude to search locations, get weather, etc.
- Use prompts: Try weather analysis, travel advisory, etc.
- Deploy: Run
uv run gradio-weatheron production server with proper networking
Notes
- No breaking changes to existing FastMCP implementation
- FastMCP server still available at
uv run mcp-open-meteo - Both implementations use identical core logic
- Gradio app is recommended for new development
- Can run both simultaneously on different ports if needed