Elicitation fails with Jackson 3.2+: ElicitRequest `mode` conflicts with @JsonTypeInfo
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 64/100
Research direction
Start in McpSchema where ElicitRequest declares @JsonTypeInfo(property = "mode") and where ElicitFormRequest/ElicitUrlRequest expose mode(). Reproduce by running ElicitRequestJsonTests with -Djackson3.version=3.3.0, then add the proposed JSONRPCRequest-wrapped test so the params serialization path is covered. Done means both form and url requests serialize mode exactly once inside params on Jackson 3.3.0, but confirm with a maintainer which of the two fix options they want before patching.
Written by the indexing model from the issue text.
Description
Bug description
With Jackson 3.2.0 or newer, server-initiated elicitation fails. ElicitRequest declares @JsonTypeInfo(include = As.PROPERTY, property = "mode"), and ElicitFormRequest/ElicitUrlRequest also expose @JsonProperty("mode"). Since 3.2.0, Jackson rejects this:
InvalidDefinitionException: Conflict between type id property 'mode' and …
at …_verifyNoTypeIdPropertyConflict
The transport closes the response stream, so the tool result is lost too and the client times out. Jackson 3.1.8 (the version the SDK builds with) works.
This is also a security concern. Several Jackson 3.2.x releases have known CVEs in their modules (see MvnRepository, e.g. 3.2.0), while 3.2.4 and 3.3.0 list none. Upgrading to a clean release breaks elicitation, so elicitation users are stuck on 3.1.8 and cannot pick up future Jackson security fixes.
The conflict was introduced in #993 (URL elicitation), which added the ElicitRequest interface with @JsonTypeInfo(include = As.PROPERTY, property = "mode") while the ElicitFormRequest and ElicitUrlRequest records also expose @JsonProperty("mode").
Environment
MCP Java SDK 2.2.0, Streamable HTTP servlet transport, Java 25, MCP Inspector 2.13.0. Fails with every Jackson release since 3.2.0 that I tried (3.2.0, 3.2.4, 3.3.0).
Steps to reproduce
- Use SDK 2.2.0 with Jackson 3.3.0 (import
tools.jackson:jackson-bom:3.3.0beforemcp-bom). - In a tool handler, call
exchange.createElicitation(ElicitFormRequest.builder(message, schema).build()). - Call the tool from a client that supports elicitation.
Expected behavior
Elicitation works with current Jackson 3 releases (e.g. 3.3.0), and mode is sent exactly once inside params of elicitation/create, for both form and URL requests.
Minimal Complete Reproducible example
A test for ElicitRequestJsonTests (from #1045) that serializes the request the way the transport does, as params of a JSONRPCRequest:
@Test
void urlRequestKeepsModeAsJsonRpcParams() throws IOException {
McpSchema.ElicitUrlRequest request = McpSchema.ElicitUrlRequest.builder("msg", "https://example.com", "eid")
.build();
McpSchema.JSONRPCRequest message = new McpSchema.JSONRPCRequest(McpSchema.JSONRPC_VERSION,
McpSchema.METHOD_ELICITATION_CREATE, "1", request);
String json = mapper.writeValueAsString(message);
assertThatJson(json).node("params.mode").isEqualTo("url");
}
Run with -Djackson3.version=3.3.0:
| Version | Result |
|---|---|
| #1045 | fails: Missing node in path "params.mode" |
EXISTING_PROPERTY (below) |
passes (5/5 in ElicitRequestJsonTests) |
Fix options
#1045 marks mode() with @JsonIgnore. That removes the exception, but when the request is the value of JSONRPCRequest.params (declared as Object), no type id is written either, so mode is not sent at all. Form mode still works by default, but URL mode would reach the client without mode. The same @JsonIgnore approach works for Content.type() because content is declared as List<Content>, so Jackson writes the type id there. Raw SSE captures in a comment on #1045.
Alternative: change only the discriminator to EXISTING_PROPERTY:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "mode",
defaultImpl = ElicitFormRequest.class)
and keep @JsonProperty("mode") on the mode() accessors of both ElicitFormRequest and ElicitUrlRequest, as in 2.2.0:
@Override
@JsonProperty("mode")
public String mode() {
return MODE;
}
Tested on top of v2.2.0 with Jackson 3.3.0: #1045's ElicitRequestJsonTests and the test above pass, and on the wire (Streamable HTTP, MCP Inspector) "mode":"form" is sent exactly once.
Which approach would you prefer? I can open a PR if that helps, but I'm equally fine with a maintainer picking this up.
- Dominant language
- Java
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/java-sdk
-
Modern `HttpServletMcpTransport` does not check `Mcp-Name` when `params.name` or `params.uri` is not a JSON stringPossibly taken @starryeye claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelcontextprotocol/java-sdk#1352 · 1 comment ·
Maintainers usually reply within 1 day
-
Unknown tool error always says "Unknown tool: invalid_tool_name" instead of the name that was calledOpen
Difficulty 1/5 Under an hour Newbie friendliness 85/100
modelcontextprotocol/java-sdk#1346 · 1 comment ·
Maintainers usually reply within 1 day
-
Tool result _meta is lost when the server automatically adds text content for structured outputOpenarea/server legacy P3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
modelcontextprotocol/java-sdk#1330 · 1 comment ·
Maintainers usually reply within 1 day
-
Client request handlers that complete empty send no JSON-RPC responsePossibly taken @1fanwang claimed this 83 days ago. Openarea/client bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/java-sdk#1124 · 6 comments ·
Maintainers usually reply within 1 day
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilitiesPossibly taken @1yuxiangJ claimed this 98 days ago. Openbug P2 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/java-sdk#1086 · 2 comments ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/java-sdk
Similar issues
-
crash
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
account bug course exam iris lecture
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100