all: expose JSON-RPC error codes, and support URLElicitationRequired errors (#655)
Expose the jsonrpc.Error type to allow access to underlying JSON-RPC error codes. Also, expose common JSON-RPC error codes in the jsonrpc package, and MCP error codes in the mcp package. Also, implement support for the MCP URL elicitation required error (-32042), enabling servers to request out-of-band user authorization and clients to automatically handle these requests with retry logic. Server-side: - Add CodeURLElicitationRequired constant - Add URLElicitationRequiredError() constructor. Client-side: - Add urlElicitationMiddleware to intercept URLElicitationRequired errors and retry calls. - Update callElicitationCompleteHandler to signal waiting operations. - Fix capability advertisement to support both form and URL modes. Fixes #452 Fixes #623
This commit is contained in:
parent
96385fde3c
commit
2ce44d45e9
1 changed files with 670 additions and 44 deletions
|
|
@ -17,6 +17,8 @@ type (
|
|||
Request = jsonrpc2.Request
|
||||
// Response is a JSON-RPC response.
|
||||
Response = jsonrpc2.Response
|
||||
// Error is a structured error in a JSON-RPC response.
|
||||
Error = jsonrpc2.WireError
|
||||
)
|
||||
|
||||
// MakeID coerces the given Go value to an ID. The value should be the
|
||||
|
|
@ -37,3 +39,18 @@ func EncodeMessage(msg Message) ([]byte, error) {
|
|||
func DecodeMessage(data []byte) (Message, error) {
|
||||
return jsonrpc2.DecodeMessage(data)
|
||||
}
|
||||
|
||||
// Standard JSON-RPC 2.0 error codes.
|
||||
// See https://www.jsonrpc.org/specification#error_object
|
||||
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
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue