MCP-Weather-Chatbot

Subitha-Murugesan/MCP-Weather-Chatbot

3.2

If you are the rightful owner of MCP-Weather-Chatbot and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

MCP Weather Chatbot is a Generative AI project that provides real-time weather data and alerts through an MCP server, utilizing the US National Weather Service API.

Tools
2
Resources
0
Prompts
0

MCP Weather Chatbot

MCP Weather Chatbot is a Generative AI project that exposes real-time weather data and alerts as an MCP (Model Context Protocol) server. It demonstrates how to build MCP tools that can be accessed by different clients using both SSE (Server-Sent Events over HTTP) and stdio transport.

The backend integrates with the US National Weather Service (NWS) API to provide accurate, structured weather alerts and forecasts.


Quick Start

Clone the repo and set up the environment using uv:

# Initialize venv
uv venv
source .venv/bin/activate

# Install dependencies
uv add mcp httpx nest_asyncio

Run the MCP Weather server:

uv run server.py

Run a client (stdio or SSE):

uv run client_stdio.py
# or
uv run client_sse.py

Workflow Overview

User -> Client (stdio / SSE) -> MCP Weather Server -> NWS API
  • Weather MCP Server (server.py)

    • Tools:

      • get_alerts(state) → Fetches weather alerts for a given U.S. state
      • get_forecast(lat, lon) → Returns a detailed forecast for a location
    • Supports stdio and SSE (HTTP) transports

    • Runs locally or in Docker

  • Clients

    • client_stdio.py → Connects via stdio
    • client_sse.py → Connects via SSE (http://localhost:8000/sse)

User Experience

  1. Start the server:

    uv run server.py
    
    image
  2. Run the SSE client:

    uv run client_sse.py
    
image
  1. Or run the stdio client:

    uv run client_stdio.py
    
  2. Example interaction:

You: provide me the weather state of NC image


Running with Docker

Build and run the containerized server:

docker build -t mcp-weather .
docker run -p 8000:8000 mcp-weather
image image

This starts the MCP Weather Server with SSE enabled and exposes it on localhost:8000.


Testing the MCP Weather Server

You can test the server in three different ways:

MCP Inspector

uv run mcp dev server/weather.py
image image

Claude Desktop

Install the MCP server:

uv run mcp install server/weather.py
image

Cursor IDE

  1. Open Cursor → Settings → MCP & Integrations
  2. Add a Custom MCP Server
  3. Insert your server config (server/weather.py)
  4. Save → Chat with weather tools directly in Cursor
image