modelcontextprotocol / modelcontextprotocol/java-sdk

Simplify error response when accessing MCP without session ID

オープン 初心者向け
#577 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

説明

Description:
Currently, when accessing the MCP Streamable HTTP server at https://host:port/mcp without providing a session ID, the server responds with the full exception stack trace and detailed error information.

Issue:
Returning the complete stack trace in the response is not user-friendly and may expose internal details unnecessarily.

https://github.com/modelcontextprotocol/java-sdk/blob/7f16cd0b9dc72f5adc3358a903bebb0f909dda3e/mcp-core/src/main/java/io/modelcontextprotocol/server/transport/HttpServletStreamableServerTransportProvider.java#L264C4-L264C100

Suggestion:
Instead of returning the full error, return a simple, clear message indicating there is an issue with the request headers or the session ID

stack trace

{
  "cause": null,
  "stackTrace": [
    {
      "moduleName": null,
      "moduleVersion": null,
      "classLoaderName": null,
      "methodName": "doGet",
      "fileName": "HttpServletStreamableServerTransportProvider.java",
      "lineNumber": 268,
      "className": "com.ibm.modelcontextprotocol.server.transport.HttpServletStreamableServerTransportProvider",
      "nativeMethod": false
    },
    {
      "moduleName": null,
      "moduleVersion": null,
      "classLoaderName": null,
      "methodName": "service",
      "fileName": "HttpServlet.java",
      "lineNumber": 527,
      "className": "jakarta.servlet.http.HttpServlet",
      "nativeMethod": false
    },
    {
      "moduleName": null,
      "moduleVersion": null,
      "classLoaderName": null,
      "methodName": "service",
      "fileName": "HttpServlet.java",
      "lineNumber": 614,
      "className": "jakarta.servlet.http.HttpServlet",
      "nativeMethod": false
    }
  ],
  "jsonRpcError": null,
  "message": "text/event-stream required in Accept header; Session ID required in mcp-session-id header",
  "localizedMessage": "text/event-stream required in Accept header; Session ID required in mcp-session-id header",
  "suppressed": []
}

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

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

はじめの一歩

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

調査の方向性

HttpServletStreamableServerTransportProvider.java の264行目付近から始め、mcp-session-id ヘッダーのないリクエストに対する GET の処理を調査します。issue に記載されたリクエストを再現し、その後、レスポンスが例外のスタックトレースを公開せず、単純なリクエストまたはセッションIDのメッセージを返すことを確認します。

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

評価

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

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

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