modelcontextprotocol / modelcontextprotocol/java-sdk
Servlet transports serialize McpError exceptions instead of JSON-RPC error envelopes
還沒有人認領這個 Issue。
- 主要語言
- Java
- 星號
- 3.7k
- 分支
- 1.1k
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 9
描述
Servlet transports serialize McpError exceptions instead of JSON-RPC error envelopes
Bug description
Some servlet transport error paths serialize McpError directly instead of returning a JSON-RPC error response envelope.
Because McpError extends RuntimeException, the response body can expose exception-shaped fields such as:
stackTracecauselocalizedMessagejsonRpcError
For example, on current main, a servlet transport validation error returns a body like this:
This is not the JSON-RPC response shape clients expect.
Environment
- MCP Java SDK version: current
main - Java version: 21
- Transport: servlet server transports
Steps to reproduce
- Run an MCP server with a servlet transport.
- Send a request that triggers a servlet transport error path.
- Inspect the response body.
Expected behavior
The response body should look like:
{
"jsonrpc": "2.0",
"error": {
"code": -32601,
"message": "Both application/json and text/event-stream required in Accept header"
}
}
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從重現步驟中描述的 servlet 伺服器傳輸錯誤路徑開始,追蹤驗證失敗是如何序列化的。將目前的回應與預期的 JSON-RPC 信封進行比較,然後執行所述的 Accept 標頭驗證請求,以確認本文僅包含 JSON-RPC 錯誤結構。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- api, backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 活躍
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100