Weather Forecast MCP Server

Weather Forecast MCP Server

Provides real-time weather and forecast tools backed by Open-Meteo API, enabling natural-language weather queries and smart predictions like umbrella recommendations through Databricks Agent Bricks.

Category
访问服务器

README

Weather Forecast MCP Server + Databricks Agent Bricks

A Model Context Protocol (MCP) server that exposes weather forecast tools backed by the Open-Meteo API, integrated with Databricks Agent Bricks to answer natural-language weather questions and make intelligent predictions.

📦 Repository & Deployment

GitHub Repository: https://github.com/SanthoshKumar777/databricks-weather-predict-mcp-agent
Branch: main

Databricks App:

  • App Name: mcp-weather-server
  • Status: ✅ RUNNING
  • App URL: https://mcp-weather-server-7474646610904631.aws.databricksapps.com
  • MCP Endpoint: https://mcp-weather-server-7474646610904631.aws.databricksapps.com/mcp

Key Files:

Architecture

┌─────────────────────────────────────────────┐
│      Databricks Agent Bricks Agent          │
│  (Natural language weather Q&A + routing)   │
└────────────────┬────────────────────────────┘
                 │ Tool calls
                 ↓
┌─────────────────────────────────────────────┐
│        Weather MCP Server (FastMCP)         │
│  ┌──────────────────────────────────────┐   │
│  │  @mcp.tool decorators (thin layer)   │   │
│  │  - get_current_weather               │   │
│  │  - get_forecast                      │   │
│  │  - predict_umbrella_needed           │   │
│  └──────────┬───────────────────────────┘   │
│             ↓                                │
│  ┌──────────────────────────────────────┐   │
│  │  weather_broker.py (adapter layer)   │   │
│  │  - HTTP calls to Open-Meteo API      │   │
│  │  - Response parsing                  │   │
│  │  - Error handling                    │   │
│  └──────────┬───────────────────────────┘   │
└─────────────┼───────────────────────────────┘
              ↓
     ┌────────────────────┐
     │  Open-Meteo API    │
     │  (Free, no API key)│
     └────────────────────┘

Weather API

Provider: Open-Meteo
Authentication: None required (free tier, ~10,000 calls/day)
Data source: Official government weather models (NOAA, DWD, etc.)
Coverage: Global

Why Open-Meteo?

  • No signup, no API key, no credit card
  • Simple REST API with JSON responses
  • Reliable and well-documented
  • Perfect for educational/demo projects

MCP Tools (3 Required + Extras)

1. get_current_weather(location: str)

Returns real-time weather conditions for any location.

Args:

  • location: City name or location string (e.g., "Chicago", "London, UK")

Returns:

{
  "location": "Chicago, United States",
  "temperature_f": 45.2,
  "temperature_c": 7.3,
  "conditions": "Partly cloudy",
  "humidity": 72,
  "wind_speed_mph": 12.5,
  "wind_direction": "NW",
  "timestamp": "2026-08-10T14:30:00"
}

2. get_forecast(location: str, days: int = 7)

Returns multi-day weather forecast (up to 16 days).

Args:

  • location: City name or location string
  • days: Number of forecast days (1-16, default 7)

Returns:

{
  "location": "Austin, United States",
  "forecast_days": [
    {
      "date": "2026-08-11",
      "temp_high_f": 92.1,
      "temp_low_f": 73.4,
      "conditions": "Clear sky",
      "precipitation_probability": 10,
      "precipitation_mm": 0.0
    },
    ...
  ]
}

3. predict_umbrella_needed(location: str, date: str = None)

Smart prediction tool - applies threshold logic to raw forecast data.

Logic:

  • Precipitation probability > 40% OR precipitation > 5mm → "Yes, bring an umbrella"
  • Precipitation probability 20-40% → "Maybe, keep one handy"
  • Precipitation probability < 20% → "No umbrella needed"

Args:

  • location: City name or location string
  • date: Target date in YYYY-MM-DD format (defaults to tomorrow if omitted)

Returns:

