Repository navigation
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| } | ||
| } `graphql:"enablePullRequestAutoMerge(input: $input)"` | ||
| } | ||
| if err := client.Mutate(ctx, &mutation, mutationInput, nil); err != nil { |
There was a problem hiding this comment.
🔵 Needs a closer look
The new write tool authorizes future repository merges, extending effects beyond the current call and introducing authorization, branch-protection, and later-head-change interactions that warrant human review.
No open issues 🎉
What changed in this PR
Adds enable_pull_request_auto_merge behind the pull_requests_granular feature flag, letting agents schedule a merge once GitHub’s requirements are met rather than merge immediately.
Changes:
- Implements the GraphQL mutation using the existing merge tool’s input schema.
- Adds coverage for argument mapping, errors, feature gating, protocol output, and tool snapshots.
- Updates the pull-request-authoring skill and generated feature-flag documentation.
| File | Description |
|---|---|
pkg/skills/catalog/tools.go |
Adds auto-merge to the authoring skill’s optional tools. |
pkg/skills/catalog/skills/pull-request-authoring/SKILL.md |
Explains auto-merge behavior and required user confirmation. |
pkg/github/typed_granular_pull_request_outputs_test.go |
Covers typed protocol output and error handling. |
pkg/github/tools.go |
Registers the new tool. |
pkg/github/pullrequests.go |
Extracts the shared merge input schema. |
pkg/github/pull_request_auto_merge.go |
Implements validation, GraphQL calls, and feature gating. |
pkg/github/pull_request_auto_merge_test.go |
Tests defaults, options, failures, and feature gating. |
pkg/github/granular_tools_test.go |
Updates expected granular tool availability. |
pkg/github/__toolsnaps__/enable_pull_request_auto_merge.snap |
Records the new tool’s schema and metadata. |
docs/feature-flags.md |
Documents the tool’s inputs and required scope. |
Review effort: Balanced (adaptive)
| ToolsetMetadataPullRequests, | ||
| mcp.Tool{ | ||
| Name: "enable_pull_request_auto_merge", | ||
| Description: t("TOOL_ENABLE_PULL_REQUEST_AUTO_MERGE_DESCRIPTION", "Enable auto-merge for a pull request when GitHub's merge requirements are met. If merge_method is omitted, GitHub defaults to merge."), |
There was a problem hiding this comment.
Updated the tool description to say it is for pull requests that cannot be merged immediately because requirements are pending, and regenerated the snapshot (83d4823). script/test and snapshot regeneration passed; script/lint could not download its linter because DNS resolution failed, so hosted lint remains to be evaluated.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
|
||
| // EnablePullRequestAutoMerge creates a tool to enable auto-merge for a pull request. | ||
| func EnablePullRequestAutoMerge(t translations.TranslationHelperFunc) inventory.ServerTool { | ||
| st := NewTool[MergePullRequestInput, *RepositoryMessageOutput]( |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| ) | ||
|
|
||
| // EnablePullRequestAutoMerge creates a tool to enable auto-merge for a pull request. | ||
| func EnablePullRequestAutoMerge(t translations.TranslationHelperFunc) inventory.ServerTool { |

Summary
Add a tool to enable auto-merge behind the
pull_requests_granularfeature flag and expose its state when reading a pull request.Why
Agents currently have a tool to merge immediately but cannot schedule a merge after GitHub's requirements are met. No linked issue.
What changed
enable_pull_request_auto_merge, using GitHub's GraphQL mutation and matchingmerge_pull_request's input schema.auto_mergestate, merge method, and enabler topull_request_read'sgetresponse without changing list responses.MCP impact
The new write tool is available only when
pull_requests_granularis enabled. GitHub defaults to themergemethod if none is supplied.pull_request_readreturnsauto_merge: nullwhen disabled or an object when enabled.Prompts tested (tool changes only)
pull_request_readresults across supported protocol versions.tools/callrequests against GitHub from a locally built server at PR head83d4823, withpull_requests_granularenabled:merge_method: squashand the currentexpectedHeadShasucceeded. GitHub confirmed auto-merge was enabled; it was then disabled and confirmed off.expectedHeadShawas rejected and left auto-merge disabled.MERGE.Security / limits
The tool requires the
reposcope; GitHub enforces repository permissions and auto-merge eligibility. An expected head SHA can guard against enabling auto-merge on a changed head.Tool renaming
deprecated_tool_aliases.goNo existing tools were renamed.
Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.
Lint & tests
./script/lint— passed../script/test— passed.Also passed:
UPDATE_TOOLSNAPS=true go test ./...andscript/generate-docs.go build -o /root/.copilot/session-state/bd4800d3bbe24f9d8fc6e277cef7753b/files/github-mcp-auto-merge ./cmd/github-mcp-server— passed for the live MCP tests above.Docs
Regenerated
docs/feature-flags.mdwith the new tool.Skills
Updated the pull-request-authoring skill and its tool catalog.