[Feat] Enable GitHub pull request auto-merge from sessions - #3134
Merged
mrubens merged 3 commits intoSep 22, 2026
Merged
Conversation
Contributor
roomote-roomote
Bot
requested review from
brunobergher,
daniel-lxs and
mrubens
as code owners
September 22, 2026 19:44
mrubens
deleted the
feat/github-pr-auto-merge-native-tool-0707ymnwzxhud
branch
September 22, 2026 19:45
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.
Related issue
Fixes #
Why this PR exists
What changed
Sessions (Fast) can now enable auto-merge on GitHub pull requests through a native
enable_pull_request_auto_mergetool on the GitHub MCP endpoint. GitHub's own MCP server has no auto-merge tool, so the endpoint answers this one in-process, mirroring the existing ADO/Gitea native merge handler conventions:expectedHeadShafrom a pull request read taken immediately before the call; the handler re-reads the pull request and rejects a closed, already merged, or head-moved pull request instead of acting on stale state.enablePullRequestAutoMergemutation and success is only reported when auto-merge is actually enabled (already-enabled pull requests reportalreadyEnabledwithout mutating).source_control_mcp_auto_merge_authorizedaudit event shape the ADO/Gitea merge handlers use.Fast guidance and the GitHub provider docs now name the capability and the fresh-read/head-SHA rule.
How it was tested
Added
apps/api/src/handlers/mcp/__tests__/github-auto-merge.test.ts(14 tests) covering tool discovery for members vs run tokens, schema/argument validation, member-only authorization, connected-repository requirement, stale-head race rejection, closed/merged rejection, auto-merge-disabled and unsupported-method errors, provider failure propagation, successful mutation with post-read verification, already-enabled idempotence, unconfirmed-mutation failure, and the audit event. Fullapps/api/src/handlers/mcpsuite (937 tests),pnpm lint,pnpm check-types,pnpm knip, and the docs Mintlify/broken-link check all pass.Checklist
[Fix],[Feat],[Improve],[Refactor],[Docs], or[Chore]followed by a user-facing descriptionpnpm lintandpnpm check-typespass locallypnpm changeset