Skip to content

Commit 57d2eb6

Browse files
committed
inline jsonRPCError
1 parent 29500f6 commit 57d2eb6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

internal/mcp/mcp_request.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ import (
1515

1616
const McpURLPath = ".api/mcp/v1"
1717

18-
type jsonRPCError struct {
19-
Code int `json:"code"`
20-
Message string `json:"message"`
21-
}
22-
2318
func FetchToolDefinitions(ctx context.Context, client api.Client) (map[string]*ToolDef, error) {
2419
resp, err := doJSONRPC(ctx, client, "tools/list", nil)
2520
if err != nil {
@@ -34,7 +29,10 @@ func FetchToolDefinitions(ctx context.Context, client api.Client) (map[string]*T
3429

3530
var rpcResp struct {
3631
Result json.RawMessage `json:"result"`
37-
Error *jsonRPCError `json:"error"`
32+
Error *struct {
33+
Code int `json:"code"`
34+
Message string `json:"message"`
35+
} `json:"error,omitempty"`
3836
}
3937
if err := json.Unmarshal(data, &rpcResp); err != nil {
4038
return nil, errors.Wrap(err, "failed to unmarshal JSON-RPC response")
@@ -114,7 +112,10 @@ func DecodeToolResponse(resp *http.Response) (map[string]json.RawMessage, error)
114112
Content []json.RawMessage `json:"content"`
115113
StructuredContent map[string]json.RawMessage `json:"structuredContent"`
116114
} `json:"result"`
117-
Error *jsonRPCError `json:"error"`
115+
Error *struct {
116+
Code int `json:"code"`
117+
Message string `json:"message"`
118+
} `json:"error,omitempty"`
118119
}{}
119120
if err := json.Unmarshal(data, &jsonRPCResp); err != nil {
120121
return nil, errors.Wrapf(err, "failed to unmarshal MCP JSON-RPC response")

0 commit comments

Comments
 (0)