weatherinfo-mcp
An MCP server that provides access to environmental weather data for AI agents through the National Weather Service (NWS) API, enabling location management, weather observations, alerts, and HeatRisk guidance.
README
WeatherInfoMCP
An MCP (Model Context Protocol) server that provides access to environmental weather data for AI agents through the National Weather Service (NWS) API.
Features
- 🌍 Location Management: Create locations from addresses or coordinates
- 🌤️ Weather Observations: Fetch real-time weather data from NWS stations
- 📊 Data Extraction: Extract specific weather metrics (temperature, humidity, wind, descriptions)
- ⚠️ Weather Alerts: Get active weather alerts for locations
- 🌡️ HeatRisk Guidance: Access HeatRisk information and CDC dashboard links
Usage
Using Directly from GitHub (No Installation Required) ⚡
The easiest way to use WeatherInfoMCP is directly from GitHub without cloning or installing anything locally. This method uses uvx (from the uv package manager) to automatically download, install, and run the MCP server from the repository.
Prerequisites:
- uv must be installed (it provides the
uvxcommand)
How it works:
uvxautomatically creates an isolated environment, installs the package from GitHub, and runs it- No local repository clone needed
- No manual dependency management
- Always uses the latest version from the repository
With OpenAI Agents SDK
from agents import Agent
from agents.mcp import MCPServerStdio
# Configuration for direct GitHub usage
PARAMS_WEATHER_MCP = {
"name": "weatherinfo-mcp",
"command": "uvx",
"args": ["--from", "git+https://github.com/Babakjfard/weatherinfo_mcp.git", "weatherinfo-mcp"]
}
weather_server = MCPServerStdio(params=PARAMS_WEATHER_MCP)
agent = Agent(
name="weather-agent",
model="gpt-4",
mcp_servers=[weather_server]
)
With Claude Desktop
Add this to your Claude Desktop configuration file (typically ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"weatherinfo-mcp": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Babakjfard/weatherinfo_mcp.git", "weatherinfo-mcp"]
}
}
}
Benefits of this approach:
- ✅ Zero setup - no cloning, no installation, no virtual environment management
- ✅ Always up-to-date - uses the latest version from GitHub
- ✅ Isolated -
uvxmanages dependencies in isolated environments - ✅ Portable - works the same way on any system with
uvinstalled
Note: The first run may take a moment as uvx downloads and sets up the package. Subsequent runs are faster due to caching.
As an MCP Server
The package can be used as an MCP server with any MCP-compatible client:
python -m weatherinfo_mcp.mcp_tools.main
Or using the installed script:
weatherinfo-mcp
With AI Agent Frameworks
OpenAI Agents SDK
If the package is installed in editable mode (pip install -e . or uv sync), you can use:
from agents import Agent
from agents.mcp import MCPServerStdio
params = {
"name": "weatherinfo-mcp",
"command": "python",
"args": ["-m", "weatherinfo_mcp.mcp_tools.main"],
# PYTHONPATH not needed if package is installed
}
weather_server = MCPServerStdio(params=params)
agent = Agent(
name="weather-agent",
model="gpt-4",
mcp_servers=[weather_server]
)
If the package is not installed, specify the source directory:
import os
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
params = {
"name": "weatherinfo-mcp",
"command": "python",
"args": ["-m", "weatherinfo_mcp.mcp_tools.main"],
"env": {
"PYTHONPATH": os.path.join(project_root, "src")
}
}
Claude Desktop Configuration
If the package is installed:
{
"mcpServers": {
"weatherinfo-mcp": {
"command": "python",
"args": ["-m", "weatherinfo_mcp.mcp_tools.main"]
}
}
}
If the package is not installed, use the full path to the virtual environment Python and set PYTHONPATH:
{
"mcpServers": {
"weatherinfo-mcp": {
"command": "/full/path/to/project/.venv/bin/python",
"args": ["-m", "weatherinfo_mcp.mcp_tools.main"],
"env": {
"PYTHONPATH": "/full/path/to/weatherinfo_mcp/src"
}
}
}
}
Note: Using the virtual environment Python (/full/path/to/project/.venv/bin/python) ensures all dependencies are available.
Available Tools
The MCP server provides the following tools:
create_location- Create a location object from an address or coordinatesget_current_observation- Fetch current weather observation dataget_temperature_from_observation- Extract temperature value (Celsius)get_humidity_from_observation- Extract relative humidity (%)get_weather_description_from_observation- Extract weather descriptionget_wind_info_from_observation- Extract wind speed and directionget_alerts- Get active weather alerts for a locationget_HeatRisk- Get HeatRisk guidance and CDC dashboard information
Prerequisites
- Python >= 3.12
- uv package manager (recommended) or pip
- Internet connection (for NWS API access)
Installation
Using uv (Recommended)
-
Clone the repository:
git clone <repository-url> weatherinfo_mcp cd weatherinfo_mcp -
Install dependencies and create virtual environment:
uv syncThis will:
- Create a virtual environment in
.venv/ - Install all required dependencies
- Install the package in editable mode
- Create a virtual environment in
-
Activate the virtual environment (optional, but recommended):
source .venv/bin/activate -
Install notebook dependencies (optional, for running example notebooks):
uv pip install -r notebooks/requirements.txt -
Set up Jupyter kernel (for Jupyter notebooks):
# Register the kernel with Jupyter .venv/bin/python -m ipykernel install --user --name=weatherinfo_mcp --display-name="Python (weatherinfo_mcp)"After this, you'll see "Python (weatherinfo_mcp)" in your Jupyter notebook kernel selector.
Using pip
-
Clone and navigate to the project:
git clone <repository-url> weatherinfo_mcp cd weatherinfo_mcp -
Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Install the package:
pip install -e .
Running Tests
The project includes a comprehensive test suite to verify MCP protocol compliance and functionality. Once available, use the following instructions:
Prerequisites for Testing
Install test framework dependencies:
cd tests
make install
This will automatically use uv if available, or fall back to pip.
Alternatively, install manually:
# Using uv (if available)
uv pip install -r requirements-framework.txt
# Or using pip
pip install -r requirements-framework.txt
Running All Tests
cd tests
make test-all
This will run:
- Base MCP protocol conformance tests
- WeatherInfoMCP-specific functionality tests
- MCP Inspector integration tests
Running Specific Test Suites
# Base MCP protocol tests only
make test-base
# WeatherInfoMCP-specific tests only
make test-weatherinfo_mcp
# Session lifecycle tests
make test-lifecycle
# Error handling tests
make test-errors
# Simple stdio test
make test-stdio
# Verbose output
make test-verbose
Test Reports
Test reports are saved to tests/ directory:
comprehensive_conformance_report.txt- Full test resultsbase_conformance_report.txt- Base protocol testsweatherinfo_mcp_conformance_report.txt- Package-specific testssession_lifecycle_report.txt- Session management testserror_handling_report.txt- Error handling tests
Configuration
The package uses the NWS API which is free and requires no API key. The service automatically handles:
- Location geocoding using geopy
- Finding nearest NWS weather stations
- Fetching real-time observations
Development
Project Structure
weatherinfo_mcp/
├── src/
│ └── weatherinfo_mcp/
│ ├── __init__.py
│ ├── core/
│ │ └── nws_location_service.py # Location service
│ └── mcp_tools/
│ ├── main.py # MCP server entry point
│ └── nws_weather_tools.py # MCP tool definitions
├── tests/ # Test suite
│ ├── Makefile # Test runner
│ ├── comprehensive_stdio_tests.py # Comprehensive tests
│ ├── test_nws_location_service.py # Unit tests
│ ├── test_nws_weather_tools.py # Unit tests
│ └── ...
├── notebooks/ # Example notebooks
├── pyproject.toml # Package configuration
├── uv.lock # Dependency lock file
└── README.md # This file
Setting Up Development Environment
- Follow the installation steps above
- Install additional development tools as needed:
# Install common development tools (optional) uv pip install pytest black flake8 mypy # Or pip install pytest black flake8 mypy
Running Individual Unit Tests
# Using pytest
pytest tests/test_nws_location_service.py -v
pytest tests/test_nws_weather_tools.py -v
# Or using Python directly
python -m pytest tests/
Code Quality
# Format code (if black is installed)
black src/
# Lint code (if flake8 is installed)
flake8 src/
Troubleshooting
Virtual Environment Issues
If tests fail with "python: No such file or directory":
- Ensure you've activated the virtual environment:
source .venv/bin/activate - Or the Makefile will automatically detect the venv if present
Module Import Errors
If you get import errors:
# Reinstall the package in editable mode
uv sync
# Or
pip install -e .
Test Failures
If tests fail due to NWS API errors:
- Check your internet connection
- The NWS API may occasionally be unavailable (tests should handle this gracefully)
- Some test failures may be due to temporary API outages, not code issues
License
MIT License - See LICENSE file for details.
Author
Babak J.Fard - babak.jfard@gmail.com
References
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。