modelcontextprotocol / modelcontextprotocol/java-sdk

Add JPMS compatibility to Jackson JSON mapper

オープン
#753 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2
主要言語
Java
スター
3.7k
フォーク
1.1k
平均マージ
1日 15時間
マージ済み PR(30日)
9

説明

Expected Behavior

Applications using the MCP Java SDK should work with JPMS (Java Platform Module System) without requiring --add-opens JVM flags. Record deserialization should work through public constructors and parameter name discovery rather than reflective access.

  // Should work without --add-opens flags
  McpJsonMapper mapper = new JacksonMcpJsonMapperSupplier().get();
  MyRecord record = mapper.readValue(json, MyRecord.class);

Current Behavior

The JacksonMcpJsonMapperSupplier creates a plain ObjectMapper that uses reflection to access record constructors. This requires --add-opens JVM flags like:

  --add-opens java.base/java.lang.reflect=ALL-UNNAMED

Without these flags, deserialization of Java records fails with InaccessibleObjectException.

Context

We're integrating the MCP SDK into a JPMS-modularized application and cannot use --add-opens flags as they break module encapsulation.

The fix is straightforward:

  1. Disable MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS to prevent setAccessible() calls
  2. Add ParameterNamesModule to discover constructor parameters from bytecode

The SDK already compiles with -parameters, so ParameterNamesModule will work without additional configuration.

Workaround: We currently maintain a custom MCP client with JPMS-compatible Jackson configuration, but would prefer to use the upstream SDK directly.

I have a PR.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

JacksonMcpJsonMapperSupplierから始めて、そのObjectMapperがrecordコンストラクターとパラメーター名をどのように処理するかを調査します。JPMSの例に照らしてmapperの設定を検証し、その後、--add-opensフラグなしでrecordのデシリアライズが機能し、既存の動作が維持されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
api, backend
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。