Skip to content

Messages ​

Category: Jsonrpc

Source: messages.dart

JSON-RPC 2.0 message types, shared between the ACP and MCP servers.

Pure data — no I/O, no transport. See codec.dart for serialization and transport/stdio.dart for line-delimited framing.

Classes ​

sealed JsonRpcMessage ​

Sealed type for all JSON-RPC messages flowing in either direction.

Constructor ​

dart
const JsonRpcMessage()

JsonRpcRequest ​

A JSON-RPC request — has an [id] and expects a [JsonRpcResponse].

Constructor ​

dart
const JsonRpcRequest({required this.id, required this.method, this.params})

Properties ​

PropertyTypeDescription
idObjectEither an int or a String per JSON-RPC 2.0 §3.
methodString
paramsMap<String, Object?>?

JsonRpcNotification ​

A JSON-RPC notification — no [id], no response expected.

Constructor ​

dart
const JsonRpcNotification({required this.method, this.params})

Properties ​

PropertyTypeDescription
methodString
paramsMap<String, Object?>?

JsonRpcResponse ​

A successful response.

Constructor ​

dart
const JsonRpcResponse({required this.id, required this.result})

Properties ​

PropertyTypeDescription
idObject
resultObject?

JsonRpcError ​

An error response.

Constructor ​

dart
const JsonRpcError({
    required this.id,
    required this.code,
    required this.message,
    this.data,
  })

Properties ​

PropertyTypeDescription
idObject?Null only for parse errors that arrive before we can read the id.
codeint
messageString
dataObject?

abstract JsonRpcErrorCode ​

Standard JSON-RPC 2.0 error codes (§5.1) plus a Glue-reserved range.

Properties ​

PropertyTypeDescription
parseErrorconst intInvalid JSON received by the server.
invalidRequestconst intThe JSON sent is not a valid Request object.
methodNotFoundconst intThe method does not exist or is not available.
invalidParamsconst intInvalid method parameter(s).
internalErrorconst intInternal JSON-RPC error.
permissionDeniedconst intGlue-reserved: the user denied a permission request that gated this method. ACP/MCP both surface permission denial through this code.
sessionNotFoundconst intGlue-reserved: the requested session ID is unknown or has been closed.
cancelledconst intGlue-reserved: the agent's prompt loop was cancelled (matching session/cancel).

Released under the MIT License.