Sponsored by Deepsite.site

Weather MCP Server

Created By
devlibx8 months ago
Content

Weather MCP Server

A Spring Boot application that provides weather information through the Model Context Protocol (MCP). This project demonstrates how to create an MCP server using Spring AI to expose weather data as a tool that can be used by AI assistants.

📋 Table of Contents

🔍 Overview

This project implements a weather service that provides mock weather data for different locations. It exposes this functionality through the Model Context Protocol (MCP), allowing AI assistants to retrieve weather information for specified locations.

✨ Features

  • Get current weather information for any location
  • Mock weather data generation with realistic parameters
  • MCP integration for AI assistant compatibility
  • Spring Boot application with easy setup and configuration

🛠️ Technologies

  • Java 17
  • Spring Boot 3.2.0
  • Spring AI MCP Server
  • Maven
  • Lombok

📁 Project Structure

src/
├── main/
│   ├── java/
│   │   └── com/
│   │       └── gox/
│   │           └── weather/
│   │               ├── WeatherMcpApplication.java    # Main application class
│   │               ├── model/
│   │               │   └── WeatherData.java          # Weather data model
│   │               └── service/
│   │                   └── WeatherService.java       # Weather service with MCP tool
│   └── resources/
│       └── application.properties                    # Application configuration

📋 Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher
  • Node.js and npm (for MCP Inspector)

🚀 Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/weather-mcp-java.git
    cd weather-mcp-java
    
  2. Build the project:

    mvn clean install
    

🏃‍♂️ Running the Application

Start the Spring Boot application:

mvn spring-boot:run

The application will start on port 8080 by default (configurable in application.properties).

⚙️ Configuring MCP in IDE Tools

To use this MCP server with AI assistants in IDE tools like Cursor or Cline:

  1. Open your IDE's settings for AI assistant configuration
  2. Look for MCP or Model Context Protocol settings
  3. Add a new MCP server with the following SSE endpoint:
    http://localhost:8089/sse
    
  4. Save the settings and restart the AI assistant if necessary
  5. The weather tool should now be available to your AI assistant

Note: Make sure the port (8089) matches the port configured in your application.properties file.

🔧 Using the MCP Inspector

The MCP Inspector is a tool that allows you to test and debug your MCP server (If you want to debug MCP server). To use it:

  1. Install and run the MCP Inspector:

    npx @modelcontextprotocol/inspector
    
  2. Open the MCP Inspector in your browser:

    http://127.0.0.1:6274/#tools
    
  3. Connect to your MCP server by entering the SSE endpoint:

    http://localhost:8080/mcp/sse
    

    Note: The port (8080) should match the port your Spring Boot application is running on.

  4. Once connected, you can test the getWeather tool by providing a location parameter.

📚 API Documentation

Weather Service

The Weather Service provides the following functionality:

Get Weather

Returns weather information for a specified location.

Tool Name: getWeather

Parameters:

  • location (String): The name of the location to get weather for (e.g., "New York", "London", "Tokyo")

Response:

{
  "location": "New York",
  "temperature": 22.5,
  "condition": "Partly Cloudy",
  "humidity": 65,
  "windSpeed": 12.3
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Tavily Mcp
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Playwright McpPlaywright MCP server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
WindsurfThe new purpose-built IDE to harness magic
Serper MCP ServerA Serper MCP Server
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.