feat: Add get_commits method to pull_request_read#2608
Conversation
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
|
Rebased this branch onto latest
Copilot's nil-slice guard feedback is already addressed in 64d25a7. |
advancedresearcharray
left a comment
There was a problem hiding this comment.
Code review: implementation follows existing get_files patterns, compact response shape is well-motivated for commit-message review workflows, and test coverage looks solid (success, pagination, error, nil entry, omitted noisy fields).
Only blocker is the branch being 1 commit behind main — addressed via #2613.
SamMorrowDrums
left a comment
There was a problem hiding this comment.
Approved, I fixed the merge conflict so I will force merge with green CI
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