10000 get_file_contents accepts a ref instead of just branch by tonytrg · Pull Request #558 · github/github-mcp-server · GitHub
[go: up one dir, main page]

Skip to content

get_file_contents accepts a ref instead of just branch #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 23, 2025

Conversation

tonytrg
Copy link
Contributor
@tonytrg tonytrg commented Jun 20, 2025

#get_file_contents now accepts:

  • refs
  • sha

instead of just branches.

Closes: #539

@tonytrg tonytrg marked this pull request as ready for review June 23, 2025 08:20
@Copilot Copilot AI review requested due to automatic review settings June 23, 2025 08:20
@tonytrg tonytrg requested a review from a team as a code owner June 23, 2025 08:20
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR expands get_file_contents to accept arbitrary git refs and SHAs rather than only branches.

  • Replaces the branch parameter with ref and sha in the tool’s schema
  • Updates GetFileContents logic to handle ref, sha, and special pull-request refs
  • Refreshes tests and snapshots to assert ref/sha instead of branch

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/github/repositories.go Swapped out branch schema, added ref/sha handling and PR logic
pkg/github/repositories_test.go Updated tests to check for ref/sha instead of branch
pkg/github/toolsnaps/get_file_contents.snap Removed branch from snapshot and added ref/sha properties
Comments suppressed due to low confidence (2)

pkg/github/repositories_test.go:84

  • There are no tests covering the new sha parameter or the pull-request ref branch. Consider adding a test case that passes a sha directly and one for a refs/pull/<n>/head to verify the override logic.
				"ref":   "refs/heads/main",

pkg/github/repositories.go:473

  • The code calls fmt.Errorf but I don't see an import for "fmt" in this diff. Please ensure that "fmt" is imported to avoid a compile error.
						return nil, fmt.Errorf("failed to get GitHub client: %w", err)

@almaleksia
Copy link

Howdy 👋

Can we make the change backwards compatible because we depend on this tool: https://github.com/github/sweagentd/pull/3357

@@ -6,10 +6,6 @@
"description": "Get the contents of a file or directory from a GitHub repository",
"inputSchema": {
"properties": {
"branch": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as an aside, I think it's really nice to look at the snapshot to see the structural changes that have occurred without looking at the imperative tool handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, just looking at the files commit history is pretty great way to check user faced changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will use this for 1p clients to help them understand the diff.

@SamMorrowDrums SamMorrowDrums merged commit b2901e1 into main Jun 23, 2025
16 checks passed
@SamMorrowDrums SamMorrowDrums deleted the tonytrg/add-flexible-ref branch June 23, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visual Studio Copilot cannot retrieve files by tag
4 participants
0