Elicitation fails with Jackson 3.2+: ElicitRequest `mode` conflicts with @JsonTypeInfo
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
McpSchema から始めます。ここで ElicitRequest が @JsonTypeInfo(property = "mode") を宣言し、ElicitFormRequest/ElicitUrlRequest が mode() を公開しています。ElicitRequestJsonTests を -Djackson3.version=3.3.0 で実行して再現し、次に提案されている JSONRPCRequest でラップしたテストを追加して、params のシリアライズ経路をカバーします。完了条件は、Jackson 3.3.0 上で form と url の両方のリクエストが params 内で mode をちょうど一度だけシリアライズすることですが、パッチを当てる前に、2 つの修正案のどちらを望むか maintainer に確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 3.8k
- フォーク
- 1.1k
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/java-sdk のほかの issue
-
Modern `HttpServletMcpTransport` does not check `Mcp-Name` when `params.name` or `params.uri` is not a JSON string対応中かも @starryeye が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/java-sdk#1352 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Unknown tool error always says "Unknown tool: invalid_tool_name" instead of the name that was calledオープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
modelcontextprotocol/java-sdk#1346 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Tool result _meta is lost when the server automatically adds text content for structured outputオープンarea/server legacy P3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/java-sdk#1330 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Client request handlers that complete empty send no JSON-RPC response対応中かも @1fanwang が 83 日前に担当しました。 オープンarea/client bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/java-sdk#1124 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities対応中かも @1yuxiangJ が 98 日前に担当しました。 オープンbug P2 ready for work
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/java-sdk#1086 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/java-sdk の issue をすべて見る
似ている issue
-
crash
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
account bug course exam iris lecture
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100