MCP-Weather-API

shivangbtech/MCP-Weather-API

3.2

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.

Tools
2
Resources
0
Prompts
0

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

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?