Class McpErrorBodies
Why this exists. SDK 2.0.0's Streamable HTTP transport answers its own errors -- no
session, an unknown session, an unparseable message, and any method it rejects before
initialize (such as the 2026-07-28 revision's server/discover) -- by serialising
the whole McpError EXCEPTION OBJECT: its JSON-RPC code and message, and also its
stackTrace, naming our classes, source files, line numbers and the Jetty and JDK versions.
Measured 2026-10-02. That body is not a JSON-RPC error at all, and the web proxy carries it to
whoever called.
The rewrite keeps exactly the code and the message and drops everything else, giving
{"jsonrpc":"2.0","id":null,"error":{"code":..,"message":".."}} -- id null because
the transport answered before reading one, as JSON-RPC prescribes for that case. The status code
is not touched: a 2026-07-28 client deciding whether we are a legacy server reads the status and
whether the body is one of ITS error types, and a plain JSON-RPC error is still not one, so the
documented fallback to initialize behaves exactly as before.
Copyright 2003-2026 ATB Consultancy Services Ltd
(formerly Orinda Software Ltd, Dublin, Ireland)
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringjsonRpcErrorFor(String theBody) The JSON-RPC error to send instead of an SDK transport error body, or null when the body is not one (it is then passed on unchanged -- this rewrites the one shape it knows, and nothing else).
-
Method Details
-
jsonRpcErrorFor
The JSON-RPC error to send instead of an SDK transport error body, or null when the body is not one (it is then passed on unchanged -- this rewrites the one shape it knows, and nothing else).- Parameters:
theBody- the response body as written- Returns:
- the replacement body, or null
-