weather-mcp-server
Provides current weather, forecasts, trend predictions, and personalized recommendations for any location using the Open-Meteo API.
README
Weather MCP Server
A Model Context Protocol (MCP) server that provides weather data and predictions using the Open-Meteo API.
Features
- Current Weather - Get real-time weather conditions for any location
- Weather Forecast - 7-day detailed forecast with temperatures, precipitation, and wind
- Weather Predictions - Analyze trends and provide natural language predictions
- Smart Recommendations - Personalized advice based on weather conditions
Architecture
The project follows a clean separation of concerns:
weather_broker.py- Adapter module that handles all HTTP/API interactions with Open-Meteoweather_mcp_server.py- FastMCP server that exposes weather capabilities as MCP toolsapp.yaml- Databricks App configuration for deployment- Clean data flow: API → Broker → Dictionaries → MCP Tools → Formatted responses
Installation
pip install -r requirements.txt
Usage
Running the Server
Local Development
python weather_mcp_server.py
Databricks App Deployment
# Deploy as a Databricks App
databricks apps deploy weather-mcp-server \
--source-code-path /Workspace/Users/<your-email>/weather-mcp-agent
# Check app status
databricks apps get weather-mcp-server
Available Tools
1. get_current_weather(location: str)
Get current weather conditions for a location.
get_current_weather("San Francisco")
2. get_forecast(location: str, days: int = 7)
Get weather forecast for up to 16 days.
get_forecast("London, UK", days=5)
3. predict_weather_trend(location: str)
Analyze weather trends and provide predictions.
predict_weather_trend("Tokyo")
4. get_weather_recommendation(location: str)
Get personalized recommendations based on current and upcoming weather.
get_weather_recommendation("New York")
Data Source
Weather data is provided by Open-Meteo, a free weather API that requires no authentication.
Example Outputs
Current Weather
Current weather in San Francisco, United States:
Condition: Partly cloudy
Temperature: 18°C (feels like 17°C)
Humidity: 65%
Wind: 15 km/h from 270°
Precipitation: 0 mm
Weather Prediction
Weather Analysis for London, United Kingdom:
Current Conditions: Overcast at 12°C
7-Day Outlook:
The weather is cooling down over the next week, with temperatures averaging 10.5°C.
You can expect frequent rain, with total precipitation around 45.2 mm.
Recommendations
Weather Recommendations for Tokyo, Japan:
🧥 It's quite cold. A jacket and warm clothing recommended.
☔ High chance of rain in the next few days. Keep an umbrella handy!
✨ Great conditions for outdoor activities!
Prediction & Recommendation Thresholds
The server uses the following thresholds for weather recommendations:
Temperature Recommendations
- Cold (< 10°C): Jacket and warm clothing recommended
- Cool (10-15°C): Light jacket suggested
- Comfortable (15-25°C): No special clothing needed
- Warm (> 25°C): Light, breathable clothing suggested
Precipitation Recommendations
- High chance (> 60% probability): Umbrella strongly recommended
- Moderate chance (30-60% probability): Consider bringing umbrella
- Low chance (< 30% probability): Umbrella not needed
Wind Conditions
- Strong wind (> 30 km/h): Outdoor activity warnings
- Moderate wind (15-30 km/h): Normal conditions
- Light wind (< 15 km/h): Ideal outdoor conditions
Technical Details
- Uses FastMCP for MCP server implementation
- HTTP requests handled via httpx with 30-second timeout
- Geocoding resolves location names to coordinates
- WMO weather codes interpreted to human-readable conditions
- Temperature in Celsius, wind speed in km/h
- Supports any location worldwide
- Request middleware with context tracking (host, port, user identity)
- Deployable as a Databricks App
Error Handling
The server gracefully handles:
- Invalid location names
- API connection issues
- Invalid parameter ranges
- Missing data
Project Structure
weather-mcp-agent/
├── weather_mcp_server.py # Main FastMCP server
├── weather_broker.py # Weather API adapter
├── app.yaml # Databricks App configuration
├── requirements.txt # Python dependencies
├── setup_secrets.py # Secret management helper
├── DEPLOYMENT_FIX.md # Deployment troubleshooting
└── README.md # This file
Configuration
Environment Variables
DATABRICKS_APP_PORT- Server port (default: 8000)DATABRICKS_APP_HOST- Server host (default: 0.0.0.0)
Secrets Management
Use setup_secrets.py to securely store credentials (lakebase url) in Databricks Secrets instead of hardcoding them in your configuration files.
Dependencies
fastmcp>=0.2.0- FastMCP server frameworkhttpx>=0.27.0- HTTP client for API requeststyping_extensions>=4.12.0- Type hints support
Development Notes
- The server runs on host
0.0.0.0and port8000by default - FastMCP uses stdio transport for Model Context Protocol communication
- All weather data comes from the free Open-Meteo API (no API key required)
- Request middleware captures context using Python's
contextvarsfor thread-safe operation
Transcript of agent interactions
Query 1: Recommendation Logic
- Prompt: "Should I bring a jacket to Austin this weekend?"
- Tool Called:
predict_umbrella_needed(location="Austin, TX", target_date_offset=1) - Response: "Based on the weather forecast, it's unlikely that you'll need a jacket in Austin this weekend. The temperatures are expected to be quite warm, ranging from 25.6°C to 40.1°C, with minimal chances of precipitation. You may want to consider packing light, breathable clothing and sunscreen instead."
Query 2: Forecast
- Prompt: "What does the weather forecast look like for Austin, TX?"
- Tool Called:
get_forecast(location="Austin, TX", days=3) - Response: "The weather forecast for Austin, TX from August 10th to August 12th is as follows:\n August 10th: Overcast with temperatures ranging from 26.5°C to 37.3°C and an 8% chance of precipitation.\n August 11th: Overcast with temperatures ranging from 26.1°C to 38.5°C and a 6% chance of precipitation.\n August 12th: Overcast with temperatures ranging from 25.6°C to 40.1°C and a 0% chance of precipitation.\n It's expected to be quite warm and dry, with minimal chances of rain during this period."
Query 3: Current Weather
- Prompt: "What is the current weather in NYC?"
- Tool Called:
get_current_weather(location="New York City") - Response: "The current weather in NYC is a clear sky with a temperature of 23.8°C (feeling like 26.1°C), humidity at 77%, and a wind speed of 8.9 km/h from the northwest. There is no precipitation at the moment. Please note that this information was last updated on August 10th, 2026, at 3:45 AM, so it's recommended to check for updates for the most current weather conditions."
Query 4: Ask to clarify ambiguous location
- Prompt: "can you share the current weather for sjkdfshjdff?"
- Response: "I couldn't find any information on a location called "sjkdfshjdff". It's possible that it's a misspelling or a non-existent location. If you could provide a valid city or location name, I'd be happy to try and help you with the current weather."
Troubleshooting
If you encounter deployment issues, see DEPLOYMENT_FIX.md for common problems and solutions.
License
MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。