Learn how to create an MCP weather server for alerts and forecasts using Python and NWS API
The Weather MCP Server is a learning project designed to explore and implement the Model Context Protocol (MCP) for integrating external data sources into artificial intelligence applications. Specifically, this server utilizes the National Weather Service (NWS) API to provide weather alerts and forecasts, allowing AI assistants like Claude Desktop, Continue, Cursor, and others to access real-time and forecasted weather information through a standardized protocol.
The Weather MCP Server offers two key capabilities:
get_alerts
: Retrieve active weather alerts for any US state.get_forecast
: Obtain weather forecasts based on specific location coordinates (latitude and longitude).These features enable AI applications to provide contextually relevant and timely weather information, enhancing user experience and utility.
MCP is designed to facilitate the interaction between AI assistants and external tools or data sources. The Weather MCP Server uses Python with libraries such as httpx
for HTTP requests and the mcp
library to adhere to the protocol standards. This implementation ensures compatibility across various MCP clients, including Claude Desktop, Continue, and Cursor.
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[MCP Data Source/Tool]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
This diagram illustrates the interaction between an AI application, the MCP Client, the Weather MCP Server, and external weather data sources.
To set up and run the Weather MCP Server:
Clone the Repository:
git clone https://github.com/user/repo.git
cd repo
Install Dependencies:
pip install mcp httpx
# or use uv:
uv pip install mcp httpx
Configure MCP Server in Your AI Assistant:
Add the following configuration to the Claude Desktop settings:
{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"weather.py"
]
}
}
}
Go to Cursor Settings -> MCP Servers -> Add MCP Server:
The Weather MCP Server is compatible with multiple MCP clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
This table outlines the current status of integration for different MCP clients, highlighting areas where additional development may be required.
To secure and configure the Weather MCP Server:
graph TD
A[Data Source] --> B[Weather Data API]
B --> C[MCP Server]
C --> D[AI Application Backend]
This diagram visualizes the data flow from external sources, through the Weather MCP Server, and into the AI application backend for processing.
.env
files or system-specific configuration methods like os.environ
.Contributions are welcome! If you wish to contribute, please follow these guidelines:
For more information on MCP and related resources, visit:
Join the community to stay updated on developments and participate in discussions about MCP and its applications.
This comprehensive technical documentation highlights the Weather MCP Server's capabilities, integration with various AI clients, performance, security considerations, and real-world use cases. It positions this project as a valuable resource for developers looking to enhance their AI applications with MCP-compliant servers.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration