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