http/jsonrpc.ts

JSON-RPC 2.0 envelope schemas for RPC dispatch and SAES transport.

Params are object-only following MCP (no positional arrays); per-action spec.input narrows further. Result is the full JSON-RPC valid value space per spec §5 ("determined by the method invoked"): object, array, string, number, boolean, or null — the per-action spec.output is the actual contract. The envelope-level loose-object-only constraint inherited from MCP would reject any action with output: z.null() / z.string() / etc. on the wire, so we relax it here while keeping MCP-superset shape on params + _meta.

MCP _meta types (JsonrpcMcpMeta, JsonrpcRequestParamsMeta) are exported as building blocks for per-action schemas but are NOT validated at the envelope level — _meta content validation belongs in per-action schemas where it produces the correct error code (invalid_params, not invalid_request).

@source https://github.com/modelcontextprotocol/typescript-sdk @see https://www.jsonrpc.org/specification

view source

Declarations
#

27 declarations

JSONRPC_INTERNAL_ERROR
#

JSONRPC_INVALID_PARAMS
#

JSONRPC_INVALID_REQUEST
#

JSONRPC_METHOD_NOT_FOUND
#

JSONRPC_PARSE_ERROR
#

JSONRPC_SERVER_ERROR_END
#

http/jsonrpc.ts view source

-32099 import {JSONRPC_SERVER_ERROR_END} from '@fuzdev/fuz_app/http/jsonrpc.js';

End of the server-defined error code range (-32099).

JSONRPC_SERVER_ERROR_START
#

http/jsonrpc.ts view source

-32000 import {JSONRPC_SERVER_ERROR_START} from '@fuzdev/fuz_app/http/jsonrpc.js';

Start of the server-defined error code range (-32000).

JSONRPC_VERSION
#

JsonrpcErrorCode
#

http/jsonrpc.ts view source

value + type

-32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<"JsonrpcServerErrorCode">)

type -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<"JsonrpcServerErrorCode">)

import {JsonrpcErrorCode} from '@fuzdev/fuz_app/http/jsonrpc.js';

A valid JSON-RPC error code — one of the 5 standard codes or a server-defined code in the -32000 to -32099 range.

JsonrpcErrorObject
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; code: -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<"JsonrpcServerErrorCode">); message: string; data?: unknown; } import {JsonrpcErrorObject} from '@fuzdev/fuz_app/http/jsonrpc.js';

Error object within a JSON-RPC error response.

code

type -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<"JsonrpcServerErrorCode">)

message

type string

data?

type unknown

[key: string]

type unknown

JsonrpcErrorResponse
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number | null; error: { [x: string]: unknown; code: -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<"JsonrpcServerErrorCode">); message: string; data?: unknown; }; } import {JsonrpcErrorResponse} from '@fuzdev/fuz_app/http/jsonrpc.js';

A response that indicates an error occurred.

jsonrpc

type "2.0"

id

type string | number | null

error

type JsonrpcErrorObject

[key: string]

type unknown

JsonrpcMcpMeta
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; } import {JsonrpcMcpMeta} from '@fuzdev/fuz_app/http/jsonrpc.js';

MCP metadata object — loose to allow additional properties and .extend.

[key: string]

type unknown

JsonrpcMessage
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; } | undefined; } | { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: JSONType; } | { ...; } | { ...; }

type JsonrpcRequest | JsonrpcResponse | JsonrpcErrorResponse | JsonrpcNotification

import {JsonrpcMessage} from '@fuzdev/fuz_app/http/jsonrpc.js';

Any valid JSON-RPC message (request, notification, response, or error response).

JsonrpcMessageFromClientToServer
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; } | undefined; } | { [x: string]: unknown; jsonrpc: "2.0"; method: string; params?: { [x: string]: unknown; } | undefined; }

type JsonrpcRequest | JsonrpcNotification

import {JsonrpcMessageFromClientToServer} from '@fuzdev/fuz_app/http/jsonrpc.js';

Messages a client can send to a server (request or notification).

JsonrpcMessageFromServerToClient
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: JSONType; } | { [x: string]: unknown; jsonrpc: "2.0"; id: string | number | null; error: { [x: string]: unknown; code: -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<...>); message: string; data?: unknown; }; } | { ...; }

