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
Adds enable_pull_request_auto_merge and disable_pull_request_auto_merge tools to the pull requests toolset, wrapping the GraphQL enablePullRequestAutoMerge / disablePullRequestAutoMerge mutations so a PR can be set to merge automatically once its requirements are met — the MCP equivalent of gh pr merge --auto.
Real-world use case (the one that prompted this PR): an agent running a series of verified, test-only PRs through this MCP server needed "merge as they land and are checked." The only available tool was merge_pull_request — an immediate merge that bypasses checks still running — because auto-merge was unreachable through the server. With these tools, the agent (or a user) can set auto-merge and let GitHub land the PR when it is green.
On shape: #2411 proposes an enable_auto_merge method "or similar" on the pull request write tools. This PR implements standalone tools mirroring the existing merge_pull_request tool (which is itself standalone rather than a method of a consolidated write tool), and the GraphQL plumbing mirrors the hide/unhide comment tools, which exist for the same reason — a GraphQL-only capability. Happy to restructure if maintainers prefer the method form.
What changed
New pkg/github/pullrequest_auto_merge.go: both tools share a factory and handler. Each resolves the pull request's node ID via the REST API (PullRequests.Get), then runs the mutation through the existing GraphQL client.
Output: node_id, auto_merge_enabled, and (on enable) the merge_method GitHub recorded.
Registered both tools in pkg/github/tools.go, added an auto_merge argument spec in consolidated_pull_request_types.go, and added both tools to the pull-request-authoring skill's optional tools in pkg/skills/catalog/tools.go.
Unit tests (pullrequest_auto_merge_test.go) with mocked REST + GraphQL: enable with method/commit text, enable with defaults, disable, PR-not-found, and mutation-failure paths.
Tool snapshots generated; README/docs catalogs regenerated with script/generate-docs.
MCP impact
No tool or API changes
Tool schema or behavior changed
New tool added — two tools in the existing pull requests toolset; no existing tool changes behavior.
"Once CI passes, auto-merge this PR" — maps to enable_pull_request_auto_merge with defaults.
"Turn off auto-merge for PR [docker] build arm64 #42" — maps to disable_pull_request_auto_merge.
Handler behavior for each path is covered by the unit tests listed above (mocked REST + GraphQL).
Security / limits
No security or limits impact
Auth / permissions considered — both tools require the repo scope (scopes.RequireAll(scopes.Repo)), like merge_pull_request. GitHub enforces the repository's auto-merge setting and the caller's write access server-side; failures surface as tool errors.
Data exposure, filtering, or token/size limits considered
Tool renaming
I am renaming tools as part of this PR
I am not renaming tools as part of this PR
Lint & tests
Linted locally with ./script/lint — golangci-lint reports 0 issues.
Tested locally with ./script/test — full ./pkg/... ./internal/... suite passes, including the skills catalog coverage tests.
Docs
Not needed
Updated (README / docs / examples) — regenerated with script/generate-docs.
Skills
Updated relevant skills or confirmed no bundled skill applies — both tools added to the pull-request-authoring skill's optional tool list in the catalog; TestCatalogToolRequirementsAreRegistered and TestToolsetInstructionsAreCoveredBySkills pass.
Disclosure: this change was developed with AI (model) assistance, using the workflow described in #2411's own context — fittingly, the feature exists because an agent needed it. All code was built, tested, and linted locally per CONTRIBUTING.
Implements the enablePullRequestAutoMerge and disablePullRequestAutoMerge GraphQL mutations as two new tools in the pull requests toolset, following the standalone shape of merge_pull_request (upstream issue github#2411 proposes an enable_auto_merge method 'or similar').
Each tool resolves the pull request's node ID through the REST API, then runs the mutation through the existing GraphQL client, mirroring the hide/unhide comment tools. Enable accepts an optional merge_method (merge/squash/rebase) and merge commit title/message.
Includes unit tests (mocked REST + GraphQL), tool snapshots, skills catalog registration, and regenerated README/docs catalogs. Full pkg/internal test suite passes; golangci-lint reports 0 issues.
- Enable tool now sets destructiveHint: true (enabling auto-merge authorizes a later merge of the base branch); disable stays false. Enable snapshot regenerated.
- Mutation failures now use NewGitHubGraphQLErrorResponse instead of the REST error helper, matching comment_minimize.go, so GetGitHubGraphQLErrors consumers see enable/disable failures.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
When no merge method is specified, auto-merge uses GraphQL’s MERGE default rather than a repository-permitted method, causing the parameterless workflow to fail on squash- or rebase-only repositories.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Use the repository's merge method when none is specified
pkg/github/pullrequest_auto_merge.go:176
Issue #2411 specifies that an omitted merge method should use the repository setting, but this path leaves mergeMethod unset, which uses GraphQL's MERGE default. On a repository that permits only squash or rebase, the advertised parameterless workflow ("Once CI passes, auto-merge this PR") therefore fails despite an allowed merge method being available. Resolve a repository-permitted default when the argument is omitted, and update the default-path test and documentation accordingly.
…nable tool
Per the GraphQL schema, an omitted mergeMethod defaults to MERGE; on repositories that disallow merge commits the mutation fails with GitHub's error. Say so in the parameter description so callers pass a permitted method. Verified empirically on a squash-only repository (see PR discussion).
On the "previously missed" finding — use the repository's merge method when none is specified — we checked this against the schema docs and against a live repository before deciding. Summary: the finding's premise is correct, and the failure it predicts is real, but it surfaces as a loud, enable-time error from GitHub itself rather than a silent wrong-method merge, so we have documented the behavior instead of adding client-side method resolution. Details:
What the documentation says
The GraphQL reference for EnablePullRequestAutoMergeInput.mergeMethod says: "The merge method to use. If omitted, defaults to MERGE." There is no repository-aware default at the API layer; the "default to repo setting" phrasing in Add auto-merge support to pull request tools #2411 describes the web UI's behavior (it only offers permitted methods), not the mutation's.
Repository settings expose three independent booleans (allow_merge_commit, allow_squash_merge, allow_rebase_merge) — there is no single "repository merge method" value to resolve to — and branch rulesets can narrow the permitted methods further per branch, so a client-side resolver cannot reliably reproduce GitHub's own decision.
What actually happens (empirical)
We configured a scratch repository as squash-only (allow_merge_commit: false, allow_rebase_merge: false, auto-merge on, base branch held by a required check) and called the mutation with nomergeMethod. GitHub rejected it at enable time:
{"type": "UNPROCESSABLE", "path": ["enablePullRequestAutoMerge"],
"message": "Merge method merge commits are not allowed on this repository"}
So the disallowed-method case is validated by GitHub, immediately, with a specific message — and this tool returns that GraphQL error to the caller verbatim. No auto-merge is armed with a wrong method, and nothing fails later or silently. This is also the same contract as the sibling merge_pull_request tool, which leaves merge_method optional and lets GitHub refuse a disallowed method (e.g. 405 Merge commits are not allowed on this repository).
What we changed
Commit 9b621655 updates the merge_method parameter description on the enable tool to state the ground truth: if omitted, GitHub applies MERGE, which fails on repositories that do not allow merge commits, so callers should pass the method the repository permits.
If maintainers would still prefer client-side resolution of a permitted method when the argument is omitted, we are happy to implement it — it would need a policy for choosing when several methods are permitted (e.g. both squash and rebase), which is why we did not pick one unilaterally here.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The README description is out of sync with the updated merge_method schema, so the docs-check workflow will fail until the documentation is regenerated and committed.
The README's generated tool documentation still carried the pre-9b621655
merge_method wording for enable_pull_request_auto_merge. Regenerated
with generate-docs so the docs check passes.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The new tools authorize future base-branch merges and depend on GitHub repository rules and merge-queue semantics, exceeding the limited-consequence automated review scope and warranting human review.
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
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
enable_pull_request_auto_mergeanddisable_pull_request_auto_mergetools to the pull requests toolset, wrapping the GraphQLenablePullRequestAutoMerge/disablePullRequestAutoMergemutations so a PR can be set to merge automatically once its requirements are met — the MCP equivalent ofgh pr merge --auto.Why
Fixes #2411
Real-world use case (the one that prompted this PR): an agent running a series of verified, test-only PRs through this MCP server needed "merge as they land and are checked." The only available tool was
merge_pull_request— an immediate merge that bypasses checks still running — because auto-merge was unreachable through the server. With these tools, the agent (or a user) can set auto-merge and let GitHub land the PR when it is green.On shape: #2411 proposes an
enable_auto_mergemethod "or similar" on the pull request write tools. This PR implements standalone tools mirroring the existingmerge_pull_requesttool (which is itself standalone rather than a method of a consolidated write tool), and the GraphQL plumbing mirrors the hide/unhide comment tools, which exist for the same reason — a GraphQL-only capability. Happy to restructure if maintainers prefer the method form.What changed
pkg/github/pullrequest_auto_merge.go: both tools share a factory and handler. Each resolves the pull request's node ID via the REST API (PullRequests.Get), then runs the mutation through the existing GraphQL client.enable_pull_request_auto_merge:owner,repo,pullNumber(required); optionalmerge_method(merge/squash/rebase),commit_title,commit_message.disable_pull_request_auto_merge:owner,repo,pullNumber.node_id,auto_merge_enabled, and (on enable) themerge_methodGitHub recorded.pkg/github/tools.go, added anauto_mergeargument spec inconsolidated_pull_request_types.go, and added both tools to thepull-request-authoringskill's optional tools inpkg/skills/catalog/tools.go.pullrequest_auto_merge_test.go) with mocked REST + GraphQL: enable with method/commit text, enable with defaults, disable, PR-not-found, and mutation-failure paths.script/generate-docs.MCP impact
Prompts tested (tool changes only)
enable_pull_request_auto_mergewithmerge_method: "squash".enable_pull_request_auto_mergewith defaults.disable_pull_request_auto_merge.Security / limits
reposcope (scopes.RequireAll(scopes.Repo)), likemerge_pull_request. GitHub enforces the repository's auto-merge setting and the caller's write access server-side; failures surface as tool errors.Tool renaming
Lint & tests
./script/lint— golangci-lint reports 0 issues../script/test— full./pkg/... ./internal/...suite passes, including the skills catalog coverage tests.Docs
script/generate-docs.Skills
pull-request-authoringskill's optional tool list in the catalog;TestCatalogToolRequirementsAreRegisteredandTestToolsetInstructionsAreCoveredBySkillspass.Disclosure: this change was developed with AI (model) assistance, using the workflow described in #2411's own context — fittingly, the feature exists because an agent needed it. All code was built, tested, and linted locally per CONTRIBUTING.