{
  "location": "Seattle, United States",
  "date": "2026-08-11",
  "recommendation": "yes",
  "reason": "High chance of rain (65% probability, 8.2mm expected). Bring an umbrella.",
  "precipitation_probability": 65,
  "precipitation_mm": 8.2,
  "conditions": "Moderate rain"
}

Project Structure

databricks-weather-predict-mcp-agent/
├── weather_broker.py          # Adapter: HTTP calls to Open-Meteo API
├── weather_mcp_server.py      # FastMCP server with @mcp.tool decorators
├── requirements.txt           # Python dependencies
├── app.yaml                   # Databricks App configuration
└── README.md                  # This file

Setup & Deployment

Step 1: Deploy the MCP Server as a Databricks App

# From your workspace, navigate to the project directory
cd /Workspace/Users/<your-email>/databricks-weather-predict-mcp-agent

# Deploy the app
databricks apps deploy mcp-weather-server \
  --source-code-path /Workspace/Users/<your-email>/databricks-weather-predict-mcp-agent

# Check deployment status
databricks apps get mcp-weather-server

Once deployed, note the app URL (e.g., https://<workspace>.cloud.databricks.com/apps/<app-id>).

Step 2: Register the MCP Server as an External Tool

  1. Navigate to Databricks Workspace → Machine Learning → Agents
  2. Click "+ New External Tool"
  3. Configure:
    • Name: weather_forecast_mcp
    • Type: MCP Server (HTTP)
    • URL: https://<workspace>.cloud.databricks.com/apps/<app-id>/mcp
    • Authentication: None (internal app-to-app)
  4. Click "Test Connection" to verify
  5. Save the tool

Step 3: Create the Agent Bricks Agent

  1. Navigate to Databricks Workspace → Machine Learning → Agents
  2. Click "+ Create Agent"
  3. Configure:
    • Name: Weather Assistant
    • LLM: Choose your preferred model (e.g., databricks-dbrx-instruct)
    • System Prompt:
You are a helpful weather assistant powered by real-time weather data.

Your capabilities:
1. Check current weather conditions for any location
2. Provide multi-day weather forecasts
3. Make smart predictions (e.g., umbrella recommendations)

Guidelines:
- Always call the appropriate weather tool to get real-time data
- Never guess or hallucinate weather information
- If a location cannot be resolved, ask the user to clarify
- For umbrella predictions, explain the threshold logic you used
- If the API fails, inform the user clearly and suggest trying again
- Be conversational and helpful, but precise about weather data

When answering weather questions:
1. First, call get_current_weather or get_forecast
2. Then, interpret the results in plain language
3. Provide specific numbers (temps, precipitation chance)
4. For predictions, use predict_umbrella_needed and explain the reasoning
  1. Add External Tool:

    • Select weather_forecast_mcp from the dropdown
    • Enable all three tools: get_current_weather, get_forecast, predict_umbrella_needed
  2. Click "Create Agent"

Example Queries & Demonstrations

Query 1: Current Weather

User: "What's the weather like in Chicago right now?"

Agent's Tool Call:

{
  "tool": "get_current_weather",
  "args": {"location": "Chicago"}
}

Agent's Response:

"In Chicago, United States, it's currently 45°F (7°C) with partly cloudy skies. The humidity is at 72%, and there's a moderate northwest wind at 12.5 mph."


Query 2: Multi-Day Forecast

User: "Will it rain in Austin this weekend?"

Agent's Tool Call:

{
  "tool": "get_forecast",
  "args": {"location": "Austin", "days": 3}
}

Agent's Response:

"Looking at the 3-day forecast for Austin, United States:

  • Saturday (Aug 11): Clear sky, high of 92°F, low of 73°F. Only 10% chance of rain.
  • Sunday (Aug 12): Partly cloudy, high of 89°F, low of 72°F. 15% chance of rain.
  • Monday (Aug 13): Clear sky, high of 91°F, low of 74°F. No rain expected.

Overall, it looks like a dry weekend with no rain. Perfect weather for outdoor plans!"


Query 3: Smart Prediction

User: "Should I bring a jacket to Seattle tomorrow?"

Agent's Tool Call:

{
  "tool": "get_forecast",
  "args": {"location": "Seattle", "days": 2}
}

Agent's Response:

"Tomorrow in Seattle, the high will be 58°F with a low of 48°F and partly cloudy conditions. Yes, I'd recommend bringing a jacket—it's going to be quite cool, especially in the morning and evening."


Query 4: Umbrella Prediction

User: "Do I need an umbrella in London tomorrow?"

Agent's Tool Call:

{
  "tool": "predict_umbrella_needed",
  "args": {"location": "London"}
}

Agent's Response:

"Yes, bring an umbrella for London tomorrow (Aug 11). There's a 65% chance of moderate rain with about 8.2mm of precipitation expected. My threshold logic says any precipitation probability over 40% or total rainfall over 5mm warrants an umbrella—and tomorrow exceeds both!"


Error Handling

The MCP server gracefully handles common failure modes:

Bad Location:

{
  "error": "Location 'Zzyzyx123' not found. Please check spelling or try a different format (e.g., 'City, Country')."
}

Invalid Date:

{
  "error": "Invalid date format: 2026-13-99. Use YYYY-MM-DD."
}

API Timeout:

{
  "error": "Failed to fetch current weather: Connection timeout"
}

The Agent Bricks agent then interprets these errors and responds helpfully (e.g., asking the user to clarify the location).

Testing the MCP Server Directly

You can test the MCP server endpoints directly before wiring up the agent:

# Test get_current_weather
curl -X POST https://<workspace>.cloud.databricks.com/apps/<app-id>/mcp/call \
  -H "Content-Type: application/json" \
  -d '{
    "method": "tools/call",
    "params": {
      "name": "get_current_weather",
      "arguments": {"location": "San Francisco"}
    }
  }'

