跪拜 Guibai
← All articles
MCP · AI Programming

MCP's Biggest Overhaul Kills Sessions and Handshakes—Here's What Breaks in Java

By Lambert281 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

MCP servers can now be deployed like ordinary HTTP microservices—no sticky sessions, no shared state stores, no gateway deep-packet inspection. For Java teams, the immediate risk is assuming Spring AI's STATELESS mode equals the new spec; it doesn't, and that confusion will produce hard-to-diagnose interop failures when clients and servers mix protocol generations.

Summary

The 2026-07-28 MCP specification is the protocol's largest upgrade, eliminating the initialize handshake, Mcp-Session-Id, ping, and all server-initiated requests. Every request now carries its own identity and capabilities in _meta fields, and stateful workflows move to explicit server-minted handles passed as ordinary tool parameters. Multi Round-Trip Requests (MRTR) replace the old server-to-client calls, and a new server/discover RPC lets clients probe protocol versions without a handshake.

In the Java ecosystem, LangChain4j 1.19 already supports the new spec on the client side, but its default 30-second auto-detection timeout causes stealthy startup delays. The MCP Java SDK and Spring AI remain on the 2025-11-25 spec, and Spring AI's STATELESS mode is a different, older form of statelessness—not the new protocol. Literal error-code matching against -32002 will silently break when servers upgrade, and the old Tasks API requires a mandatory migration.

Remote MCP servers gain the biggest operational win: they can now sit behind round-robin load balancers without sticky sessions, shared session storage, or deep packet inspection. The protocol is converging on HTTP's request/response model, and the Java server-side tooling is roughly one version cycle behind the client libraries.

Takeaways
All session semantics are gone: no initialize handshake, no Mcp-Session-Id, no ping, no server-initiated requests.
Every request carries its own protocol version, client info, and capabilities in _meta fields, making each call self-contained.
Stateful workflows move to explicit server-minted handles—IDs returned as tool parameters that the model passes back in subsequent calls.
Multi Round-Trip Requests (MRTR) replace server-to-client calls: the server returns InputRequiredResult, and the client retries the original request with the missing data.
LangChain4j 1.19 supports the new spec on the client side but defaults to a 30-second auto-detection timeout that silently falls back to legacy mode.
MCP Java SDK 2.0.1 and Spring AI 2.0.x remain on the 2025-11-25 spec; Spring AI's STATELESS mode is an older variant, not the new protocol.
The error code for resource-not-found changed from -32002 to -32602, so literal error-code checks will silently fail after a server upgrade.
The experimental Tasks API from 2025-11-25 is now a separate extension with a redesigned lifecycle—existing implementations must migrate.
Streamable HTTP POST now requires Mcp-Method and Mcp-Name headers, and x-mcp-header lets tools inject custom HTTP headers for gateway routing and auth.
Conclusions

The protocol is deliberately converging on HTTP's request/response model—MCP wants to be the HTTP of AI tool calling, and this spec makes that architectural bet explicit.

Spring AI's STATELESS mode solves multi-replica deployment but is a 2025-11-25 variant, not the new spec; calling it 'stateless' creates a naming collision that will confuse teams during the migration cycle.

The 30-second auto-detection default in LangChain4j is a pragmatic choice for subprocess-based servers but a performance trap for remote-server setups, and the silent-warning fallback makes it hard to notice.

Explicit handles are arguably more capable than sessions because the model can reason about them, combine them across tools, and pass them around—state becomes a first-class concept the LLM can manipulate.

Error-code literal matching is the kind of silent failure that survives code review because it looks correct; the -32002 to -32602 change will break conditionals without any exception or log line.

The Java server-side SDK lagging behind the client libraries is a recurring pattern in protocol adoption, but the annotation-based tool model means most user code won't need changes when the SDK eventually upgrades.

Concepts & terms
Explicit handles (server-minted handles)
Server-generated IDs returned as ordinary tool parameters that clients pass back in subsequent calls, replacing implicit session state. The model can reason about handles, combine them across tools, and pass them to other tools—making state a first-class concept the LLM manipulates rather than hidden transport metadata.
Multi Round-Trip Requests (MRTR)
A pattern replacing server-initiated requests. When a server lacks information to complete a request, it returns an InputRequiredResult listing what's needed. The client collects the answers and retries the original request with the data in the payload, so any server instance can handle the retry.
server/discover
A mandatory RPC method in the 2026-07-28 spec that lets clients query a server's supported protocol versions, capabilities, and identity before sending any requests. Replaces the version-negotiation role that the initialize handshake previously served.
x-mcp-header
A mechanism where servers mark tool parameters in the input schema with x-mcp-header, and clients automatically place those parameter values into custom HTTP headers (e.g., Mcp-Param-X-Tenant-Id). Enables gateway-level routing and authentication without parsing JSON-RPC bodies.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