package mcp import ( "encoding/json" "fmt" ) // Request is a JSON-RPC 2.0 request. type Request struct { JSONRPC string `json:"jsonrpc"` ID int64 `json:"id"` Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` } // Response is a JSON-RPC 2.0 response. type Response struct { JSONRPC string `json:"jsonrpc"` ID int64 `json:"id"` Result json.RawMessage `json:"result,omitempty"` Error *RPCError `json:"error,omitempty"` } // Notification is a JSON-RPC 2.0 notification (no ID, no response expected). type Notification struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` } // RPCError is the JSON-RPC 2.0 error object. type RPCError struct { Code int `json:"code"` Message string `json:"message"` Data json.RawMessage `json:"data,omitempty"` } func (e *RPCError) Error() string { return fmt.Sprintf("rpc error %d: %s", e.Code, e.Message) }