jsonrpc

package
v0.1.0-alpha.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL