-
Notifications
You must be signed in to change notification settings - Fork 736
Closed as not planned
Description
Problem Statement
I want to access JSONRPCResponse.Error.Code in requests like CallTool, which would be very helpful for determining the error type, but currently only JSONRPCResponse.Error.Message is exposed...
// sendRequest sends a JSON-RPC request to the server and waits for a response.
// Returns the raw JSON response message or an error if the request fails.
func (c *Client) sendRequest(
ctx context.Context,
method string,
params any,
) (*json.RawMessage, error) {
if !c.initialized && method != "initialize" {
return nil, fmt.Errorf("client not initialized")
}
id := c.requestID.Add(1)
request := transport.JSONRPCRequest{
JSONRPC: mcp.JSONRPC_VERSION,
ID: mcp.NewRequestId(id),
Method: method,
Params: params,
}
response, err := c.transport.SendRequest(ctx, request)
if err != nil {
return nil, fmt.Errorf("transport error: %w", err)
}
if response.Error != nil {
return nil, errors.New(response.Error.Message)
}
return &response.Result, nil
}
Proposed Solution
Wrap an error struct in the returned error, then the outside code can unwrap it.
rodriguezmanueljoaquin, gianniboccazzi and shwann
Metadata
Metadata
Assignees
Labels
No labels