Sponsored by Deepsite.site

🌩️ MCP Weather Alerts Tool using FastMCP + Claude Desktop

Created By
nahilahmed7 months ago
A Python MCP (Model Context Protocol) server that fetches real-time weather alerts by U.S. state using api.weather.gov, built with FastMCP and integrated into Claude Desktop.
Content

🌩️ MCP Weather Alerts Tool using FastMCP + Claude Desktop

This project demonstrates how to build an MCP (Model Context Protocol) tool using the official FastMCP Python SDK. It integrates with Claude Desktop to enable an AI assistant to retrieve weather alerts by U.S. state via the api.weather.gov API.


🚀 What This Project Does

  • ✅ Implements a custom MCP server with FastMCP
  • 🌐 Uses httpx to call real-time weather alerts from api.weather.gov
  • 📦 Returns structured information: event, severity, description, and instructions
  • 🧠 Integrates with Claude Desktop
  • 🌈 Can be tested interactively via MCP Inspector

🧱 Tech Stack

Tool/LibraryPurpose
mcp[cli]MCP server toolkit with CLI tools
httpxAsync HTTP client
uvModern Python package/dependency manager
Claude DesktopAI interface for LLM + MCP
MCP InspectorUI to debug MCP endpoints

📁 Project Structure

mcpcrashcourse/
├── server/
│   └── weather.py         # MCP server logic (get_alerts)
├── pyproject.toml         # Project metadata + dependencies
├── uv.lock                # Locked versions (auto-generated by uv)
└── README.md              # You're reading it!

🧠 Tool Logic: get_alerts

@mcp.tool()
async def get_alerts(state: str) -> list[dict]:
    # Fetch weather alerts for a given U.S. state (e.g., 'CA')
    url = "https://api.weather.gov/alerts/active"
    params = {"area": state.upper()}
    async with httpx.AsyncClient() as client:
        response = await client.get(url, params=params)
        data = response.json()

    return [
        {
            "event": alert.get("event"),
            "severity": alert.get("severity"),
            "description": alert.get("description"),
            "instruction": alert.get("instruction"),
        }
        for alert in data.get("features", [])
        if alert.get("properties")
    ]

🛠️ Installation & Setup

1. Create & Configure Project

pipx install uv               # install uv if you haven't
uv init mcpcrashcourse        # start new project
cd mcpcrashcourse
uv add "mcp[cli]" httpx       # add dependencies

2. Add Your Tool

Place your weather.py in the server/ folder, containing the logic for get_alerts.


🧪 Run & Inspect

Launch with MCP Inspector

uv run mcp dev server/weather.py

Then open http://localhost:6757 to:

  • View your get_alerts tool
  • Try calling it with input like "TX"

🤖 Claude Desktop Integration

  1. Update your claude_desktop_config.json:
{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "<your-project-directory>/server/weather.py"
      ]
    }
  }
}
  1. Restart Claude Desktop
  2. Prompt:

    "What are the weather alerts for Texas?"

Claude will call your MCP tool and display structured output.


💡 What is MCP?

The Model Context Protocol standardizes how apps send context (data, tools, prompts) to LLMs. It separates the "context provider" from the LLM layer.

Three core primitives:

TypeUse CaseAnalogy
ToolsExecute functionsPOST endpoint
ResourcesProvide static dataGET endpoint
PromptsReusable interactionsLLM templates

📎 Credits


📄 License

This project is open-sourced under the MIT License.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
DeepChatYour AI Partner on Desktop
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
Serper MCP ServerA Serper MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
CursorThe AI Code Editor
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
WindsurfThe new purpose-built IDE to harness magic
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp