Weather MCP Server
This is a Model Context Protocol (MCP) server that provides weather information using the National Weather Service (NWS) API.
Features
- Get weather alerts for a US state
- Get weather forecast for a specific location (using latitude and longitude)
Requirements
- Python 3.10+
- FastMCP
- httpx
Installation
- Clone this repository
- Set up a virtual environment:
- Install the required packages using uv:
Configuration
The server uses a configuration file config.py
with the following settings:
NWS_API_BASE
: The base URL for the National Weather Service APIUSER_AGENT
: The User-Agent string used when making requests to the NWS APILOG_LEVEL
: The logging level (e.g., "INFO", "DEBUG")LOG_FORMAT
: The format string for log messagesREQUEST_TIMEOUT
: The timeout for API requests in seconds
You can modify these settings in the config.py
file to customize the server behavior.
Usage
Running the server standalone
To run the server standalone:
- Activate the virtual environment if not already activated:
- Run the server:
Using with Cline
The Weather MCP Server has been added to the Cline configuration. To use it within Cline:
- Ensure that Cline is properly set up and running.
- The Weather MCP Server will be available as a tool named "weather".
- You can use the following tools within Cline:a.
get_alerts(state: str)
: Get weather alerts for a US state (use two-letter state code, e.g., "CA" for California) b.get_forecast(latitude: float, longitude: float)
: Get weather forecast for a specific location
Example usage in Cline:
Note: The exact syntax for calling MCP tools may vary depending on your Cline setup. Refer to Cline documentation for the most up-to-date usage instructions.
Error Handling and Logging
The server includes improved error handling for API requests and logging. If an error occurs during a request, the server will log the error and return an appropriate error message. Logs are printed to the console with the configured log level and format.
Testing
Unit Tests
To run the unit tests:
These tests cover the basic functionality of the get_alerts
and get_forecast
tools.
Manual Testing
To manually test the server, you can use the MCP client to call the provided tools. Here are some example commands:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is open source and available under the MIT License.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
这是一个模型上下文协议 (MCP) 服务器,使用国家气象局 (NWS) API 提供天气信息。
功能获取美国某个州的天气警报获取特定位置的天气预报(使用纬度和经度)
Related Resources
Related MCP Servers
- -securityFlicense-qualityThis SSE-based MCP server allows users to connect and interact with National Weather Service APIs to retrieve weather alerts and forecasts.Last updated -296
- AsecurityAlicenseAqualityA Model Context Protocol server that provides tools to fetch weather alerts for US states and forecasts based on latitude/longitude coordinates using the US National Weather Service API.Last updated -256MIT License
- -securityFlicense-qualityAn MCP server that provides weather information like forecasts and alerts for US locations using the National Weather Service API.Last updated -2
- AsecurityFlicenseAqualityAn MCP server that provides weather information and alerts for US locations using the National Weather Service API, enabling retrieval of weather forecasts and active weather alerts.Last updated -2