mcp -weather
MCP server from yestarz/mcp-server-weather
claude mcp add --transport stdio yestarz-mcp-server-weather java -Dspring.ai.mcp.server.stdio=true -jar mcp-server-weather-0.0.1-SNAPSHOT.jar --weather.api.api-key=YOUR API KEY \ --env HEFENG_WEATHER_API_KEY="Your HeWeather API key"
How to use
This MCP server provides real-time weather information by leveraging the HeWeather (QWeather) API. It exposes a single tool named getWeather that returns current weather conditions for a specified location. The server is implemented in Java and is intended to be started as a standard MCP servicejar. Once running, clients can query the getWeather capability to fetch up-to-date weather data such as temperature, humidity, wind, and more for a given city or region. The server expects an API key for the HeWeather API, provided at startup via the weather.api.api-key parameter.
To use it in an MCP workflow, ensure the server is running with a valid API key, then route weather-related prompts to the getWeather tool. The example integration in the repository demonstrates how LangChain4J can be wired to call the MCP server through an MCP transport and feed the results into higher-level AI assistants.
How to install
Prerequisites:
- Java JDK 11+ installed
- Maven for building the project
- Access to the HeWeather (QWeather) API with a valid API key
Installation steps:
-
Clone the repository: git clone <your-repo-url> cd mcp-server-weather
-
Build the project (skip tests for speed if desired): mvn clean package -Dmaven.test.skip=true
-
Prepare the run configuration:
- Ensure you have a valid API key for HeWeather and set it if needed. You can pass it at runtime as shown in the example (weather.api.api-key).
- Ensure the generated jar exists, typically under target/, e.g., target/mcp-server-weather-0.0.1-SNAPSHOT.jar.
-
Run the server: java -Dspring.ai.mcp.server.stdio=true -jar target/mcp-server-weather-0.0.1-SNAPSHOT.jar --weather.api.api-key=YOUR_API_KEY
replacements:
- Replace YOUR_API_KEY with your actual HeWeather API key.
Additional notes
Notes:
- The server uses the HeWeather API to fetch real-time weather data. Ensure your API key has the necessary permissions and is not expired.
- If you embed the API key in code or config, consider environment variable-based configuration in deployment to avoid leaking keys.
- The example shows a single tool (getWeather). If you extend the server, maintain clear command-line arguments and environment variable handling for reliability.
- When integrating with LangChain4J or similar frameworks, you can adapt the McpClient transport to your preferred orchestration layer. Ensure proper handling of network/IO exceptions since external API calls may fail intermittently.