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)
522
+
returnmcp.NewToolResultError("failed to get file contents"), nil
468
523
}
469
-
returnmcp.NewToolResultError(fmt.Sprintf("failed to get file contents: %s", string(body))), nil
470
-
}
524
+
deferfunc() { _=resp.Body.Close() }()
471
525
472
-
varresultinterface{}
473
-
iffileContent!=nil {
474
-
result=fileContent
475
-
} else {
476
-
result=dirContent
477
-
}
526
+
ifresp.StatusCode!=200 {
527
+
body, err:=io.ReadAll(resp.Body)
528
+
iferr!=nil {
529
+
returnmcp.NewToolResultError("failed to read response body"), nil
530
+
}
531
+
returnmcp.NewToolResultError(fmt.Sprintf("failed to get file contents: %s", string(body))), nil
532
+
}
478
533
479
-
r, err:=json.Marshal(result)
480
-
iferr!=nil {
481
-
returnnil, fmt.Errorf("failed to marshal response: %w", err)
534
+
r, err:=json.Marshal(dirContent)
535
+
iferr!=nil {
536
+
returnmcp.NewToolResultError("failed to marshal response"), nil
537
+
}
538
+
returnmcp.NewToolResultText(string(r)), nil
482
539
}
483
-
484
-
returnmcp.NewToolResultText(string(r)), nil
540
+
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