Documentation
¶
Overview ¶
Package jsonrpc provides shared JSON-RPC 2.0 types used by MCP and A2A protocols.
Index ¶
Constants ¶
View Source
const ( ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 )
Standard JSON-RPC error codes.
Variables ¶
This section is empty.
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 represents a JSON-RPC 2.0 error.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID *json.RawMessage `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request represents a JSON-RPC 2.0 request.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID *json.RawMessage `json:"id,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response represents a JSON-RPC 2.0 response.
func NewErrorResponse ¶
func NewErrorResponse(id *json.RawMessage, code int, message string) Response
NewErrorResponse creates a JSON-RPC error response.
func NewSuccessResponse ¶
func NewSuccessResponse(id *json.RawMessage, result any) Response
NewSuccessResponse creates a JSON-RPC success response.
Click to show internal directories.
Click to hide internal directories.