Skip to content

Commit 5badfe6

Browse files
committed
adding better response
1 parent 0188cc0 commit 5badfe6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/github/repositories.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t
542542

543543
// If the path is (most likely) not to be a directory, we will
544544
// first try to get the raw content from the GitHub raw content API.
545+
546+
var rawAPIResponseCode int
545547
if path != "" && !strings.HasSuffix(path, "/") {
546548
// First, get file info from Contents API to retrieve SHA
547549
var fileSHA string
@@ -631,8 +633,8 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t
631633
return mcp.NewToolResultResource(fmt.Sprintf("successfully downloaded binary file (SHA: %s)", fileSHA), result), nil
632634
}
633635
return mcp.NewToolResultResource("successfully downloaded binary file", result), nil
634-
635636
}
637+
rawAPIResponseCode = resp.StatusCode
636638
}
637639

638640
if rawOpts.SHA != "" {
@@ -677,7 +679,7 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t
677679
if err != nil {
678680
return mcp.NewToolResultError(fmt.Sprintf("failed to marshal resolved refs: %s", err)), nil
679681
}
680-
return mcp.NewToolResultText(fmt.Sprintf("Path did not point to a file or directory, but resolved git ref to %s with possible path matches: %s", resolvedRefs, matchingFilesJSON)), nil
682+
return mcp.NewToolResultText(fmt.Sprintf("Failed to get raw repository content with response %d, but resolved git ref to %s with possible path matches: %s", rawAPIResponseCode, resolvedRefs, matchingFilesJSON)), nil
681683
}
682684

683685
return mcp.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

Comments
 (0)