Python weather service with forecasts alerts and city lookup via NWS API
The Weather Service MCP Server is a Python-based solution built on the Model Context Protocol (MCP) that provides weather forecasts and alerts by leveraging data from the National Weather Service (NWS) API. This server, through its implementation as an MCP server using FastMCP, offers a robust interface for AI applications, enabling them to connect directly to real-time weather information sources with minimal effort. The server's clean tool endpoints allow for seamless integration into MCP-compatible applications like Claude Desktop, Continue, Cursor, and others.
The Weather Service MCP Server includes several core features that cater to various scenarios of weather data access and management:
get_weather_by_city
tool to obtain detailed weather forecasts for a specific US city and state.get_forecast
tool.get_alerts
tool provides current active weather alerts for any US state, ensuring users are informed about ongoing weather events that may impact their activities.get_coordinates
tool.The Weather Service MCP Server is designed to implement the Model Context Protocol (MCP) over stdio, enabling it to act as an adapter layer for AI applications. By adhering to the standards defined by MCP, this server can be easily integrated into MCP-compatible environments without requiring custom configuration or adjustments.
The architecture of the Weather Service MCP Server is centered around the following components:
MCP Client Compatibility: The server supports integration with AI applications like Claude Desktop, Continue, Cursor. However, some tools might not be fully compatible. For instance, while Cursor provides tool support, it does not include support for prompts.
Data Source Integration: Data from the NWS API is aggregated and presented via well-defined MCP tools, ensuring consistent data access patterns.
Error Handling & Logging: The server implements robust error handling and logging mechanisms to ensure smooth operation even under unexpected conditions. Logs are crucial for debugging and understanding the operational state of the service.
To get started with the Weather Service MCP Server, follow these steps:
pip install -r requirements.txt
.python -m weather_service
.In emergency management contexts, real-time access to weather data is critical. The Weather Service MCP Server can be integrated into an infrastructure that continuously monitors and alerts stakeholders based on active weather conditions. For example, a disaster response application using the get_alerts
tool to notify teams about imminent severe weather events.
For infrastructure planning, understanding future weather patterns is key to ensuring safety and operational efficiency. An AI system could integrate with the get_weather_by_city
and get_forecast
tools to predict upcoming weather conditions and proactively plan maintenance activities.
The Weather Service MCP Server ensures compatibility with multiple MCP clients, including:
Integration involves using the provided environment variables and command-line arguments to establish a connection between the server and the desired client application. This setup ensures that AI applications can interact with real-time weather data effectively.
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✔️ | ✔️ | ✔️ |
Continue | ✔️ | ✔️ | ✔️ |
Cursor | ❌ | ✔️ | ❌ |
Advanced users can customize the server by modifying configuration settings in the provided JSON format below. Additionally, security measures such as API key management and authentication should be implemented to protect sensitive data.
{
"mcpServers": {
"weather-service-server": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-weather-service"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
A1: While the current implementation focuses on US weather data, it can potentially be adapted to include other regions with appropriate changes and access rights.
A2: The server implements sophisticated error handling through comprehensive logging. Errors are logged and can be monitored for troubleshooting purposes.
A3: Compatible applications include Claude Desktop, Continue, and Cursor. Cursor has limited tool support but provides full access to resources.
A4: Geocoding is performed using OpenStreetMap’s Nominatim API within the server environment to convert city names into latitude-longitude coordinates.
A5: The current implementation does not enforce request limits, but users should monitor usage patterns to avoid overloading the service or any external data sources.
Contributions to the Weather Service MCP Server are welcome. Interested developers can contribute by submitting pull requests or opening issues on GitHub. For more information, refer to the contributing guidelines provided in the repository.
Explore the broader Model Context Protocol ecosystem and resources at the official MCP website. Additional tools and services built using MCP can be discovered through the MCP community forums and documentation.
By leveraging the Weather Service MCP Server, AI developers can enhance their applications with real-time weather data, enabling more intelligent decision-making processes across various industries.
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