shivangbtech/MCP-Weather-API
If you are the rightful owner of MCP-Weather-API and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server written in Java that provides weather data, including current conditions and forecasts, for MCP-enabled clients.
MCP-Weather-API
A Model Context Protocol (MCP) server written in Java that provides weather data (current conditions and forecast) as tools for MCP-enabled clients.
It demonstrates how to implement a custom MCP server in Java that connects to an external weather provider API.
β¨ Features
- Implements MCP server in Java using the reference design.
- Exposes tools like:
get_current_weather
β fetches real-time weather for a location.get_forecast
β retrieves hourly forecast.
- Designed to integrate seamlessly with Claude Desktop, Cursor, Windsurf, or any MCP client.
- Can be configurable via environment variables (
WEATHER_API_KEY
, API URL).
π οΈ Setup
Prerequisites
- Java 17 or above
- Maven (for build)
- A weather provider API key (e.g., AccuWeather or OpenWeatherMap or Weather API)
Clone & Build
git clone https://github.com/shivangbtech/MCP-Weather-API.git
cd MCP-Weather-API
mvn clean package
Run the MCP Server
java -jar target/mcp-weather-api.jar
The server communicates over stdio (default for MCP).
βοΈ Configuration
Set your weather API key (If required):
export WEATHER_API_KEY=your_api_key_here
Optional properties (can go in application.properties or as env vars):
weather.api.key=your_api_key_here
weather.api.base-url=https://api.weatherprovider.com
π MCP Client Integration
Example config for Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"weather": {
"command": "java",
"args": ["-jar", "/path/to/MCP-Weather-API/target/mcp-weather-api.jar"],
"env": {
"WEATHER_API_KEY": "your_api_key_here"
}
}
}
}
Once configured, Claude (or any MCP client) can call:
- get_current_weather β returns location, temperature, humidity, condition.
- get_forecast β returns hourly/daily forecast depending on provider.
π Project Structure
MCP-Weather-API/
βββ src/main/java/... # MCP server + tool implementations
βββ src/test/java/... # Unit tests
βββ pom.xml # Maven dependencies and build config
βββ README.md
π Example Tool Call
Request:
{
"tool": "get_current_weather",
"params": {
"location": "Delhi, IN"
}
}
Response:
{
"location": "Delhi, IN",
"temperature": { "value": 30.5, "unit": "C" },
"condition": "Sunny",
"humidity": 55
}
Prompt
Use below prompts to test:
- Whatβs the weather in Sacramento?
- What are the active weather alerts in Texas?