Back in July, we walked through Integrating MCP Tooling with Spring AI, wiring up Model Context Protocol servers over SSE and Streamable HTTP. It worked great on localhost. Then teams put those MCP servers behind a Kubernetes Ingress with three replicas—and immediately ran headfirst into sticky sessions, dropped initialize handshakes, and broken server-to-client elicitation callbacks whenever a pod rolled.
Spring AI 2.1 (via 2.1.0-RC2 and MCP Java SDK 2.2.0-M2) solves that deployment headache head-on by shipping first-class support for the 2026-07-28 (“Modern”) MCP specification (spring.ai.mcp.server.protocol=MODERN).
No initialize handshake. No server-side session state. A single POST /mcp endpoint that scales horizontally behind any plain round-robin load balancer—while still supporting interactive human confirmation and sampling through Multi-Round-Trip Requests (MRTR).
In this sequel, we will compare legacy stateful MCP against protocol=MODERN, build a real Spring Boot 4.2 @McpTool that pauses to ask a human for confirmation before deleting a record, and cover the key migration caveats (including OAuth governance and the Anthropic SDK 3.4.0 breaking changes bundled in Spring AI 2.1).
1. Legacy Stateful MCP vs. Modern 2026-07-28 MCP
At AGNTCon + MCPCon NA 2026, James Ward and Alexander Ioffe argued that teams need to stop treating MCP as a thin CRUD wrapper and start designing it as a true Agent Integration Interface. The 2026-07-28 protocol redesign makes that architecture cloud-native by stripping away stateful session plumbing:
| Capability | Legacy SSE / STREAMABLE MCP | Modern 2026-07-28 (protocol=MODERN) |
|---|---|---|
| Session State | Stateful server sessions; requires sticky routing across K8s replicas | 100% sessionless; any replica can serve any request |
| Capability Handshake | Stateful initialize negotiation per connection | Cacheable server/discover request; protocol version & client capabilities travel in _meta on every call |
| HTTP Transport | Multi-endpoint SSE + POST or long-lived Streamable streams | Single POST /mcp endpoint (returns JSON or short-lived text/event-stream for progress updates) |
| Human Confirmation / Sampling | Session-bound server-to-client callbacks (ctx.elicit, ctx.sample) | Multi-Round-Trip Requests (MRTR) via InputRequiredResult + sealed requestState |
| Change Notifications | Bound to active client session stream | Dedicated subscriptions/listen stream backed by runtime repositories |
| Capability Enforcement | Manual checks inside tool bodies | Declarative requiredCapabilities attribute on @McpTool, @McpResource, @McpPrompt |
Supported transports for protocol=MODERN include Spring WebMVC, Spring WebFlux, and STDIO.
2. Enabling protocol=MODERN in Gradle and application.yml
If you already run a STATELESS MCP server in Spring AI, migrating your existing @McpTool, @McpResource, and @McpPrompt beans is literally a one-line configuration switch.
// build.gradle.kts
ext["springAiVersion"] = "2.1.0-RC2"
dependencyManagement {
imports {
mavenBom("org.springframework.ai:spring-ai-bom:${property("springAiVersion")}")
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webmvc")
implementation("org.springframework.ai:spring-ai-starter-mcp-server-webmvc")
}
# application.yml
spring:
ai:
mcp:
server:
name: task-operations-mcp
version: 2.1.0
protocol: MODERN
type: SYNC
streamable-http:
mcp-endpoint: /mcp
Important RC2 constraint: Modern MCP server support currently requires spring.ai.mcp.server.type=SYNC. Combining type=ASYNC with protocol=MODERN fails fast at application startup rather than misbehaving silently. On Java 25 with spring.threads.virtual.enabled=true, synchronous WebMVC handlers already scale cleanly without reactive boilerplate.
3. Building a Destructive @McpTool with Multi-Round-Trip Elicitation
How do you ask a human for confirmation—“Are you sure you want to delete production task TASK-409?”—when the server holds zero session memory between HTTP calls?
MCP 2026-07-28 solves this cleanly with Multi-Round-Trip Requests (MRTR):
- Round-Trip 1: The client calls
POST /mcpto invokedelete_task. Spring AI first verifies the client declaredMcpClientCapability.ELICITATION_FORMin its request_meta(rejecting the call automatically if unsupported). Inside our Java method,ctx.inputResponse("confirm", Map.class)returnsnull. - Our handler emits a progress update via
McpSyncNotifierand returns anInputRequiredResultcontaining a JSON Schema confirmation form plus a sealedrequestStatepayload (here, the task ID). - The client renders the confirmation form to the user, collects
{ "confirmed": true }, and sends Round-Trip 2 toPOST /mcp—which can land on an entirely different Kubernetes pod—carrying bothinputResponsesandrequestState. - Our handler reads
ctx.inputResponse("confirm", Map.class), verifies the user approved, and executes the deletion.
package com.ghostprogrammer.mcp.tools;
import java.util.Map;
import org.springaicommunity.mcp.annotation.McpTool;
import org.springaicommunity.mcp.annotation.McpToolParam;
import org.springframework.ai.mcp.modern.CallToolOutcome;
import org.springframework.ai.mcp.modern.ElicitFormRequest;
import org.springframework.ai.mcp.modern.InputRequiredResult;
import org.springframework.ai.mcp.modern.McpClientCapability;
import org.springframework.ai.mcp.modern.McpModernSyncRequestContext;
import org.springframework.ai.mcp.modern.McpSyncNotifier;
import org.springframework.stereotype.Component;
@Component
public class TaskOperationsTools {
private final TaskRepository taskRepository;
public TaskOperationsTools(TaskRepository taskRepository) {
this.taskRepository = taskRepository;
}
@McpTool(
name = "delete_task",
description = "Permanently deletes a task after explicit human confirmation",
requiredCapabilities = McpClientCapability.ELICITATION_FORM
)
public CallToolOutcome deleteTask(
McpSyncNotifier notifier,
McpModernSyncRequestContext ctx,
@McpToolParam(description = "Unique task identifier") String id) {
// Round-Trip 1: null until the client submits the elicitation form
Map<?, ?> answer = ctx.inputResponse("confirm", Map.class);
if (answer == null) {
notifier.progress(10, 100.0, "Requesting user confirmation for task " + id);
Map<String, Object> confirmationSchema = Map.of(
"type", "object",
"required", java.util.List.of("confirmed"),
"properties", Map.of(
"confirmed", Map.of(
"type", "boolean",
"title", "Confirm permanent deletion"
)
)
);
return InputRequiredResult.builder()
.elicit("confirm", ElicitFormRequest.builder(
"Permanently delete task " + id + "?",
confirmationSchema).build())
.requestState(id)
.build();
}
// Round-Trip 2: verify explicit approval before mutating state
boolean confirmed = Boolean.TRUE.equals(answer.get("confirmed"));
if (!confirmed) {
return CallToolOutcome.text("Deletion cancelled by user for task " + id + ".");
}
notifier.progress(75, 100.0, "Deleting task " + id);
taskRepository.deleteById(id);
notifier.progress(100, 100.0, "Deleted task " + id);
return CallToolOutcome.text("Task " + id + " was permanently deleted.");
}
}
Bonus Metadata Annotations in Modern MCP
Spring AI 2.1 also adds rich descriptor metadata so agent clients can render better UIs and cache read-only resources aggressively:
@McpIcon: Attach brand or domain icons to tools and resources.@McpArg(title = "..."): Provide human-friendly argument labels.@McpResource(size = ..., ttlMs = ..., cacheScope = ...): Let clients cache static documentation or schema resources cleanly.@McpToolParam(header = true): Bind HTTP request headers (such as tenant IDs or correlation IDs) directly into tool parameters without exposing them to the LLM schema.
4. Enterprise Security & Spring AI 2.1 Migration Pitfalls
As you upgrade your MCP servers to Spring AI 2.1, keep three production gotchas on your checklist:
- Securing Stateless MCP with OAuth: Stateless
POST /mcpplays dramatically better with standard Spring Security OAuth2 Resource Server JWT validation than long-lived SSE streams did. Check out the communityspring-ai-community/mcp-securityproject (highlighted alongside Spring Office Hours S5E29) for ready-made OAuth 2.1 metadata discovery and token enforcement for MCP servers and clients. - Legacy Streamable APIs Without Modern Equivalents Yet: When migrating from
STREAMABLEtoMODERN, replacectx.elicit(...)/ctx.sample(...)withInputRequiredResult, and replacectx.progress(...)withMcpSyncNotifier. Note that client logging,ctx.roots(), andctx.ping()do not yet have equivalents inMcpModernSyncRequestContext. - Anthropic Java SDK
3.4.0Breaking Changes in Spring AI 2.1: If your MCP host application also calls Anthropic models, Spring AI2.1.0-RC2upgrades to Anthropic SDK3.4.0(API version2026-10-21), which rejectstemperature,topP, andtopK(Spring AI deprecates, strips, and logs aWARN) and switches authentication fromX-Api-KeytoAuthorization: Bearer. Also remove any manual cache-token addition in your billing code:Usage.getPromptTokens()now includes prompt cache read and write tokens automatically for both Anthropic and AWS Bedrock Converse.
Conclusion
Stateless protocol=MODERN turns MCP from a fragile laptop prototype protocol into an enterprise-grade HTTP interface ready for auto-scaled Kubernetes clusters. Pairing POST /mcp with requiredCapabilities and Multi-Round-Trip InputRequiredResult gives Java teams the best of both worlds: horizontal scalability on the backend and ironclad human-in-the-loop safety on destructive agent actions.
Discover more from GhostProgrammer - Jeff Miller
Subscribe to get the latest posts sent to your email.

