Skip to content

feat(examples): add Java WebFlux MCP server example#439

Open
apappascs wants to merge 1 commit intomodelcontextprotocol:mainfrom
apappascs:feat/basic-server-java-webflux
Open

feat(examples): add Java WebFlux MCP server example#439
apappascs wants to merge 1 commit intomodelcontextprotocol:mainfrom
apappascs:feat/basic-server-java-webflux

Conversation

@apappascs
Copy link

  • Spring Boot 3.5 + MCP Java SDK 0.17.2 with WebFlux Streamable HTTP transport
  • calculate tool with add, subtract, multiply, divide operations
  • interactive calculator UI via ext-apps SDK (CDN)
  • 3 MCP prompts: quick-calc, compare-numbers, percentage
  • CSP metadata on content items for unpkg.com script loading

Summary

Add a Java WebFlux example server demonstrating the MCP Java SDK with Spring Boot and Streamable HTTP transport.

Motivation and Context

The existing examples are all TypeScript/Python. This adds the first Java example, showing how to build an MCP Apps server using the official MCP Java SDK (mcp-spring-webflux) with Spring Boot WebFlux and Streamable HTTP transport. It serves as a starter template for Java developers.

How Has This Been Tested?

  • 18 unit tests (16 tool tests, 2 resource tests)
  • End-to-end verification against all MCP endpoints (initialize, tools/list, tools/call, resources/list, resources/read, prompts/list, prompts/get)
  • Tested with MCP Inspector
  • Tested through Claude.ai web page via Cloudflare tunnel

Breaking Changes

None. This is a new example — no existing code is modified.

Types of changes

  • New Example (non-breaking change which adds functionality)

Checklist

  • I have read the https://modelcontextprotocol.io
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

  • Uses MCP Java SDK 0.17.2 (io.modelcontextprotocol.sdk:mcp-spring-webflux)
  • Spring Boot 3.5.10 with WebFlux (Netty) — HTTP only, no stdio support
  • Clean separation: McpConfig, CalculatorTools, CalculatorResources, CalculatorPrompts
  • View HTML loads ext-apps SDK from CDN (unpkg.com) with proper CSP metadata on contents[]._meta
  • Maven wrapper included — only requires Java 17+, no global Maven install

- Spring Boot 3.5 + MCP Java SDK 0.17.2 with WebFlux Streamable HTTP transport
- calculate tool with add, subtract, multiply, divide operations
- interactive calculator UI via ext-apps SDK (CDN)
- 3 MCP prompts: quick-calc, compare-numbers, percentage
- CSP metadata on content items for unpkg.com script loading
@apappascs
Copy link
Author

cc: @tzolov

@schlpbch
Copy link

schlpbch commented Feb 7, 2026

Here's my Open Source example example using Java 25 with Virtual Threads and Spring Boot 4.0 / Spring AI 2.0.

https://github.com/schlpbch/open-meteo-mcp-java

The Open-Meteo MCP Java server provides weather, air quality, and conversational AI capabilities through three distinct API endpoints with enterprise-grade security and real-time streaming in a modular, containerized architecture:

🔌 Three API Endpoints
🌐 REST API - Traditional HTTP REST endpoints for direct integration
🔗 MCP API - Model Context Protocol for AI tool integration (Claude Desktop, IDEs)
💬 Chat API - Conversational interface with weather expertise and memory
📡 Streaming API - Real-time SSE streaming for weather data and AI chat responses

@schlpbch
Copy link

schlpbch commented Feb 7, 2026

If interested I gladly extract only the MCP part and contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants