Repository navigation
feat: Support choosing the merge commit author email - #3852
Arham-Begani wants to merge 2 commits into
Conversation
Add optional author_email to merge_pull_request and use GraphQL when it is non-empty, preserving commit metadata, expected head SHA, and the existing response fields. Keep REST behavior for existing callers and surface GraphQL failures without retrying through REST. Add MCP protocol and REST regression coverage, the tool snapshot, README documentation, and authoring-skill guidance. Prepared with AI assistance from Codex and independently reviewed by a separate read-only agent. Fixes github#3814
There was a problem hiding this comment.
🟡 Changes recommended
An unchecked integer conversion can wrap an oversized pull request number to a different valid PR number, potentially merging the wrong pull request instead of rejecting the input.
1 open issue
What changed in this PR
Adds optional author_email support to merge_pull_request, addressing #3814 so callers can select the email associated with a merge commit.
Changes:
- Uses GraphQL when a nonempty email is supplied, forwarding merge options and the expected-head guard without falling back to REST on failure.
- Preserves REST behavior for omitted or empty emails and maintains existing response formats.
- Adds regression tests and updates the schema snapshot, generated documentation, and bundled skill guidance.
| File | Description |
|---|---|
| README.md | Documents the optional author_email argument. |
| pkg/skills/catalog/skills/pull-request-authoring/SKILL.md | Explains email selection and handling rejected emails. |
| pkg/github/pullrequests.go | Adds the schema argument and GraphQL merge path. |
| pkg/github/pullrequests_test.go | Checks schema inclusion and empty-email REST behavior. |
| pkg/github/pullrequests_merge_author_test.go | Tests GraphQL inputs, errors, and response compatibility. |
| pkg/github/consolidated_pull_request_types.go | Adds typed input and argument normalization. |
| pkg/github/__toolsnaps__/merge_pull_request.snap | Records the updated tool schema. |
Review effort: Balanced (dynamic)
| err = client.Query(ctx, &query, map[string]any{ | ||
| "owner": githubv4.String(input.Owner), | ||
| "repo": githubv4.String(input.Repo), | ||
| "prNum": githubv4.Int(input.PullNumber), // #nosec G115 - pull request numbers are always small positive integers |
There was a problem hiding this comment.
Fixed in 83751e9. The GraphQL merge path now rejects pull numbers outside 1–2147483647 before acquiring the client or converting the number. The regression reproduced 4294967338 wrapping to 42 before the fix; invalid inputs now make zero GitHub requests. Tests cover both boundaries and numeric-string inputs on modern and legacy MCP protocols.
Local lint and the full race-enabled suite pass across 32 test-bearing packages. The seven workflows on this head still await maintainer authorization, so upstream CI has not run. AI assistance: Codex helped implement and test the correction and prepare this reply.
Reject pull request numbers outside the positive GraphQL Int range before any API request. Cover boundary values and numeric strings through MCP, and require invalid inputs to make no GitHub requests on either protocol. AI assistance: Codex (GPT-6).

Summary
Allow
merge_pull_requestcallers to choose the merge commit's author email with an optionalauthor_emailargument. Calls that omit the email retain the existing REST merge path.Why
Fixes #3814. Accounts with multiple verified email addresses need to select the appropriate work or noreply address when merging through MCP, as they can in GitHub's web UI.
What changed
mergePullRequestwhen a nonempty email is supplied, forwarding the commit title, message, merge method and expected head SHA. Return GraphQL failures directly without retrying the merge through REST.MCP impact
Prompts tested (tool changes only)
Automated tests invoke the tool through an in-memory MCP client with mocked GitHub endpoints. They cover selecting an email for merge, squash and rebase; commit metadata; the head-SHA guard; invalid-email/API errors; missing results; and legacy/modern output compatibility. Existing REST cases and an explicitly empty email are also covered.
No natural-language client prompt or live GitHub merge was executed. The tests verify the actual MCP request/response boundary and GitHub request construction.
Security / limits
Tool renaming
Lint & tests
script/lint— 0 issues.script/testusing scopedGOFLAGS='-p=2 -timeout=25m'— all 32 test-bearing packages pass.The original direct-handler regression failed before implementation because the request still reached REST. The focused MCP-client and REST tests pass. The first full race-enabled run reached the default 10-minute timeout in the existing all-tools schema-parity matrix; no assertion or race failure was reported. The full rerun passes with the scoped 25-minute timeout (
pkg/github: 1054.237 seconds). Repository tests and CI timeouts are unchanged.Documentation generation, the server build, tool catalog and skill-instruction checks pass. The full
UPDATE_TOOLSNAPS=true go test ./...run also passes with the same local timeout (32 test-bearing packages).The real UI type check and build pass.
npm auditreports four existing dependency advisories (two low, two high); package manifests and lockfiles are unchanged. Live authenticated E2E tests were not run.Docs
Skills
AI assistance: Codex assisted with the implementation, tests and this description. The diff also received an independent read-only AI review.