https://github.com/roryp/starter-webflux-server
https://github.com/roryp/starter-webflux-server
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/roryp/starter-webflux-server
- Owner: roryp
- Created: 2025-03-31T10:58:23.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-31T11:24:20.000Z (about 1 year ago)
- Last Synced: 2025-03-31T12:22:42.950Z (about 1 year ago)
- Language: Java
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-mcp-servers - starter-webflux-server - A reference implementation demonstrating how to build an MCP server with SSE transport using Spring Boot and WebFlux. It showcases the definition and registration of MCP Tools, Resources, and Prompts, serving as an example for developers building their own MCP servers. ([Read more](/details/starter-webflux-server.md)) `reference-implementation` `spring-boot` `webflux` `sse` (Reference Implementations & Examples)
README
# Spring AI MCP Echo Server Sample with WebFlux Starter
This sample project demonstrates how to create an MCP server using the Spring AI MCP Server Boot Starter with WebFlux transport. It implements a simple echo service that provides text echo functionality.
For more information, see the [MCP Server Boot Starter](https://docs.spring.io/spring-ai/reference/api/mcp/mcp-server-boot-starter-docs.html) reference documentation.
## Overview
The sample showcases:
- Integration with `spring-ai-mcp-server-webflux-spring-boot-starter`
- Support for SSE (Server-Sent Events)
- Automatic tool registration using Spring AI's `@Tool` annotation
- Echo service tools:
- Echo back messages exactly as received
## Dependencies
The project requires the Spring AI MCP Server WebFlux Boot Starter:
```xml
org.springframework.ai
spring-ai-mcp-server-webflux-spring-boot-starter
```
This starter provides:
- Reactive transport using Spring WebFlux (`WebFluxSseServerTransport`)
- Auto-configured reactive SSE endpoints
- Included `spring-boot-starter-webflux` and `mcp-spring-webflux` dependencies
## Building the Project
Build the project using Maven:
```bash
./mvnw clean install -DskipTests
```
## Running the Server
```bash
java -jar target/mcp-echo-starter-webflux-server-0.0.1-SNAPSHOT.jar
```
## Development with DevContainer
This project includes a DevContainer configuration for Visual Studio Code, providing a consistent development environment:
1. Install [VS Code](https://code.visualstudio.com/) and the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
2. Open the project folder in VS Code
3. Click "Reopen in Container" when prompted or run the "Dev Containers: Reopen in Container" command
4. The container will build and start with:
- Java 21 JDK
- Maven 3.9.6
- Required VS Code extensions for Spring and Java development
- All dependencies pre-installed
See the `.devcontainer` folder for more details.
## Running with Docker
The project includes a Dockerfile for containerization:
```bash
docker build --pull --rm -f 'DockerFile' -t 'starterwebfluxserver:latest' '.'
docker run -d -p 8080:8080 starterwebfluxserver:latest
```
## Testing the Server
### Using the ClientSse Test Client
The project includes a `ClientSse` class that provides a simple client for testing the server. This utility helps you send requests and receive streaming responses from the MCP server endpoints.
step 1 - Build and run the docker server (on port 8080)
step 2 - Run the ClientSse test
## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.