# Test predict_umbrella_needed
curl -X POST https://<workspace>.cloud.databricks.com/apps/<app-id>/mcp/call \
  -H "Content-Type: application/json" \
  -d '{
    "method": "tools/call",
    "params": {
      "name": "predict_umbrella_needed",
      "arguments": {"location": "Seattle", "date": "2026-08-11"}
    }
  }'

Design Principles

Thin tool functions: All HTTP/parsing logic lives in weather_broker.py, not in @mcp.tool functions
Clear error messages: API failures return actionable errors, not stack traces
No secrets committed: Open-Meteo requires no API key, avoiding secrets management
Threshold logic: predict_umbrella_needed applies explicit rules (40% threshold, 5mm threshold) and explains them in the docstring
Specific system prompt: The agent is instructed not to hallucinate weather data and always call tools first

Future Enhancements (Stretch Goals)

  • Severe Weather Alerts: Add a tool that calls NWS API (US only) for active warnings/watches
  • Historical Lookups: Add a tool for past weather data (e.g., "What was the weather like in Paris on Christmas last year?")
  • Multi-City Comparison: Add a tool to compare weather across multiple cities (e.g., "Which is warmer this weekend, Miami or LA?")
  • Dashboard App: Build a small Streamlit dashboard (like dashboard/ in the reference repo) to visualize recent agent queries and predictions

Troubleshooting

Problem: MCP server returns "Location not found"
Solution: Try a different format (e.g., "London, UK" instead of "London"). Some small towns may not be indexed by the geocoding API.

Problem: Agent doesn't call the tool
Solution: Check that the tool is enabled in the Agent Bricks configuration and that the system prompt encourages tool usage.

Problem: App deployment fails
Solution: Verify app.yaml has correct file paths and that requirements.txt includes fastmcp>=3.4.0.

Problem: "Unexpected API response format" error
Solution: Open-Meteo occasionally changes response schemas. Check the API docs and update weather_broker.py accordingly.

License

This project is provided as-is for educational purposes. Open-Meteo data is licensed under CC BY 4.0.


Built with: FastMCP, Open-Meteo API, Databricks Agent Bricks
Author: Your Name
Date: August 10, 2026

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选