MCP Weather Sample

mcp 學習樣本
  • python

3

GitHub Stars

python

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs

MCP Weather Sample demonstrates how to build a complete client–server setup that integrates NOAA weather data with multiple AI models, using two transport modes (STDIO and SSE) for flexible deployment. You can query real-time weather alerts and forecasts while leveraging models like Claude, GPT, and Gemini through a unified MCP workflow.

How to use

You connect a client to a hosted MCP server and issue natural language queries about weather. The system routes your requests through an AI model provider of your choice, then retrieves weather data from NOAA to enrich the response. Use either STDIO for local runs or SSE for remote connections. When you start the servers, you can explore weather alerts and forecasts by asking natural questions such as which states have alerts or what the forecast looks like for a given area.

How to install

Prerequisites: You need Python 3.12 or higher and a package manager such as UV (recommended) or pip. You also require valid API keys for NOAA Weather data and one or more AI model providers (Anthropic, OpenAI, or Google).

Install steps are shown below. Run each command in its own line in your terminal.

  1. Clone the project and navigate into the project directory.
git clone <repository-url>
cd mcp-sample

Configuration and server setup

Configure the MCP servers by editing the provided configuration to specify how you want to connect. You will have an SSE server endpoint for remote consumption and a local STDIO server for development and testing.

The following configuration enables both an SSE server and a local STDIO server. Use this as a starting point and adjust as needed.

{
  "mcpServers": {
    "sse_weather": {
      "type": "http",
      "name": "sse_weather",
      "url": "http://localhost:8080/sse",
      "accessToken": "your_access_token",
      "args": []
    },
    "stdio_weather": {
      "type": "stdio",
      "name": "stdio_weather",
      "command": "uv",
      "args": ["run", "python", "weather.py"],
      "cwd": "src/servers/weather/stdio"
    }
  }
}

Running the servers and querying weather

Start the SSE weather server in one terminal, then run the MCP client in another terminal. Once both are running, you can send queries to retrieve weather alerts and forecasts.

Start the SSE weather server:

uv run src/servers/weather/sse/mcp-weather.py

Start the MCP client in a separate terminal:

uv run src/client/client.py

Basic weather query example you can try after both servers are running. You will see a prompt and can type your queries, such as asking whether a state has weather alerts or requesting a detailed forecast for a location.

Advanced usage and tools

Access the built-in tools to fetch weather data and alerts. The available tools include get_alerts to retrieve state-wide weather alerts and get_forecast to obtain detailed forecasts for a given location.

Security and access control

SSE mode supports multiple authentication methods: HTTP header x-api-key, Bearer token Authorization: Bearer <token>, and query parameter api_key=<key>. Manage access using the API keys you provision for your AI models and weather service.

Notes

Configuration can be extended with per-server tool permissions and additional environment variables as needed. Ensure you store your API keys securely and rotate them according to your security policy.

Available tools

get_alerts

Retrieve weather alerts for a given US state, including alert type and affected regions.

get_forecast

Fetch detailed weather forecast for specified coordinates, including temperature, humidity, wind, and precipitation data.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational