Weather MCP Server

Weather MCP Server

Provides weather forecast tools using Open-Meteo, enabling users to get current conditions, multi-day forecasts, and umbrella recommendations through natural language queries.

Category
访问服务器

README

Weather Forecast MCP Server & Agent

A complete implementation of a weather forecast MCP (Model Context Protocol) server with a Databricks Agent Bricks agent integration.

Overview

This project demonstrates how to build and deploy:

  1. Weather MCP Server - FastMCP server exposing weather forecast tools
  2. Agent Bricks Integration - An intelligent agent that uses the MCP server to answer weather questions

The weather data comes from Open-Meteo, a free weather API requiring no signup or API key.

Architecture

┌─────────────────┐      ┌──────────────────┐      ┌─────────────────┐
│  User Question  │─────▶│  Agent Bricks    │─────▶│  Weather MCP    │
│   "Will it      │      │     Agent        │      │     Server      │
│  rain in SF?"   │      │                  │      │                 │
└─────────────────┘      └──────────────────┘      └─────────────────┘
                                  │                          │
                                  │                          ▼
                                  │                  ┌─────────────────┐
                                  │                  │  weather_broker │
                                  │                  │                 │
                                  ▼                  └─────────────────┘
                         ┌─────────────────┐                │
                         │  Natural Lan-   │                ▼
                         │  guage Response │        ┌─────────────────┐
                         └─────────────────┘        │   Open-Meteo    │
                                                    │      API        │
                                                    └─────────────────┘

Files

Weather MCP Server

  • weather_broker.py - Weather API adapter (HTTP calls to Open-Meteo)
  • weather_mcp_server.py - FastMCP server with 3 tools
  • app.yaml - Databricks App deployment config
  • requirements.txt - Python dependencies

Agent Configuration

  • weather_agent.py - Agent Bricks agent configuration

MCP Tools

The server exposes 3 tools:

1. get_current_weather(location: str)

Get current weather conditions for any location.

Example:

get_current_weather("Chicago")
# Returns: temperature, feels_like, humidity, wind, conditions, etc.

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

Get multi-day weather forecast (1-16 days).

Example:

get_forecast("Austin", days=5)
# Returns: daily forecasts with high/low temps, precipitation, conditions

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

Make a recommendation about needing an umbrella.

Example:

predict_umbrella_needed("Seattle", "2026-08-15")
# Returns: YES/NO/MAYBE recommendation with reasoning

Deployment

Step 1: Deploy the MCP Server

# From the workspace CLI or notebook
databricks apps create weather_mcp \
  --source-path /Workspace/Users/your-email@example.com/weather_mcp

Step 2: Get the App URL

databricks apps get weather_mcp
# Note the URL, e.g., https://dbc-xxxxx.cloud.databricks.com/apps/weather_mcp

Step 3: Configure the Agent

Edit weather_agent.py and set WEATHER_MCP_URL to your deployed app URL:

MCP_SERVER_URL = "https://dbc-xxxxx.cloud.databricks.com/apps/weather_mcp"

Step 4: Deploy the Agent

The agent can be deployed as another Databricks App or used directly in notebooks.

Testing

Test the MCP Server Locally

# In a notebook
import weather_broker

# Test current weather
weather_broker.get_current_weather("San Francisco")

# Test forecast
weather_broker.get_forecast("New York", days=3)

Test the Agent

from weather_agent import create_weather_agent

agent = create_weather_agent()

# Ask weather questions
response = agent.chat("What's the weather like in Chicago right now?")
print(response)

response = agent.chat("Will it rain in Austin this weekend?")
print(response)

response = agent.chat("Should I bring a jacket to Seattle tomorrow?")
print(response)

Example Queries

The agent can handle natural language questions like:

  • "What's the temperature in Los Angeles?"
  • "Will it rain in Seattle tomorrow?"
  • "Should I bring an umbrella to Chicago this weekend?"
  • "Give me a 5-day forecast for New York"
  • "What's the weather like in Austin compared to Dallas?"
  • "Is it going to be hot in Phoenix next week?"

Weather Data Source

This implementation uses Open-Meteo:

  • ✓ Free, no API key required
  • ✓ ~10,000 calls/day for non-commercial use
  • ✓ Current conditions + 16-day forecasts
  • ✓ Global coverage
  • ✓ Temperature, precipitation, wind, humidity, sunrise/sunset

Extending

Add More Tools

To add new weather-related tools:

  1. Add a function to weather_broker.py to fetch the data
  2. Decorate a new tool function in weather_mcp_server.py with @mcp.tool
  3. Update the agent instructions to describe when to use the new tool

Switch to a Different Weather API

To use a different weather API:

  1. Replace the API calls in weather_broker.py
  2. If the API requires authentication, add secret management
  3. Update app.yaml with any needed environment variables
  4. Keep the same function signatures so the MCP tools don't change

License

This is a learning project for educational purposes.

推荐服务器

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

官方
精选