Java MCP weather server integrates with Claude to provide real-time weather data using wttr.in API
The MCP Weather Server is a sophisticated, open-source implementation leveraging the Model Context Protocol (MCP) to deliver real-time weather data to various AI applications and agents like Claude Desktop. By adhering to the standardized protocol, this server ensures seamless integration with diverse tools, making it an indispensable resource for developers aiming to enhance their AI workflows with dynamic and context-aware information.
The MCP Weather Server is designed to offer a robust platform for fetching weather data. Key features include:
This project also includes necessary dependencies to facilitate communication over the MCP protocol, ensuring data interoperability between the server and client components.
At its core, the MCP Weather Server utilizes Spring framework libraries tailored for creating MCP servers. These include:
The architecture leverages these components to establish a robust, standards-compliant environment where weather data can be requested over STDIO transport mode. This ensures that any compliant client can query the server efficiently and receive accurate, up-to-date information.
To get started with running this server on your local machine, follow these detailed steps:
Clone the Repository:
git clone https://github.com/chrischiedo/weather-mcp-server-java.git
cd weather-mcp-server-java
Build the Project: Use Maven to package the application into a JAR file.
./mvnw clean install -DskipTests
This command compiles the sources and packages them neatly into target/weather-mcp-server-0.0.1-SNAPSHOT.jar
.
Run Tests:
./mvnw test
Start the Server: Execute the JAR file.
java -jar target/weather-mcp-server-0.0.1-SNAPSHOT.jar
These steps ensure that you have all necessary dependencies and configurations to run the server effectively.
Incorporate this MCP Weather Server into a business intelligence system where real-time weather updates can trigger automatic responses. For instance, if the temperature drops below freezing, the system could automatically notify field workers or adjust logistics schedules to avoid delays due to harsh weather.
Integrate the server with personal assistants like Claude Desktop for providing context-aware advice. A user might ask, "What should I wear today?" and the assistant can query the server for local weather conditions before suggesting appropriate clothing based on the forecast.
The MCP Weather Server is designed to work seamlessly with several popular AI clients:
Claude Desktop: Fully supports all core functionalities including resources, tools, and prompts.
{
"mcpServers": {
"mcp-weather-server": {
"command": "java",
"args": [
"-Dspring.ai.mcp.server.stdio=true",
"-jar",
"/absolute/path/to/weather-mcp-server-0.0.1-SNAPSHOT.jar"
]
}
}
}
graph TD
A[AI Application/Claude Desktop] -->|MCP Client| B[MCP Server]
B --> C[Weather Data/Tool]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
The diagram illustrates the flow of data from an AI application to MCP servers and ultimately to weather tools, demonstrating efficient connectivity within the protocol.
Compatibility matrix for various clients:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ❌ | ✅ | ❌ |
This matrix highlights the current status and compatibility levels across different AI clients, ensuring users can make informed decisions based on their specific needs.
To configure the MCP Weather Server for advanced use cases and security:
API_KEY
to securely manage access keys.
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
This configuration allows for secure and controlled interactions between the server and external tools.
The server can be configured using any modern JDK, but specifically targeting version 17 ensures compatibility with latest MCP standards. Other versions may introduce incompatibilities or performance issues.
Yes, you can replace the current wttr.in API with another weather service provider by modifying the implementation code within the server.
The server adheres to standard data handling practices, ensuring that only public APIs are used and all interactions are logged securely. Specific measures include secure storage of environment variables and encrypted communication channels.
The server implements retry mechanisms for failed requests. Upon failure, it logs the error and retries after a configurable delay period.
The server queries the API every 10 minutes by default, providing relatively fresh data while conserving resources.
Contributions are welcome from the developer community. For getting started:
For further exploration, consider these additional resources:
By following these guidelines and integrating the MCP Weather Server, developers can significantly enhance their AI applications' capability to fetch real-time data seamlessly.
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization
Connects n8n workflows to MCP servers for AI tool integration and data access
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases