JSON-RPC 2.0 message types and standard error codes.
Values
INTERNAL_ERROR
INTERNAL_ERROR: Int -32603
Internal JSON-RPC error (-32603).
INVALID_PARAMS
INVALID_PARAMS: Int -32602
Invalid method parameters (-32602).
INVALID_REQUEST
INVALID_REQUEST: Int -32600
The JSON sent is not a valid Request object (-32600).
METHOD_NOT_FOUND
METHOD_NOT_FOUND: Int -32601
The method does not exist or is not available (-32601).
PARSE_ERROR
PARSE_ERROR: Int -32700
Invalid JSON was received by the server (-32700).
Types
Error
Error type {
code: Int,
message: Str,
data: Any?
}
A JSON-RPC 2.0 error object with code, message, and optional data.
Standard error codes are defined as constants: PARSE_ERROR (-32700),
INVALID_REQUEST (-32600), METHOD_NOT_FOUND (-32601),
INVALID_PARAMS (-32602), INTERNAL_ERROR (-32603).
Example
::types ::json-rpc::types
error ::types/Error({code: -32601, message: "Method not found", data: null})
error.code // => -32601
error.message // => "Method not found"
Notification
Notification type {
jsonrpc: Str,
method: Str,
params: Map?
}
A JSON-RPC 2.0 notification message. Has no id and expects no response.
Use ::json-rpc::client/notification to build notification messages.
Example
::rpc ::json-rpc::client
notif ::rpc/notification("notifications/initialized", null)
// notif => {jsonrpc: "2.0", method: "notifications/initialized", params: null}
Request
Request type {
jsonrpc: Str,
id: Str,
method: Str,
params: Map?
}
A JSON-RPC 2.0 request message. Contains a unique id for response correlation.
Use ::json-rpc::client/request to build requests with auto-generated ids.
Example
::rpc ::json-rpc::client
req ::rpc/request("tools/list", {})
// req => {jsonrpc: "2.0", id: "<uuid>", method: "tools/list", params: {}}
Response
Response type {
jsonrpc: Str,
id: Str?,
result: Any?,
error: Error?
}
A JSON-RPC 2.0 response message. Contains either a result or an error.
Use ::json-rpc::client/parse-response to convert raw response maps into
this type, which automatically returns err() for error responses.
Example
::rpc ::json-rpc::client
response ::rpc/send(url, headers, req)
response.jsonrpc // => "2.0"
response.result // => {serverInfo: {...}, ...} (on success)
response.error // => null (on success) or Error (on failure)