jsonrpc

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(network, address string) (*rpc.Client, error)

func NewClient

func NewClient(conn Connection) *rpc.Client

Types

type Connection

type Connection interface {
	io.ReadWriteCloser
}

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

type ErrorCode

type ErrorCode int
const (
	ErrorCodeParseError     ErrorCode = -32700
	ErrorCodeInvalidRequest ErrorCode = -32600
	ErrorCodeMethodNotFound ErrorCode = -32601
	ErrorCodeInvalidParams  ErrorCode = -32602
	ErrorCodeInternalError  ErrorCode = -32603
	ErrorCodeServerError    ErrorCode = -32000
)

type ErrorInternalError

type ErrorInternalError error

type ErrorInvalidParams

type ErrorInvalidParams error

type ErrorInvalidRequest

type ErrorInvalidRequest error

type ErrorMethodNotFound

type ErrorMethodNotFound error

type ErrorParseError

type ErrorParseError error

type ErrorServerError

type ErrorServerError error

type Response

type Response struct {
	JSONRPC string           `json:"jsonrpc"`
	Result  any              `json:"result"`
	Error   *Error           `json:"error"`
	ID      *json.RawMessage `json:"id"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server embeds the rpc.Server. server is not exported, which inherently limits access to the server API. This is a deliberate and opinionated design decision to make the mcp implementation easier to understand and maintain.

func NewServer

func NewServer() *Server

NewServer creates a new json RPC server. The default codec is used to ensure that the server is compatible with the json RPC 2.0 spec. Again, this is a rigid, but intentional decision.

func (*Server) Register

func (s *Server) Register(rcvr any) error

Register registers a new object for use as a service. It is a wrapper around the rpc.Server.Register method.

func (*Server) Serve

func (s *Server) Serve(listener net.Listener) error

Jump to

Keyboard shortcuts

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