A Model Context Protocol (MCP) implementation that exposes weather alerts from the National Weather Service API as tools. Includes an interactive chat client powered by Groq LLM and test scripts for both STDIO and SSE transports.
- Python 3.13+ (see pyproject.toml)
- uv – Python package manager (install)
- Groq API Key – for the LLM (get one)
-
Clone or navigate to the project:
cd /path/to/MCP -
Create a
.envfile with your Groq API key:GROQ_API_KEY=your_groq_api_key_here -
Install dependencies with uv:
uv sync
This creates a
.venvand installs all dependencies frompyproject.toml. The project useslangchain>=1.2.0,<2.0.0for compatibility with mcp-use.
| File | Purpose |
|---|---|
server/weather_mcp.json |
Default config for stdio: spawns uv run server/weather.py |
server/weather_stdio_config.json |
Same as above; used by stdio test script |
server/weather_sse_config.json |
SSE config: connects to http://127.0.0.1:8000/sse |
STDIO (command-based):
{
"mcpServers": {
"weather": {
"command": "uv",
"args": ["run", "server/weather.py"]
}
}
}SSE (URL-based):
{
"mcpServers": {
"weather": {
"url": "http://127.0.0.1:8000/sse"
}
}
}All commands use uv run to execute scripts with the project's virtual environment and dependencies.
Run an interactive chat that connects to the weather MCP server. The agent can call get_alerts when you ask about weather.
Run:
uv run client_chatbot.pyCommands:
- Type any question (e.g., "What are the weather alerts for California?")
exitorquit– end the sessionclear– clear conversation history
What happens:
- Client reads
server/weather_mcp.json - Spawns
uv run server/weather.pyas a subprocess - Communicates via stdin/stdout (stdio transport)
- Agent uses Groq LLM and calls
get_alertswhen needed
Explicit test of the stdio transport. Same behavior as Case 2 but uses a dedicated config file.
Run:
uv run test_weather_stdio.pyWhat happens:
- Uses
server/weather_stdio_config.json - Client spawns
uv run server/weather.py - Runs one query and exits
Test the SSE (HTTP) transport. The script starts the server in HTTP mode, connects via URL, runs a query, then shuts down the server.
Run:
uv run test_weather_sse.pyWhat happens:
- Starts
server/weather_sse.pyin the background (listens on port 8000) - Waits for the server to be ready
- Connects to
http://127.0.0.1:8000/sse - Runs one query
- Terminates the server process
Run the weather server as a standalone HTTP process. Useful for debugging or when multiple clients need to connect.
Run:
# Terminal 1: Start the server
uv run server/weather_sse.pyThen in another terminal, use a client configured with url: "http://127.0.0.1:8000/sse" (e.g., test_weather_sse.py or a custom client with weather_sse_config.json).
Running the stdio server directly is rarely useful because it expects JSON-RPC on stdin. It's normally spawned by the client.
For debugging:
uv run server/weather.py
# Server waits for stdin; won't do anything useful without a clientMCP/
├── README.md # This file
├── .env # GroQ API key (create this)
├── pyproject.toml # Project dependencies
├── client_chatbot.py # Interactive chat client (stdio)
├── test_weather.py # Quick one-shot test (stdio)
├── test_weather_stdio.py # STDIO transport test
├── test_weather_sse.py # SSE transport test
├── server/
│ ├── weather.py # MCP server (STDIO transport)
│ ├── weather_sse.py # MCP server (SSE transport)
│ ├── weather_mcp.json # Default client config (stdio)
│ ├── weather_stdio_config.json
│ └── weather_sse_config.json
└── src/
└── app_mcp/
└── __init__.py # Package init
| Tool | Description | Args |
|---|---|---|
get_alerts |
Get active weather alerts for a US state | state (e.g., "CA", "NY") |
| URI | Description |
|---|---|
echo://{message} |
Echo a message (for testing) |
Run uv sync to install dependencies, then use uv run for all scripts:
uv sync
uv run client_chatbot.pyDependencies are in pyproject.toml. Run uv sync to install.
The project uses llama-3.3-70b-versatile. If you see references to qwen-qwq-32b, update the model in the client/test scripts.
Avoid printing to stdout from code that runs in the MCP server process. Stdio uses stdin/stdout for JSON-RPC; any extra output breaks the protocol.
Stop the process using port 8000, or change the port in server/weather_sse.py:
mcp = FastMCP("weather", host="127.0.0.1", port=8001)Then update SSE_SERVER_PORT in test_weather_sse.py and the URL in weather_sse_config.json.
Run with full permissions if you see "Operation not permitted" for uv cache:
uv run client_chatbot.py # may need to run outside sandbox