Weather MCP Server

Weather MCP Server

Provides real-time weather forecasts and alerts for US locations using the National Weather Service API. Supports querying forecasts by coordinates and retrieving active weather alerts by state.

Category
访问服务器

README

Weather MCP Server

A Model Context Protocol (MCP) server that provides weather information using the National Weather Service API. This server exposes tools for getting weather forecasts and alerts for US locations.

Features

  • 🌤️ Weather Forecasts: Get detailed weather forecasts for any US location using latitude/longitude coordinates
  • 🚨 Weather Alerts: Retrieve active weather alerts for any US state
  • 🔌 MCP Integration: Works seamlessly with Claude for Desktop and other MCP-compatible clients
  • 📡 Real-time Data: Fetches live data from the National Weather Service API

Tools Available

get-forecast

Get weather forecast for a specific location.

Parameters:

  • latitude (float): Latitude of the location (-90 to 90)
  • longitude (float): Longitude of the location (-180 to 180)

Example usage:

  • "What's the weather forecast for San Francisco?" (Claude will use coordinates ~37.7749, -122.4194)
  • "Give me the weather forecast for latitude 47.6062, longitude -122.3321" (Seattle)

get-alerts

Get active weather alerts for a US state.

Parameters:

  • state (string): Two-letter US state code (e.g., "CA", "NY", "TX")

Example usage:

  • "What are the active weather alerts in California?"
  • "Are there any weather warnings in Texas?"

Prerequisites

  • Python 3.10 or higher
  • uv package manager
  • Access to the internet (for NWS API calls)

Installation

  1. Install uv (if not already installed):

    # macOS/Linux
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # Windows
    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
    
  2. Clone or navigate to the project directory:

    cd weather
    
  3. Install dependencies:

    uv sync
    

Running the Server

Standalone Testing

To test the server directly:

uv run weather.py

The server will start and listen on standard input/output. You can test it using the MCP inspector or other MCP clients.

With Claude for Desktop

  1. Install Claude for Desktop from claude.ai/download

  2. Configure Claude for Desktop by editing the configuration file:

    macOS/Linux:

    code ~/Library/Application\ Support/Claude/claude_desktop_config.json
    

    Windows:

    code $env:AppData\Claude\claude_desktop_config.json
    
  3. Add the weather server configuration:

    macOS/Linux:

    {
      "mcpServers": {
        "weather": {
          "command": "uv",
          "args": [
            "--directory",
            "/ABSOLUTE/PATH/TO/YOUR/weather",
            "run",
            "weather.py"
          ]
        }
      }
    }
    

    Windows:

    {
      "mcpServers": {
        "weather": {
          "command": "uv",
          "args": [
            "--directory",
            "C:\\ABSOLUTE\\PATH\\TO\\YOUR\\weather",
            "run",
            "weather.py"
          ]
        }
      }
    }
    
  4. Restart Claude for Desktop completely

  5. Verify the integration by looking for the "Search and tools" icon in Claude for Desktop

Usage Examples

Once configured with Claude for Desktop, you can ask questions like:

  • "What's the weather forecast for Sacramento?"
  • "Give me the weather forecast for New York City"
  • "What are the active weather alerts in Florida?"
  • "Are there any severe weather warnings in Texas?"
  • "What's the weather like at coordinates 40.7128, -74.0060?" (NYC)

API Details

This server uses the National Weather Service API (api.weather.gov), which:

  • Provides free access to US weather data
  • Requires no API key
  • Returns data in JSON format
  • Only covers US locations

Project Structure

weather/
├── main.py          # Entry point (if needed)
├── weather.py       # Main MCP server implementation
├── pyproject.toml   # Project configuration and dependencies
├── uv.lock         # Dependency lock file
└── README.md       # This file

Troubleshooting

Server Not Showing Up in Claude

  1. Check the configuration file syntax - Ensure valid JSON

  2. Verify the absolute path - Use full paths, not relative ones

  3. Check Claude's logs:

    # macOS/Linux
    tail -f ~/Library/Logs/Claude/mcp*.log
    
    # Windows
    # Check logs in %AppData%\Claude\logs\
    
  4. Restart Claude for Desktop completely

Tool Calls Failing

  1. Verify the server runs standalone:
    uv run weather.py
    
  2. Check for rate limiting - The NWS API has rate limits
  3. Ensure coordinates are for US locations - The NWS API only covers the US
  4. Check internet connectivity - Server needs to reach api.weather.gov

Common Error Messages

  • "Failed to retrieve grid point data": Usually means coordinates are outside the US
  • "No active alerts for this state": Not an error - just means no current alerts
  • "Unable to fetch forecast data": Network issue or invalid coordinates

Development

Adding New Tools

To add new weather-related tools:

  1. Add the tool using the @mcp.tool() decorator
  2. Implement the async function with proper type hints
  3. Add error handling and validation
  4. Test with uv run weather.py

Dependencies

Key dependencies (managed by uv):

  • mcp: Model Context Protocol SDK
  • httpx: HTTP client for API requests
  • fastmcp: Simplified MCP server framework

License

This project is part of the Model Context Protocol ecosystem. Check individual dependencies for their licenses.

Contributing

Feel free to submit issues and pull requests to improve the weather server functionality.

Related Resources

推荐服务器

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

官方
精选