feat: Add get_commits method to pull_request_read#2608
Open
RossTarrant wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new get_commits method to the existing pull_request_read tool so agents can list commits on a pull request with a compact, PR-focused response shape.
Changes:
- Extended
pull_request_readwithmethod: "get_commits"and implementedGetPullRequestCommitsusingclient.PullRequests.ListCommits()with existing page/perPage pagination. - Introduced
MinimalPullRequestCommitand conversion helpers to return a lightweight commit list (sha, html_url, message, author). - Added unit tests plus updated the toolsnap and generated README tool docs to reflect the new method.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new get_commits method under pull_request_read. |
| pkg/github/pullrequests.go | Adds the get_commits dispatch case and implements GetPullRequestCommits. |
| pkg/github/pullrequests_test.go | Adds unit coverage for get_commits (success, pagination, error). |
| pkg/github/minimal_types.go | Adds MinimalPullRequestCommit and conversion logic for PR commit listing output. |
| pkg/github/helper_test.go | Adds the REST route constant for the PR commits endpoint used by mocks. |
| pkg/github/toolsnaps/pull_request_read.snap | Updates tool schema snapshot to include get_commits. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
get_commitsmethod topull_request_readso agents can list commits on a pull request. The response uses a compact PR-specific commit summary to keep the payload focused on commit-message review workflows.Why
Fixes #2368
Review agents need access to the commits on a pull request so they can validate commit messages, for example checking whether commits follow Conventional Commits or another repository-specific format.
What changed
pull_request_readmethodget_commits.client.PullRequests.ListCommits()with existingpage/perPagepagination support.MinimalPullRequestCommitfor a compact commit-list response.pull_request_readtoolsnap and generated README docs.Response shape tradeoff
This PR uses a new lightweight
MinimalPullRequestCommitinstead of reusing the existingMinimalCommittype used by repository commit tools.MinimalCommitis a better fit for detailed commit views likeget_commit, where nested git metadata, resolved GitHub users, stats, and files are useful.For PR commit listing, the primary use case is commit-message inspection across multiple commits, so the new type avoids repeated
author/committerblocks and resolved profile data that can quickly consume context without helping that workflow. If future use cases need richer commit details, callers can still fetch an individual commit through the existing repository commit tools.Example tool/method response
[ { "sha": "b1c3b16910cfa89f7d2f19e1c31b8db143938450", "html_url": "https://github.com/github/github-mcp-server/commit/b1c3b16910cfa89f7d2f19e1c31b8db143938450", "message": "feat: add pull request commit listing", "author": { "name": "Octocat", "email": "octocat@github.com", "date": "2026-06-05T08:30:00Z" } } ]MCP impact
pull_request_readnow acceptsmethod: "get_commits"and returns a compact list of PR commits.Prompts tested (tool changes only)
Security / limits
reposcope required bypull_request_read.Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs