Wire mcpServerJsonMapper into stateless MCP server builders#5895
Open
PVPankaj wants to merge 1 commit intospring-projects:mainfrom
Open
Wire mcpServerJsonMapper into stateless MCP server builders#5895PVPankaj wants to merge 1 commit intospring-projects:mainfrom
PVPankaj wants to merge 1 commit intospring-projects:mainfrom
Conversation
McpServerStatelessAutoConfiguration did not pass the configured mcpServerJsonMapper to the McpServer builder, causing the handler stage to fall back to a strict default ObjectMapper. This rejected unknown fields from MCP clients implementing the 2025-11-25 spec (e.g. Codex), breaking the initialize handshake. Add @qualifier("mcpServerJsonMapper") JsonMapper parameter and .jsonMapper(new JacksonMcpJsonMapper(...)) call to both the sync and async stateless server bean methods, consistent with how the stdio transport is already wired in McpServerAutoConfiguration. Closes spring-projectsgh-5894 Signed-off-by: Pankaj <pankajvpande@gmail.com>
ec0f397 to
567ee2d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
McpServerStatelessAutoConfigurationbuilds the stateless sync and asyncMcpServerwithout calling.jsonMapper(...). This causes the handler stage (e.g.convertValue(req, InitializeRequest.class)) to fall back toMcpJsonMapper.getDefault()- a strict vanilla ObjectMapper withFAIL_ON_UNKNOWN_PROPERTIES=true.Meanwhile, the transport layer correctly uses the lenient
mcpServerJsonMapperbean. So we end up with two different mappers at different stages:JSONRPCRequest: lenient mapper ✅params->InitializeRequest: strict default ❌Any MCP client implementing the 2025-11-25 spec (e.g. Codex) sends fields like
capabilities.elicitation.formthat the current SDK records don't model yet, so the strict mapper rejects them and the initialize handshake fails with:This change adds
@Qualifier("mcpServerJsonMapper") JsonMapperto bothmcpStatelessSyncServerandmcpStatelessAsyncServerbean methods and wires it via.jsonMapper(new JacksonMcpJsonMapper(...))on the builder - the same pattern already used byMcpServerAutoConfigurationfor the stdio transport.Closes gh-5894