Skip to content

Commit 70d47de

Browse files
aryasoni98williammartin
authored andcommitted
Add request_copilot_review tool with placeholder implementation
1 parent f345fcb commit 70d47de

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,13 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
437437
- `base`: New base branch name (string, optional)
438438
- `maintainer_can_modify`: Allow maintainer edits (boolean, optional)
439439

440+
- **request_copilot_review** - Request a GitHub Copilot review for a pull request (experimental; subject to GitHub API support)
441+
442+
- `owner`: Repository owner (string, required)
443+
- `repo`: Repository name (string, required)
444+
- `pull_number`: Pull request number (number, required)
445+
- _Note: As of now, requesting a Copilot review programmatically is not supported by the GitHub API. This tool will return an error until GitHub exposes this functionality._
446+
440447
### Repositories
441448

442449
- **create_or_update_file** - Create or update a single file in a repository

pkg/github/pullrequests.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,3 +1729,40 @@ func newGQLStringlike[T ~string](s string) *T {
17291729
stringlike := T(s)
17301730
return &stringlike
17311731
}
1732+
1733+
// RequestCopilotReview creates a tool to request a Copilot review for a pull request.
1734+
func RequestCopilotReview(getClient GetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1735+
return mcp.NewTool("request_copilot_review",
1736+
mcp.WithDescription(t("TOOL_REQUEST_COPILOT_REVIEW_DESCRIPTION", "Request a GitHub Copilot review for a pull request. Note: This feature depends on GitHub API support and may not be available for all users.")),
1737+
mcp.WithString("owner",
1738+
mcp.Required(),
1739+
mcp.Description("Repository owner"),
1740+
),
1741+
mcp.WithString("repo",
1742+
mcp.Required(),
1743+
mcp.Description("Repository name"),
1744+
),
1745+
mcp.WithNumber("pull_number",
1746+
mcp.Required(),
1747+
mcp.Description("Pull request number"),
1748+
),
1749+
),
1750+
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1751+
owner, err := requiredParam[string](request, "owner")
1752+
if err != nil {
1753+
return mcp.NewToolResultError(err.Error()), nil
1754+
}
1755+
repo, err := requiredParam[string](request, "repo")
1756+
if err != nil {
1757+
return mcp.NewToolResultError(err.Error()), nil
1758+
}
1759+
pullNumber, err := RequiredInt(request, "pull_number")
1760+
if err != nil {
1761+
return mcp.NewToolResultError(err.Error()), nil
1762+
}
1763+
1764+
// As of now, GitHub API does not support Copilot as a reviewer programmatically.
1765+
// This is a placeholder for future support.
1766+
return mcp.NewToolResultError(fmt.Sprintf("Requesting a Copilot review for PR #%d in %s/%s is not currently supported by the GitHub API. Please request a Copilot review via the GitHub UI.", pullNumber, owner, repo)), nil
1767+
}
1768+
}

pkg/github/pullrequests_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,3 +1545,27 @@ func Test_AddPullRequestReviewComment(t *testing.T) {
15451545
})
15461546
}
15471547
}
1548+
1549+
func Test_RequestCopilotReview(t *testing.T) {
1550+
mockClient := github.NewClient(nil)
1551+
tool, handler := RequestCopilotReview(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1552+
1553+
assert.Equal(t, "request_copilot_review", tool.Name)
1554+
assert.NotEmpty(t, tool.Description)
1555+
assert.Contains(t, tool.InputSchema.Properties, "owner")
1556+
assert.Contains(t, tool.InputSchema.Properties, "repo")
1557+
assert.Contains(t, tool.InputSchema.Properties, "pull_number")
1558+
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"})
1559+
1560+
request := createMCPRequest(map[string]interface{}{
1561+
"owner": "owner",
1562+
"repo": "repo",
1563+
"pull_number": float64(42),
1564+
})
1565+
1566+
result, err := handler(context.Background(), request)
1567+
assert.NoError(t, err)
1568+
assert.NotNil(t, result)
1569+
textContent := getTextResult(t, result)
1570+
assert.Contains(t, textContent.Text, "not currently supported by the GitHub API")
1571+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy