Documentation
¶
Overview ¶
Package jsonrpc defines minimal JSON-RPC 2.0 envelopes used by mcpbench and a lock-free monotonically increasing correlation-id allocator.
Index ¶
Constants ¶
const Version = "2.0"
Version is the JSON-RPC protocol version string.
Variables ¶
var ErrUnknownID = errors.New("jsonrpc: unknown response id")
ErrUnknownID is returned when demuxing a response whose id is not registered.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
Error is the error field inside a JSON-RPC response.
type IDPool ¶
type IDPool struct {
// contains filtered or unexported fields
}
IDPool allocates monotonically increasing correlation IDs starting at 1.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
}
Request represents a single JSON-RPC 2.0 request envelope.
func NewRequest ¶
NewRequest constructs a valid JSON-RPC request envelope.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response represents a single JSON-RPC 2.0 response envelope.
func ParseResponse ¶
ParseResponse parses a single JSON-RPC response frame.
type ToolCallParams ¶
type ToolCallParams struct {
Name string `json:"name"`
Arguments map[string]any `json:"arguments,omitempty"`
}
ToolCallParams is the MCP tools/call params shape.