🌩️ MCP Weather Alerts Tool using FastMCP + Claude Desktop

by nahilahmed

342 downloads
Not rated
GitHub

About

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.

Details

Author
nahilahmed
Downloads
342
Categories
Media

- Implements a custom MCP server with FastMCP Python SDK
- Uses httpx to call real-time weather alerts from api.weather.gov
- Returns structured information: event, severity, description, and instructions
- Integrates directly with Claude Desktop as an MCP tool
- Testable interactively via MCP Inspector

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name 🌩️ MCP Weather Alerts Tool using FastMCP + Claude Desktop
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install dependencies using uv add "mcp[cli]" httpx and place the weather.py tool in a server/ folder. Launch interactively with uv run mcp dev server/weather.py and test via MCP Inspector at http://localhost:6757. For Claude Desktop, add a weather entry to claude_desktop_config.json pointing to uv run mcp run <path>/server/weather.py, restart the app, and ask for alerts by state (e.g., β€œWhat are the weather alerts for Texas?”).

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "\ud83c\udf29\ufe0f mcp weather alerts tool using fastmcp + claude desktop": {
            "mcp-weather-alert-tool": {
                "command": "uv",
                "args": [
                    "init",
                    "mcpcrashcourse",
                    "#",
                    "start",
                    "new",
                    "project"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-weather-alert-tool": {
        "command": "uv",
        "args": [
            "init",
            "mcpcrashcourse",
            "#",
            "start",
            "new",
            "project"
        ]
    }
}

🌩️ 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/Library | Purpose |
|--------------|---------|
| mcp[cli] | MCP server toolkit with CLI tools |
| httpx | Async HTTP client |
| uv | Modern Python package/dependency manager |
| Claude Desktop | AI interface for LLM + MCP |
| MCP Inspector | UI 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"
      ]
    }
  }
}

2. Restart Claude Desktop
3. 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:
| Type | Use Case | Analogy |
|----------|-----------------------|-------------------|
| Tools | Execute functions | POST endpoint |
| Resources| Provide static data | GET endpoint |
| Prompts | Reusable interactions | LLM templates |

---

πŸ“Ž Credits

- FastMCP Python SDK
- api.weather.gov
- Claude Desktop
- Project structure based on examples from the official MCP docs

---

πŸ“„ License

This project is open-sourced under the MIT License.

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.