weather-prediction-mcp-server
MCP server that provides real-time weather data, forecasts, city weather comparisons, and travel recommendations using the OpenMeteo API, enabling AI agents to answer weather-related queries and suggest optimal travel conditions.
README
Weather MCP Server
A Model Context Protocol (MCP) server that provides weather data and intelligent travel recommendations through the OpenMeteo API. This server enables AI agents in Databricks Agent Bricks to access real-time weather information and forecasts for any city worldwide.
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐
│ │ │ │ │ │
│ OpenMeteo API │◄────►│ MCP Server App │◄────►│ Agent Bricks Agent │
│ │ │ (Databricks) │ │ (Databricks) │
│ - Weather Data │ │ - FastMCP │ │ - Natural Language │
│ - Geocoding │ │ - Tool Exposure │ │ - Tool Invocation │
│ │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────────┘
Available Tools
The MCP server exposes four weather-related tools that can be invoked by AI agents:
1. get_current_weather(location: str)
Get current weather data for a specific city.
Parameters:
location: City name (e.g., "Berlin", "New York", "Tokyo")
Returns:
- Current temperature (°C)
- Relative humidity (%)
- Precipitation (mm)
- Wind speed (km/h)
- Location coordinates (latitude, longitude)
2. get_forecast(location: str, days: int)
Get weather forecast for the next N days (up to 16 days).
Parameters:
location: City namedays: Number of forecast days (1-16)
Returns:
- Daily forecast including:
- Min/max temperature (°C)
- Precipitation probability (%)
- Max wind speed (km/h)
- Date timestamp
3. get_cities_weather_comparison(locations: list[str], days: int)
Compare weather across multiple cities and recommend the best weather conditions.
Parameters:
locations: List of city names (minimum 2 cities)days: Number of days to analyze (0 for current weather, 1-16 for forecast)
Returns:
- Weather comparison data for all cities
- Weather scores based on temperature, precipitation, wind, and humidity
- Recommendation for the city with the best weather conditions
4. get_travel_recommendation(location: str, days: int)
Get practical travel recommendations based on weather conditions.
Parameters:
location: City namedays: Number of days to analyze (0 for current weather, 1-16 for forecast)
Returns:
- Weather summary
- Actionable recommendations (e.g., "Bring an umbrella", "Pack sunscreen")
Architecture & Setup Guide
Step 1: Create the Weather Broker Module
First, we created a weather_broker.py module that handles:
- Geocoding: Translates city names to coordinates using OpenMeteo's geocoding API
- API Integration: Connects to OpenMeteo's weather and forecast endpoints
- Data Processing: Formats weather data into structured responses
Step 2: Implement the MCP Server
The weather_mcp_server.py file exposes weather tools using FastMCP:
- Defines four MCP tools with clear signatures and documentation
- Handles error cases (invalid locations, API failures)
- Implements weather scoring algorithms for comparisons
- Provides logging for debugging and monitoring
Step 3: Deploy the MCP Server as a Databricks App
- Create an
app.yamlconfiguration file specifying:- Python dependencies (fastmcp, requests)
- Entry point and command
- Compute requirements
- Deploy the app using Databricks Apps
- The server becomes accessible at a unique URL endpoint
Step 4: Create an Agent in Agent Bricks Playground
- Navigate to the Agent Bricks Playground in Databricks
- Create a new agent
- Configure the MCP server connection:
- Add the deployed app URL as an external MCP server
- The agent automatically discovers the four weather tools
Step 5: Configure the System Prompt
Set up the agent's system prompt to guide its behavior. For this project, we used:
Custom System Prompt:
Only answer for locations you can resolve; if the API call fails, say so rather than guessing.
Ask the user to clarify in case of any error.
This prompt ensures the agent:
- Provides accurate information based only on successful API responses
- Avoids hallucinating weather data when locations cannot be resolved
- Clearly communicates API failures to the user
- Requests clarification for ambiguous or invalid locations
- Maintains transparency about data availability
Step 6: Deploy the Agent as a Databricks App
- Test the agent in the Playground
- Once validated, deploy the agent as a production Databricks App
- Users can now interact with the weather agent through:
- Web interface
- API endpoints
- Integration with other Databricks workflows
Why OpenMeteo API?
I chose the OpenMeteo API for several compelling reasons:
1. Ease of Use and Setup
- No API key required for basic usage
- Simple RESTful interface with intuitive parameters
- Straightforward JSON responses
- Quick integration without authentication complexity
2. Well-Documented API
- Comprehensive documentation with clear examples
- Detailed parameter descriptions
- Complete coverage of available data points
- Active community support
3. Generous Request Limits
- Free tier allows up to 10,000 requests per day
- No credit card required for development and testing
- Sufficient for prototyping and small-scale production use
- Predictable rate limiting policies
4. Geocoding API Integration
- Built-in geocoding API to translate city names into coordinates
- Eliminates the need for a separate geocoding service
- Handles multiple cities with the same name (returns most relevant)
- Supports international cities with various naming conventions
5. Data Quality and Coverage
- High-quality weather data from multiple meteorological sources
- Global coverage for virtually any location
- Reliable forecast accuracy up to 16 days
- Frequently updated data (current weather updated every 15 minutes)
Usage Example
Once deployed, users can interact with the agent using natural language:
User: "What's the weather like in Paris right now?"
Agent: [Calls get_current_weather("Paris")]
User: "I'm planning a trip to Tokyo or Seoul next week. Which city has better weather?"
Agent: [Calls get_cities_weather_comparison(["Tokyo", "Seoul"], 7)]
User: "What should I pack for a 3-day trip to London?"
Agent: [Calls get_travel_recommendation("London", 3)]
Technical Stack
- MCP Framework: FastMCP (Model Context Protocol)
- Weather API: OpenMeteo (free, no-auth weather API)
- Deployment: Databricks Apps
- Agent Platform: Databricks Agent Bricks
- Language: Python 3.x
Project Structure
weather-mcp-server/
├── mcp-server/
│ ├── weather_mcp_server.py # MCP server implementation
│ ├── weather_broker.py # OpenMeteo API integration
│ ├── app.yaml # Databricks App configuration
│ └── README.md # This file
Future Enhancements
- Add historical weather data analysis
- Support for hourly forecasts
- Weather alerts and warnings
- Air quality index integration
- Extended forecast range (beyond 16 days)
- Multi-language support for city names
- Caching layer to reduce API calls
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。