Servlet transports serialize McpError exceptions instead of JSON-RPC error envelopes
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start at the servlet server transport error paths described in the reproduction and trace how validation failures are serialized. Compare the current response with the expected JSON-RPC envelope, then exercise the stated Accept-header validation request to confirm the body contains only the JSON-RPC error shape.
Written by the indexing model from the issue text.
Description
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"
}
}
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/java-sdk
-
area/transport bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/java-sdk#1124 · 1 comment ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Openbug P2 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/java-sdk#1086 · 1 comment ·
-
enhancement good first issue P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
modelcontextprotocol/java-sdk#898 · 1 comment ·
All issues in modelcontextprotocol/java-sdk
Similar issues
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
opensearch-project/ml-commons#5094 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
emitter:client:csharp feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100