weather-mcp-server

weather-mcp-server

MCP server providing real-time weather data and forecasts via Open-Meteo, with tools for current conditions, multi-day forecasts, and umbrella recommendations, integrated with Databricks Agent Bricks for natural-language queries.

Category
访问服务器

README

Weather Prediction MCP Server + Agent Bricks

A Model Context Protocol (MCP) server that exposes weather forecast tools, integrated with Databricks Agent Bricks for natural-language weather queries.

Architecture

┌─────────────────────────────────────┐
│  User Question                      │
│  "Will it rain in Chicago tomorrow?"│
└───────────────┬─────────────────────┘
                │
                v
┌─────────────────────────────────────┐
│  Agent Bricks Agent                 │
│  (Databricks AI)                    │
│  - Interprets question              │
│  - Selects appropriate tools        │
│  - Formats natural-language answer  │
└───────────────┬─────────────────────┘
                │
                v
┌─────────────────────────────────────┐
│  Weather MCP Server                 │
│  (FastMCP, Databricks App)          │
│  Tools:                             │
│  - get_current_weather()            │
│  - get_forecast()                   │
│  - predict_umbrella_needed()        │
└───────────────┬─────────────────────┘
                │
                v
┌─────────────────────────────────────┐
│  Open-Meteo API                     │
│  (Free weather data, no auth)       │
│  - Geocoding                        │
│  - Current conditions               │
│  - Forecast data                    │
└─────────────────────────────────────┘

Components

1. Weather MCP Server (weather_mcp_server/)

A FastMCP server deployed as a Databricks App that exposes three weather tools:

Tools:

  • get_current_weather(location) - Real-time weather conditions

    • Returns: temperature, humidity, wind speed, conditions
    • Example: get_current_weather("Chicago")
  • get_forecast(location, days=7) - Multi-day forecast (1-16 days)

    • Returns: daily high/low temps, precipitation chance, conditions
    • Example: get_forecast("Austin, TX", days=5)
  • predict_umbrella_needed(location, target_date=None) - Smart recommendation

    • Decision logic: Umbrella needed if precipitation > 40% OR rain-related conditions
    • Returns: boolean recommendation + reasoning
    • Example: predict_umbrella_needed("Seattle", "2026-08-10")

2. Weather Broker (weather_broker.py)

Adapter module for Open-Meteo API:

  • get_current_conditions() - Fetches current weather
  • get_multi_day_forecast() - Fetches forecast data
  • _geocode_location() - Converts city names to lat/lon
  • _map_weather_code() - Translates WMO codes to human-readable conditions

API Choice: Open-Meteo

  • Free and open source
  • No API key required
  • ~10,000 calls/day
  • High-quality data from official weather services

3. Agent Bricks Agent

A Databricks AI agent configured with:

  • System prompt explaining weather-answering capabilities
  • External MCP tool registration pointing to the deployed MCP server
  • Natural-language interface for weather questions

Setup Instructions

Step 1: Deploy MCP Server

  1. Create Databricks secret (if not exists):

    databricks secrets create-scope mcp_server
    databricks secrets put-secret mcp_server databricks_token
    

    (Paste your Databricks token when prompted)

  2. Deploy the app from GitHub:

    databricks apps create weather-mcp-server \
      --source-code-url https://github.com/amalphonse/weather-mcp-server.git
    
  3. Start the app:

    databricks apps start weather-mcp-server
    
  4. Get the app URL:

    databricks apps get weather-mcp-server
    

    Note the url field - you'll need this for Agent Bricks.

Step 2: Register MCP Server with Agent Bricks

  1. Navigate to the Agent Bricks UI in Databricks
  2. Create a new agent or edit an existing one
  3. Under "External Tools", add a new MCP server:
    • Name: Weather Forecast Server
    • URL: <your-app-url> (from Step 1)
    • Description: Provides weather forecasts and recommendations

Step 3: Configure Agent System Prompt

Add this system prompt to your agent:

You are a helpful weather assistant with access to real-time weather data through an MCP server.

Your capabilities:
- Get current weather conditions for any location
- Provide multi-day weather forecasts (up to 16 days)
- Make practical recommendations about umbrellas and weather preparation

Available tools:
1. get_current_weather(location) - Use for "now", "current", or "today" questions
2. get_forecast(location, days) - Use for future dates or multi-day forecasts
3. predict_umbrella_needed(location, target_date) - Use when asked about rain gear or travel preparation

