Learn to build a weather MCP server using Open-meteo API for real-time weather data integration
MCP server for getting the current weather in any location using the Open-meteo API.
Read more about Model Context Protocol: https://modelcontextprotocol.io/
The Weather MCP Server is a specialized implementation designed to enable AI applications, particularly those built on the Model Context Protocol (MCP), to easily access and utilize real-time weather data. By leveraging the Open-meteo API, this server acts as an intermediary hub, facilitating seamless connectivity between AI applications and the weather data source. Its primary role is to enhance the functionality of AI applications, such as Claude Desktop, by providing dynamic contextual information that can be incorporated into various workflows.
The Weather MCP Server features a robust architecture based on the Model Context Protocol. This protocol facilitates seamless interaction between MCP clients and data providers through standardized requests and responses. The Weather MCP Server supports key features such as real-time weather updates, geolocation-based queries, and detailed forecast information.
The server adheres to a defined set of API endpoints and request/response structures, ensuring consistency across different AI applications that support MCP. This standardization is crucial for maintaining compatibility and interoperability among various systems and tools integrated with the protocol.
By interfacing with Open-meteo, the Weather MCP Server ensures up-to-date and accurate weather information. The ability to customize queries based on geolocation provides a highly flexible solution that can be tailored to specific use cases within AI applications.
The Weather MCP Server is built using modern Python development practices, employing Flask for its robust routing and request handling capabilities. It leverages the Model Context Protocol's framework, which simplifies integration by providing a clear API surface area and consistent protocol definitions.
graph TD
A[AI Application] -->|MCP Client| B[MPC Protocol]
B --> C[MPC Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD
A[Client] --> B[Server]
B --> C[MPC API]
C --> D[Databases/External Services]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
To set up and run the Weather MCP Server, follow these steps:
Ensure you have Python 3.6 or higher installed on your system. Additionally, you need to install a virtual environment management tool such as uv
.
Create and activate the virtual environment using UV:
uv venv
source .venv/bin/activate
Install the required dependencies by running:
uv sync
Start up the MCP inspector to test the server:
mcp dev server.py
The Weather MCP Server is designed for integration within a wide range of AI applications, particularly those requiring weather context. Here are two practical use cases:
Weather-Driven Content Generation
An AI-driven news platform can use the Weather MCP Server to fetch real-time weather updates and generate localized weather reports. These reports can then be included in the daily news feed or used as a prompt for generating interactive content.
Personalized Weather-Based Prompts
In conversational AI systems, such as chatbots, the Weather MCP Server can provide geolocation-based weather prompts. For example, if a user asks about the weather in New York City, the system can retrieve current temperature and forecast information to enrich the conversation.
The Weather MCP Server is compatible with the following MCP clients:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
The Weather MCP Server has been optimized for efficient data retrieval and processing. It supports multiple API endpoints, ensuring robust performance in diverse usage scenarios.
For advanced configurations, you can customize the server settings by modifying the server.py
file. Key aspects include:
{
"mcpServers": {
"weather": {
"command": "/Users/your-username/.local/bin/uv",
"args": [
"run",
"--with",
"mcp[cli]",
"mcp",
"run",
"/Users/your-username/path/to/weather-mcp-server/server.py"
]
}
}
}
Enable environment variables and secure API keys to protect sensitive information. It is recommended to use a configuration management tool like Ansible or a secrets manager service for handling these settings.
Can the Weather MCP Server be used with multiple MCP clients?
Is there a limit to how many requests can be made per minute?
How often does the data get refreshed?
Are there any compatibility issues with Cursor?
Can I customize the server to support other APIs?
Contributions to the Weather MCP Server are welcomed! To contribute, follow these guidelines:
Fork the repository from GitHub.
Clone your fork locally using git clone https://github.com/your-fork/repo.git
.
Install necessary dependencies and create a virtual environment.
Make your changes and ensure all tests pass before committing.
Submit a pull request detailing your contributions for review.
Learn more about Model Context Protocol by visiting the official documentation and resources at ModelContextProtocol.io.
For additional information on API management, visit the Open-meteo website: https://open-meteo.com/.
By leveraging the Weather MCP Server, developers can enhance their AI applications with real-time weather data, creating more engaging and responsive user experiences.
Explore community contributions to MCP including clients, servers, and projects for seamless integration
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Python MCP client for testing servers avoid message limits and customize with API key
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Powerful GitLab MCP Server enables AI integration for project management, issues, files, and collaboration automation
SingleStore MCP Server for database querying schema description ER diagram generation SSL support and TypeScript safety