Spring AI MCP Weather Server Sample with WebMVC Starter

by alexandredavi

2 stars
178 downloads
Not rated
GitHub

Description

# Spring AI MCP Weather Server Sample with WebMVC Starter This sample project demonstrates how to create an MCP server using the Spring AI MCP Server Boot Starter with WebMVC transport. It implements a weather service that exposes tools for retrieving weather information using…

About

# Spring AI MCP Weather Server Sample with WebMVC Starter This sample project demonstrates how to create an MCP server using the Spring AI MCP Server Boot Starter with WebMVC transport. It implements a weather service that exposes tools for retrieving weather information using the National Weather Service API. For…

Details

Author
alexandredavi
GitHub stars
2
Downloads
178
Categories
Developer Tools

- Integration with spring-ai-mcp-server-webmvc-spring-boot-starter
- Supports both SSE (Server-Sent Events) and STDIO transports
- Automatic tool registration using Spring AI’s @Tool annotation
- Two weather tools: forecast by location and alerts by US state
- Auto-configured SSE endpoints with WebMVC transport
- Optional change notifications for resources, tools, and prompts

Build the project using ./mvnw clean install -DskipTests. Run the server in default WebMVC SSE mode with java -jar target/mcp-weather-starter-webmvc-server-0.0.1-SNAPSHOT.jar or enable STDIO transport by setting the appropriate properties. Configure server identification, transport, and notification settings via application.properties.

Spring AI MCP Weather Server Sample with WebMVC Starter

This sample project demonstrates how to create an MCP server using the Spring AI MCP Server Boot Starter with WebMVC transport. It implements a weather service that exposes tools for retrieving weather information using the National Weather Service API.

For more information, see the MCP Server Boot Starter reference documentation.

Overview

The sample showcases:
- Integration with spring-ai-mcp-server-webmvc-spring-boot-starter
- Support for both SSE (Server-Sent Events) and STDIO transports
- Automatic tool registration using Spring AI's @Tool annotation
- Two weather-related tools:
- Get weather forecast by location (latitude/longitude)
- Get weather alerts by US state

Dependencies

The project requires the Spring AI MCP Server WebMVC Boot Starter:

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-mcp-server-webmvc-spring-boot-starter</artifactId>
</dependency>

This starter provides:
- HTTP-based transport using Spring MVC (WebMvcSseServerTransport)
- Auto-configured SSE endpoints
- Optional STDIO transport
- Included spring-boot-starter-web and mcp-spring-webmvc dependencies

Building the Project

Build the project using Maven:

./mvnw clean install -DskipTests

Running the Server

The server supports two transport modes:

WebMVC SSE Mode (Default)

java -jar target/mcp-weather-starter-webmvc-server-0.0.1-SNAPSHOT.jar

STDIO Mode

To enable STDIO transport, set the appropriate properties:
java -Dspring.ai.mcp.server.stdio=true -Dspring.main.web-application-type=none -jar target/mcp-weather-starter-webmvc-server-0.0.1-SNAPSHOT.jar

Configuration

Configure the server through application.properties:

```properties

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.