Guidelines:
- ALWAYS use the weather tools to get real data - never guess or make up weather information
- If a location cannot be found, ask the user to clarify or try a more specific location
- If the API fails, inform the user clearly and suggest trying again
- When making recommendations, explain your reasoning based on the data
- For precipitation, consider both the percentage chance and the forecasted conditions
- Be conversational and helpful, but always ground your responses in the actual weather data

Example interactions:
- "What's the weather in Chicago?" → Use get_current_weather
- "Will it rain in Seattle this weekend?" → Use get_forecast for the next few days
- "Should I bring an umbrella to Austin tomorrow?" → Use predict_umbrella_needed

Step 4: Test the Agent

Try these example queries:

  1. Current conditions: "What's the weather like in Chicago right now?"
  2. Forecast: "Will it be hot in Austin this weekend?"
  3. Recommendation: "Should I bring an umbrella to Seattle tomorrow?"

Example Agent Conversations

Example 1: Current Weather Query

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

Tool Call: get_current_weather("Chicago")

Tool Response:

{
  "success": true,
  "data": {
    "location": "Chicago",
    "temperature_f": 68.5,
    "temperature_c": 20.3,
    "conditions": "Partly cloudy",
    "humidity": 62,
    "wind_speed_mph": 8.2,
    "last_updated": "2026-08-09T15:30:00"
  }
}

Agent Response: "In Chicago right now, it's 68.5°F (20.3°C) with partly cloudy skies. The humidity is 62% and there's a light breeze at 8.2 mph. Pleasant conditions overall!"


Example 2: Multi-Day Forecast

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

Tool Call: get_forecast("Seattle", days=5)

Tool Response:

{
  "success": true,
  "data": {
    "location": "Seattle",
    "forecast": [
      {
        "date": "2026-08-10",
        "temp_high_f": 69,
        "temp_low_f": 56,
        "precipitation_chance": 65,
        "conditions": "Moderate rain"
      },
      {
        "date": "2026-08-11",
        "temp_high_f": 67,
        "temp_low_f": 55,
        "precipitation_chance": 45,
        "conditions": "Light drizzle"
      }
    ]
  }
}

Agent Response: "Yes, it will likely rain in Seattle this weekend. Saturday (Aug 10) shows a 65% chance of moderate rain with temperatures between 56-69°F. Sunday (Aug 11) also has a 45% chance of light drizzle. I'd definitely recommend bringing rain gear if you have outdoor plans!"


Example 3: Practical Recommendation

User: "Should I bring an umbrella to Austin tomorrow?"

Tool Call: predict_umbrella_needed("Austin", target_date="2026-08-10")

Tool Response:

{
  "success": true,
  "data": {
    "location": "Austin",
    "date": "2026-08-10",
    "umbrella_needed": false,
    "reasoning": "No umbrella needed. Precipitation chance is only 15% and conditions are 'Mainly clear'.",
    "precipitation_chance": 15,
    "conditions": "Mainly clear",
    "temp_high_f": 95,
    "temp_low_f": 76
  }
}

Agent Response: "No need for an umbrella in Austin tomorrow. The forecast shows mainly clear skies with only a 15% chance of precipitation. It will be hot though - expect temperatures to reach 95°F with a low of 76°F, so you might want to bring sunscreen and stay hydrated instead!"


Example 4: Error Handling

User: "What's the weather in Atlantis?"

Tool Call: get_current_weather("Atlantis")

Tool Response:

{
  "success": false,
  "error": "Location 'Atlantis' not found"
}

Agent Response: "I couldn't find a location called 'Atlantis' in the weather database. Could you please clarify the location? If you meant a specific city, try providing more details like the state or country (e.g., 'Atlanta, Georgia' or 'Atlantic City, New Jersey')."

Files

  • app.yaml - Databricks App configuration
  • requirements.txt - Python dependencies
  • weather_mcp_server.py - FastMCP server with tool definitions
  • weather_broker.py - Open-Meteo API adapter
  • README.md - This file
  • .gitignore - Git ignore rules

Dependencies

  • fastmcp>=0.4.0 - MCP server framework
  • fastapi>=0.115.0 - Web framework
  • uvicorn>=0.32.0 - ASGI server
  • requests>=2.32.0 - HTTP client
  • databricks-sdk>=0.35.0 - Secrets management

Error Handling

  • Location not found: Returns clear error asking user to clarify
  • API outage: Returns error message explaining the service is unavailable
  • Invalid date range: Returns error with valid date range
  • Network timeout: 10-second timeout with error message

Notes

  • Open-Meteo is free for non-commercial use (~10k calls/day)
  • No API key required - zero credentials to manage
  • Data sourced from official weather services (NOAA, DWD, etc.)
  • Forecast accuracy: Best within 7 days, still useful up to 16 days

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选