Package org.apache.juneau.bean.jsonrpc
Class JsonRpcResponse
java.lang.Object
org.apache.juneau.bean.jsonrpc.JsonRpcResponse
JSON-RPC 2.0 success or error response envelope.
Exactly one of result or error should be present for a valid response.
This envelope is generic JSON-RPC 2.0 and carries no _meta property: MCP-specific per-result
metadata belongs under result._meta, not beside the envelope. See the 2026-07-28 v2 bean
package (org.apache.juneau.bean.mcp.v20260728) for the typed nested carrier.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonRpcResponseerrorResponse(Object id, int code, String message) Creates a JSON-RPC 2.0 error response with no structured error data.static JsonRpcResponseerrorResponse(Object id, int code, String message, Object data) Creates a JSON-RPC 2.0 error response.getError()Error payload on failure.getId()Correlates to therequest id.JSON-RPC protocol version.Result payload on success.static booleannotification(Object id) Tests whether a JSON-RPC id identifies a notification (a request that must not be answered).static JsonRpcResponseCreates a JSON-RPC 2.0 success response.setError(JsonRpcError value) Sets the error payload.Sets the response id.setJsonrpc(String value) Sets the JSON-RPC protocol version.Sets the result payload.
-
Constructor Details
-
JsonRpcResponse
public JsonRpcResponse()
-
-
Method Details
-
getJsonrpc
JSON-RPC protocol version.- Returns:
- The version token, or
nullif not set.
-
setJsonrpc
Sets the JSON-RPC protocol version.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object (for method chaining).
-
getId
Correlates to therequest id.- Returns:
- The id, or
nullif not set.
-
setId
Sets the response id.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object (for method chaining).
-
getResult
Result payload on success.- Returns:
- The result, or
nullif not set.
-
setResult
Sets the result payload.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object (for method chaining).
-
getError
Error payload on failure.- Returns:
- The error, or
nullif not set.
-
setError
Sets the error payload.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object (for method chaining).
-
notification
Tests whether a JSON-RPC id identifies a notification (a request that must not be answered).A JSON-RPC request with no
idis a notification; the server performs the work and returns no response body.- Parameters:
id- The request id. Can benull .- Returns:
true if the id isnull .
-
ok
Creates a JSON-RPC 2.0 success response.- Parameters:
id- The request id to correlate against. Can benull .result- The result payload. Can benull .- Returns:
- A new response object. Never
null .
-
errorResponse
Creates a JSON-RPC 2.0 error response with no structured error data.- Parameters:
id- The request id to correlate against. Can benull .code- The JSON-RPC error code.message- The error message. Can benull .- Returns:
- A new response object. Never
null .
-
errorResponse
Creates a JSON-RPC 2.0 error response.- Parameters:
id- The request id to correlate against. Can benull .code- The JSON-RPC error code.message- The error message. Can benull .data- Optional structured error data. Can benull to leave the property unset.- Returns:
- A new response object. Never
null .
-