modelcontextprotocol / modelcontextprotocol/java-sdk
Servlet transports serialize McpError exceptions instead of JSON-RPC error envelopes
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 3.7k
- Fork
- 1.1k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 9
Mô tả
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"
}
}
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ các đường dẫn lỗi transport của máy chủ servlet được mô tả trong phần tái hiện và theo dõi cách các lỗi xác thực được tuần tự hóa. So sánh response hiện tại với envelope JSON-RPC dự kiến, sau đó thực hiện request xác thực header Accept đã nêu để xác nhận rằng body chỉ chứa cấu trúc lỗi JSON-RPC.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- api, backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100