Skip to content

Add ability to request Copilot reviews via MCP #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 14, 2025

Conversation

aryasoni98
Copy link
Contributor

@aryasoni98 aryasoni98 commented May 9, 2025

Description

Closes: #374

This PR adds the request_copilot_review tool, which...requests reviews from copilot on PRs where possible. It is an MVP implementation that doesn't try to do anything particularly clever around only exposing the tool for hosts that support it, or playing nice with various error messages that might come back.

@aryasoni98 aryasoni98 requested a review from a team as a code owner May 9, 2025 09:45
@aryasoni98 aryasoni98 requested a review from williammartin May 12, 2025 09:48
@williammartin williammartin force-pushed the issues-374 branch 3 times, most recently from 762e9e1 to 8098b49 Compare May 12, 2025 15:24
@williammartin williammartin changed the base branch from main to 343-remove-comments-from-create_pull_request_review May 12, 2025 15:24
@williammartin williammartin changed the base branch from 343-remove-comments-from-create_pull_request_review to main May 12, 2025 15:25
@williammartin williammartin requested a review from Copilot May 12, 2025 15:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds an experimental tool to request GitHub Copilot reviews on pull requests, registers it in the server toolset, and provides both unit and end-to-end tests along with documentation.

  • Introduces RequestCopilotReview handler and argument parsing
  • Registers the new tool in pkg/github/tools.go
  • Adds unit test (pullrequests_test.go), e2e test (e2e_test.go), and README entry

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/github/tools.go Register RequestCopilotReview in the server toolsets
pkg/github/pullrequests.go Implement tool schema, parsing, and GitHub API call
pkg/github/pullrequests_test.go Add unit test for RequestCopilotReview
e2e/e2e_test.go Add end-to-end test for Copilot review workflow
README.md Document the new request_copilot_review tool
Comments suppressed due to low confidence (2)

pkg/github/pullrequests.go:1294

  • Parameter name 'pullNumber' is camelCase but other tools use snake_case (e.g. 'pull_number'). Rename to 'pull_number' in both the schema and parsing logic.
mcp.WithNumber("pullNumber",

e2e/e2e_test.go:493

  • Test uses camelCase 'pullNumber' but the tool schema and other tests expect 'pull_number'. Update this to 'pull_number' for consistency.
"pullNumber": 1,

return mcp.NewToolResultError(err.Error()), nil
}

if _, _, err := client.PullRequests.RequestReviewers(
Copy link
Preview

Copilot AI May 12, 2025

Choose a reason for hiding this comment

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

When the GitHub API does not support requesting Copilot reviews (e.g. returns 404), you should catch that specific status and return a text result with an explanatory message ("requesting a Copilot review is not currently supported by the GitHub API") instead of propagating the raw error.

Copilot uses AI. Check for mistakes.

@williammartin
Copy link
Collaborator

I just cleaned up the commits and force pushed a WIP commit (needs unit testing and probably also GHES considerations) that demonstrates this working. You can see that I requested a review on this PR via the MCP server.

image

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for requesting a GitHub Copilot review on pull requests via the MCP server, including registering the tool, implementing its handler, and covering it in unit and end-to-end tests.

  • Registers a new request_copilot_review tool in the main toolset
  • Implements the tool handler in pullrequests.go and adds unit tests
  • Adds an E2E test for the Copilot review flow and updates the README

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/github/tools.go Register new RequestCopilotReview tool
pkg/github/pullrequests.go Implement tool handler and GitHub API call
pkg/github/pullrequests_test.go Add unit tests for success and failure paths
pkg/github/helper_test.go Introduce expect helper and expectations struct
e2e/e2e_test.go Add full end-to-end test for Copilot review
README.md Document the new request_copilot_review tool
Comments suppressed due to low confidence (2)

pkg/github/pullrequests.go:1268

  • Parameter names in other tools use snake_case (e.g. pull_number). To maintain consistency across the API, this should be renamed to pull_number.
mcp.WithNumber("pullNumber",

README.md:461

  • The README uses pull_number but the tool’s schema and tests expect pullNumber. Update the docs to match the actual input name or align the code/schema to the documented name.
-  - `pull_number`: Pull request number (number, required)

@williammartin williammartin force-pushed the issues-374 branch 3 times, most recently from c193d38 to 688f808 Compare May 13, 2025 12:19
Co-authored-by: Sam Morrow <sammorrowdrums@github.com>
SamMorrowDrums
SamMorrowDrums previously approved these changes May 13, 2025
Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

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

A few minor comments, and a description I haven't tested manually yet.

Co-authored-by: Sam Morrow <sammorrowdrums@github.com>
Co-authored-by: Sam Morrow <sammorrowdrums@github.com>
@SamMorrowDrums SamMorrowDrums merged commit 7aced2b into github:main May 14, 2025
9 checks passed
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.

Add ability to request Copilot reviews via MCP
3 participants