You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnnil, fmt.Errorf("failed to read response body: %w", err)
521
+
returnmcp.NewToolResultError("failed to get file contents"), nil
468
522
}
469
-
returnmcp.NewToolResultError(fmt.Sprintf("failed to get file contents: %s", string(body))), nil
470
-
}
523
+
deferfunc() { _=resp.Body.Close() }()
471
524
472
-
varresultinterface{}
473
-
iffileContent!=nil {
474
-
result=fileContent
475
-
} else {
476
-
result=dirContent
477
-
}
525
+
ifresp.StatusCode!=200 {
526
+
body, err:=io.ReadAll(resp.Body)
527
+
iferr!=nil {
528
+
returnmcp.NewToolResultError("failed to read response body"), nil
529
+
}
530
+
returnmcp.NewToolResultError(fmt.Sprintf("failed to get file contents: %s", string(body))), nil
531
+
}
478
532
479
-
r, err:=json.Marshal(result)
480
-
iferr!=nil {
481
-
returnnil, fmt.Errorf("failed to marshal response: %w", err)
533
+
r, err:=json.Marshal(dirContent)
534
+
iferr!=nil {
535
+
returnmcp.NewToolResultError("failed to marshal response"), nil
536
+
}
537
+
returnmcp.NewToolResultText(string(r)), nil
482
538
}
483
-
484
-
returnmcp.NewToolResultText(string(r)), nil
539
+
returnmcp.NewToolResultError("Failed to get file contents. The path does not point to a file or directory, or the file does not exist in the repository."), nil
0 commit comments