Get the FREE Ultimate OpenClaw Setup Guide →

mcp-weather

This project is an MCP (Model Context Protocol) server implemented in Java using Spring Boot. It provides real-time weather and stock price data.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio ashishkumarkarn-mcp-weather-server gradlew bootRun \
  --env API_NINJA_KEY="the Ninja API key (set to your_api_key_here)"

How to use

The MCP Weather Server provides real-time weather information along with stock prices fetched via the Ninja API. It exposes Server-Sent Events (SSE) on the /sse endpoint for streaming weather and stock data. To use it, start the server and connect to the SSE endpoint to receive live updates, or use the HTTP endpoint if supported by the running branch configuration. Ensure you set a Ninja API key, as stock prices are retrieved from the Ninja API.

You can switch between the two configurations (main branch with Spring MVC and webflux-transport branch with Spring WebFlux) depending on your desired programming model and performance characteristics. The SSE streaming works similarly across both configurations, with the main difference being the underlying reactive vs. blocking request handling.

How to install

Prerequisites:

  • Java (Java 17+ recommended) and Gradle Wrapper included with the project
  • Git
  • Ninja API key for stock prices
  1. Clone the repository: git clone <repository-url> cd mcp-weather

  2. Configure API key:

    • Environment variable (preferred): export API_NINJA_KEY=your_api_key_here
    • Or in application.properties: api.ninja.key=your_api_key_here
  3. Build and run:

    Build the project (produces necessary artifacts)

    ./gradlew build

    Run the server (uses Gradle wrapper to start Spring Boot app)

    ./gradlew bootRun

  4. Verify the server starts and is listening (default 8081). Access the SSE endpoint at http://localhost:8081/sse or use the appropriate URL for the branch you are running.

Additional notes

Notes and tips:

  • The server exposes SSE at /sse for streaming updates. Ensure your client supports EventSource or equivalent streaming.
  • Bank on the environment variable API_NINJA_KEY or application.properties/api.ninja.key for stock price data from Ninja API.
  • Ports: defaults to 8081 unless changed in configuration; you can customize by editing application.properties or the Spring Boot config.
  • There are two branches with different configurations: main (Spring MVC) and webflux-transport (Spring WebFlux). Choose based on your needs for synchronous vs. reactive handling.
  • If you encounter a 401/403 from Ninja API, double-check your API key and its permissions.

Related MCP Servers

Sponsor this space

Reach thousands of developers