Sitelet https://github.com/github/github-mcp-server/pull/3852
Skip to content

feat: Support choosing the merge commit author email - #3852

Open
Arham-Begani wants to merge 2 commits into
github:mainfrom
Arham-Begani:fix/merge-author-email-3814
Open

Arham-Begani wants to merge 2 commits into
github:mainfrom
Arham-Begani:fix/merge-author-email-3814

Conversation

@Arham-Begani

Copy link
Copy Markdown

Summary

Allow merge_pull_request callers to choose the merge commit's author email with an optional author_email argument. 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

  • Add the optional argument to the tool schema and typed input normalization.
  • Use GraphQL mergePullRequest when 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.
  • Preserve the existing text and structured success-response shape, and add regression coverage, the schema snapshot, generated documentation and bundled skill guidance.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed — one optional argument; existing calls retain their behavior.
  • New tool added

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

  • No security or limits impact
  • Auth / permissions considered — GitHub validates the requested email and merge permissions. Errors cannot trigger a merge that discards the requested email, and the existing expected-head protection is forwarded.
  • 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 — 0 issues.
  • Tested locally with script/test using scoped GOFLAGS='-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 audit reports four existing dependency advisories (two low, two high); package manifests and lockfiles are unchanged. Live authenticated E2E tests were not run.

Docs

  • Not needed
  • Updated — generated README argument documentation and the tool schema snapshot.

Skills

  • Updated the bundled pull-request-authoring skill to pass a requested email and report rejection instead of retrying without it. Catalog and skill-instruction validation pass.

AI assistance: Codex assisted with the implementation, tests and this description. The diff also received an independent read-only AI review.

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
@Arham-Begani
Arham-Begani requested a review from a team as a code owner November 14, 2026 19:55
Copilot AI adaptive review requested due to automatic review settings November 14, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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)

Comment thread pkg/github/pullrequests.go Outdated
Comment on lines +1817 to +1820
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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

merge_pull_request: support choosing the commit author email

2 participants