home / mcp / weather mcp server

Weather MCP Server

Provides weather alerts and forecasts by exposing MCP tools get_alerts and get_forecast for real-time data.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "aitiwari-weather": {
      "command": "uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
        "run",
        "weather.py"
      ]
    }
  }
}

Model Context Protocol (MCP) servers let you connect AI agents with real-time data sources and tools. This weather MCP server exposes two practical tools—get_alerts and get_forecast—that fetch data from the National Weather Service to keep AI assistants aware of current weather conditions and alerts.

How to use

You use this server by connecting an MCP client capable of discovering and invoking MCP tools. The weather server provides two tools: get_alerts for active weather alerts in a US state, and get_forecast for a forecast at a specific location.

Typical usage patterns include asking your MCP-enabled AI to fetch current alerts for a state like Texas or to retrieve a 5-period forecast for a given city. The client will detect the two tools and execute them through the MCP server, returning readable results you can present in a natural-language response.

How to install

Prerequisites: you should have Python installed and a working MCP-capable environment. You will manage the server using the uv tool.

Step 1: Install uv `` powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ` macOS/Linux: ` curl -LsSf https://astral.sh/uv/install.sh | sh ` Restart your terminal to ensure the uv` command is recognized.

Step 2: Create and set up the project Windows/PowerShell: `` uv init weather cd weather uv venv .venv\Scripts\activate uv add mcp[cli] httpx # Create our server file new-item weather.py ` macOS/Linux: ` uv init weather cd weather uv venv source .venv/bin/activate uv add "mcp[cli]" httpx # Create our server file touch weather.py ` Step 3: Build the server file Add the weather server code exactly as shown in the example to weather.py` (see code block in the next section). Then you are ready to run the server.

Running the server

uv run weather.py

Testing with Claude for Desktop

Configure Claude to load MCP servers by editing the MCP server configuration. The example uses the following configuration to run the weather server via the uv runtime.

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

Test with Commands

Verify the MCP tools are detected by looking for the hammer icon in Claude for Desktop. Then test with natural language prompts like: - What’s the weather in Sacramento? - What are the active weather alerts in Texas?

What’s Happening Under the Hood

The client sends your question to Claude. Claude selects the available MCP tools, which your server implements. The MCP server executes the chosen tool(s) and returns results. Claude then composes a natural-language response for you.

Troubleshooting

If you run into issues, check logs at points like mcp.log for general MCP activity and mcp-server-weather.log for server-specific errors. Common steps include verifying the server starts without errors, restarting Claude for Desktop, and ensuring the project path used in the configuration is absolute.

MCP Inspector

You can inspect MCP integration with the following command to verify the server is running and the tools are exposed:

```
npx @modelcontextprotocol/inspector uv run weather.py

Available tools

get_alerts

Fetch active weather alerts for a US state using the National Weather Service API, returning readable alert details.

get_forecast

Fetch a weather forecast for a specific latitude/longitude by first querying the NWS points endpoint to locate the forecast, then returning a readable set of upcoming periods.

Weather MCP Server - aitiwari/weather