type JsonrpcResponse | JsonrpcErrorResponse | JsonrpcNotification

import {JsonrpcMessageFromServerToClient} from '@fuzdev/fuz_app/http/jsonrpc.js';

Messages a server can send to a client (notification, response, or error response).

JsonrpcMethod
#

http/jsonrpc.ts view source

value + type

string import {JsonrpcMethod} from '@fuzdev/fuz_app/http/jsonrpc.js';

A JSON-RPC method name.

JsonrpcNotification
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; method: string; params?: { [x: string]: unknown; } | undefined; } import {JsonrpcNotification} from '@fuzdev/fuz_app/http/jsonrpc.js';

A notification which does not expect a response.

jsonrpc

type "2.0"

method

type string

params?

type JsonrpcNotificationParams

[key: string]

type unknown

JsonrpcNotificationParams
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; } import {JsonrpcNotificationParams} from '@fuzdev/fuz_app/http/jsonrpc.js';

Notification params — loose object. Per-action schemas validate _meta content.

[key: string]

type unknown

JsonrpcProgressToken
#

http/jsonrpc.ts view source

value + type

string | number

type string | number

import {JsonrpcProgressToken} from '@fuzdev/fuz_app/http/jsonrpc.js';

A progress token, used to associate progress notifications with the original request.

JsonrpcRequest
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; } | undefined; } import {JsonrpcRequest} from '@fuzdev/fuz_app/http/jsonrpc.js';

A request that expects a response.

jsonrpc

type "2.0"

id

type string | number

method

type string

params?

type JsonrpcRequestParams

[key: string]

type unknown

JsonrpcRequestId
#

http/jsonrpc.ts view source

value + type

string | number

type string | number

import {JsonrpcRequestId} from '@fuzdev/fuz_app/http/jsonrpc.js';

A uniquely identifying id for a request in JSON-RPC. Like MCP, excludes null.

JsonrpcRequestParams
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; } import {JsonrpcRequestParams} from '@fuzdev/fuz_app/http/jsonrpc.js';

Request params — loose object. Per-action schemas validate _meta content.

[key: string]

type unknown

JsonrpcRequestParamsMeta
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; progressToken?: string | number | undefined; } import {JsonrpcRequestParamsMeta} from '@fuzdev/fuz_app/http/jsonrpc.js';

Request params metadata — extends MCP meta with optional progress token.

progressToken?

If specified, the caller is requesting out-of-band progress notifications for this request. The value is an opaque token attached to subsequent notifications. The receiver is not obligated to provide these notifications.

type string | number

[key: string]

type unknown

JsonrpcResponse
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: JSONType; } import {JsonrpcResponse} from '@fuzdev/fuz_app/http/jsonrpc.js';

A successful (non-error) response to a request.

jsonrpc

type "2.0"

id

type string | number

result

type JSONType

[key: string]

type unknown

JsonrpcResponseOrError
#

http/jsonrpc.ts view source

value + type

{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: JSONType; } | { [x: string]: unknown; jsonrpc: "2.0"; id: string | number | null; error: { [x: string]: unknown; code: -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<...>); message: string; data?: unknown; }; }

type JsonrpcResponse | JsonrpcErrorResponse

import {JsonrpcResponseOrError} from '@fuzdev/fuz_app/http/jsonrpc.js';

A successful response or an error response.

JsonrpcResult
#

http/jsonrpc.ts view source

value + type

JSONType

type JSONType

import {JsonrpcResult} from '@fuzdev/fuz_app/http/jsonrpc.js';

Result — any JSON value per JSON-RPC 2.0 §5. Per-action spec.output is the actual contract; the envelope only asserts presence + JSON-ness.

z.json() is required (not implicitly optional like z.unknown() / z.any(), which would let an error envelope {jsonrpc, id, error} parse successfully against the success envelope and break union discrimination).

JsonrpcServerErrorCode
#

http/jsonrpc.ts view source

value + type

number & $brand<"JsonrpcServerErrorCode">

type number & $brand<"JsonrpcServerErrorCode">

import {JsonrpcServerErrorCode} from '@fuzdev/fuz_app/http/jsonrpc.js';

A server-defined error code in the -32000 to -32099 range.

external types

z.infer<typeof JsonrpcServerErrorCode>

Imported by
#