jsonrpc

package
v1.9.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0, CC-BY-4.0, MIT Imports: 1 Imported by: 363 modules, 154 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsonrpc exposes part of a JSON-RPC v2 implementation for use by mcp transport authors.

Index

Constants

View Source
const (
	// CodeParseError indicates invalid JSON was received by the server.
	CodeParseError = -32700
	// CodeInvalidRequest indicates the JSON sent is not a valid Request object.
	CodeInvalidRequest = -32600
	// CodeMethodNotFound indicates the method does not exist or is not available.
	CodeMethodNotFound = -32601
	// CodeInvalidParams indicates invalid method parameter(s).
	CodeInvalidParams = -32602
	// CodeInternalError indicates an internal JSON-RPC error.
	CodeInternalError = -32603
)

Standard JSON-RPC 2.0 error codes. See https://www.jsonrpc.org/specification#error_object

Variables

This section is empty.

Functions

func EncodeMessage added in v0.3.0

func EncodeMessage(msg Message) ([]byte, error)

EncodeMessage serializes a JSON-RPC message to its wire format.

Types

type Error added in v1.2.0

type Error = jsonrpc2.WireError

Error is a structured error in a JSON-RPC response.

type ID

type ID = jsonrpc2.ID

ID is a JSON-RPC request ID.

func MakeID added in v0.3.0

func MakeID(v any) (ID, error)

MakeID coerces the given Go value to an ID. The value should be the JSON decoding of a Request identifier: nil, float64, json.Number, or string. Decoding with json.Number keeps integer IDs above 2^53 exact; a json.Number must be an integer literal in the int64 range.

Returns an error if the value type was not a valid Request ID type.

type Message

type Message = jsonrpc2.Message

Message is a JSON-RPC message.

func DecodeMessage added in v0.3.0

func DecodeMessage(data []byte) (Message, error)

DecodeMessage deserializes JSON-RPC wire format data into a Message. It returns either a Request or Response based on the message content.

type Request

type Request = jsonrpc2.Request

Request is a JSON-RPC request.

type Response

type Response = jsonrpc2.Response

Response is a JSON-RPC response.

Jump to

Keyboard shortcuts

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