Skip to content

Commit d25e7a7

Browse files
authored
Merge branch 'main' into wb/tool-registry
2 parents 42ca15d + 97c3004 commit d25e7a7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cmd/src/mcp.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func mcpUsage() {
3232
}
3333

3434
func mcpMain(args []string) error {
35-
fmt.Println("NOTE: This command is still experimental")
3635
apiClient := cfg.apiClient(nil, mcpFlagSet.Output())
3736

3837
ctx := context.Background()

internal/mcp/mcp_request.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func decodeToolResponse(resp *http.Response) (map[string]json.RawMessage, error)
112112
Result struct {
113113
Content []json.RawMessage `json:"content"`
114114
StructuredContent map[string]json.RawMessage `json:"structuredContent"`
115+
IsError bool `json:"isError"`
115116
} `json:"result"`
116117
Error *struct {
117118
Code int `json:"code"`
@@ -125,6 +126,19 @@ func decodeToolResponse(resp *http.Response) (map[string]json.RawMessage, error)
125126
return nil, errors.Newf("MCP tools/call failed: %d %s", jsonRPCResp.Error.Code, jsonRPCResp.Error.Message)
126127
}
127128

129+
if jsonRPCResp.Result.IsError {
130+
if len(jsonRPCResp.Result.Content) > 0 {
131+
var textContent struct {
132+
Text string `json:"text"`
133+
}
134+
if err := json.Unmarshal(jsonRPCResp.Result.Content[0], &textContent); err == nil && textContent.Text != "" {
135+
return nil, errors.Newf("MCP tool error: %s", textContent.Text)
136+
}
137+
return nil, errors.Newf("MCP tool error: %s", string(jsonRPCResp.Result.Content[0]))
138+
}
139+
return nil, errors.New("MCP tool returned an error")
140+
}
141+
128142
return jsonRPCResp.Result.StructuredContent, nil
129143
}
130144
func readSSEResponseData(resp *http.Response) ([]byte, error) {

0 commit comments

Comments
 (0)