weather-mcp
by bidhan017
README.md
# Weather Prediction MCP Server
[](https://m8ven.ai/mcp/bidhan017-weather-mcp-1tp72e)
> **Indexed in M8ven Trust Registry** - An independent security and trust index for Model Context Protocol servers.
## Overview
A FastMCP server exposing weather tools backed by Open-Meteo and connected
to a Databricks Agent Bricks agent.
## Architecture
User -> Agent Bricks -> Databricks App MCP Server
-> weather_adapter.py -> Open-Meteo APIs
## Weather API
Open-Meteo Forecast API and Geocoding API.
Authentication: none required for this non-commercial project.
## Tools
### get_current_weather
Returns current temperature, apparent temperature, humidity, precipitation,
wind, and conditions.
### get_forecast
Returns daily high/low temperature, precipitation, precipitation probability,
wind, and conditions for 1 to 16 days.
### predict_umbrella_needed
Applies rule-based recommendations:
- Umbrella at precipitation probability >= 40%.
- Umbrella at expected precipitation >= 1 mm.
- Umbrella for thunderstorms.
- Jacket when the high temperature is below 15 C.
- Warm layer when the low temperature is below 8 C.
## Local setup
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python weather_mcp_server.py
```
## Databricks Deployment
### Deployed MCP Server App
**App Name**: `mcp-weather-server`
**App URL**: https://mcp-weather-server-7474660615522196.aws.databricksapps.com
**MCP Endpoint**: https://mcp-weather-server-7474660615522196.aws.databricksapps.com/mcp
**Status**: ✅ Running
**Source Code Path**: `/Workspace/Users/bchandra.ry@gmail.com/weather-mcp`
**Note**: The app name MUST start with "mcp-" to be visible in Agent Bricks Custom MCP Server dropdown.
### Agent Bricks Configuration
**Agent URL**: https://dbc-81d3c679-2bf9.cloud.databricks.com/ml/bricks/sa/build/786f6cdf-f00b-443b-a0f9-180fe55ac3cc?o=7474660615522196
**System Prompt**: See `agent_system_prompt.txt`
**Tools Registered**:
- `get_current_weather`
- `get_forecast`
- `predict_umbrella_needed`
The agent is configured in AI Playground under Tools > MCP Servers > Custom MCP Server.
## Agent Demonstration
The following examples demonstrate the WeatherGuide agent successfully calling the MCP server tools:
### Example 1: Current Weather Query
**User Question**: "What's the weather like in Chicago right now?"
**Tools Called**:
- `get_current_weather(location="Chicago")`
**Agent Response**: The agent retrieved current conditions from Open-Meteo showing:
- Temperature: 24.2°C (feels like 26.3°C)
- Conditions: Clear sky
- Humidity: 75%
- Wind: 9.9 km/h
### Example 2: Multi-Day Forecast
**User Question**: "Will it rain in Austin this weekend?"
**Tools Called**:
- `get_forecast(location="Austin", days=5)`
**Agent Response**: The agent analyzed the 5-day forecast and reported:
- Weekend forecast shows overcast and partly cloudy conditions
- Precipitation probability: 1-3% (very low)
- Temperatures: Highs of 36-40°C, lows of 24-26°C
- **Conclusion**: No rain expected in Austin this weekend
### Example 3: Recommendation/Prediction
**User Question**: "Should I bring a jacket to San Francisco tomorrow?"
**Tools Called**:
- `predict_umbrella_needed(location="San Francisco", forecast_date="2026-08-09")`
**Agent Response**: The agent applied the rule-based decision logic:
- Date: August 9, 2026
- Temperature: 26.3°C / 13.7°C
- Conditions: Fog
- Precipitation: 0.0mm (2% chance)
- **Umbrella needed**: No
- **Jacket recommendation**: Not needed (high temp above 15°C threshold)
All three examples show the agent:
1. ✅ Correctly calling the appropriate MCP tool
2. ✅ Parsing the tool response
3. ✅ Providing natural language answers based on real weather data
4. ✅ Following the system prompt rules (no guessing, always using tools)
## Error handling
Invalid locations, invalid dates, API errors, and unsupported forecast ranges
return structured errors. The agent is instructed not to guess when a tool
fails.
## Implementation Highlights
### Code Structure
- **`weather_mcp_server.py`**: FastMCP server with 3 @mcp.tool decorated functions
- **`weather_adapter.py`**: Clean HTTP adapter handling all Open-Meteo API calls
- **`app.yaml`**: Databricks App configuration
- **`requirements.txt`**: Dependencies (fastmcp>=2.0, requests>=2.32)
- **`agent_system_prompt.txt`**: Complete agent behavior instructions
### Key Features
✅ **Clean separation of concerns**: MCP tool functions are thin wrappers; all HTTP logic lives in the adapter
✅ **Structured error handling**: WeatherAPIError exceptions return clean error dicts with guidance
✅ **No secrets required**: Uses free Open-Meteo API (no API keys)
✅ **Rule-based predictions**: The `predict_umbrella_needed` tool applies documented thresholds:
- Umbrella if precipitation ≥ 1mm OR probability ≥ 40% OR thunderstorms
- Jacket if high temp < 15°C
- Warm layer if low temp < 8°C
✅ **Location resolution**: Geocoding API resolves city names to coordinates automatically
✅ **Detailed docstrings**: Every tool has Args/Returns documentation
### GitHub Repository
**Repository**: https://github.com/bidhan017/weather-mcp
The app is deployed from this Git repository with automatic updates on push.
## Limitations
- Forecast values can change as new model runs are published.
- Recommendations are simple threshold-based judgments, not official warnings.
- Open-Meteo attribution should be retained in the application and README.
- App name must start with "mcp-" to be discoverable in Agent Bricks Custom MCP Server list.This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues