Skip to content

Commit a563bd6

Browse files
aryasoni98SamMorrowDrums
authored andcommitted
Add request_copilot_review tool with placeholder implementation
1 parent da2df71 commit a563bd6

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
@@ -458,6 +458,13 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
458458
- `base`: New base branch name (string, optional)
459459
- `maintainer_can_modify`: Allow maintainer edits (boolean, optional)
460460

461+
- **request_copilot_review** - Request a GitHub Copilot review for a pull request (experimental; subject to GitHub API support)
462+
463+
- `owner`: Repository owner (string, required)
464+
- `repo`: Repository name (string, required)
465+
- `pull_number`: Pull request number (number, required)
466+
- _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._
467+
461468
### Repositories
462469

463470
- **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
@@ -1246,3 +1246,40 @@ func CreatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
12461246
return mcp.NewToolResultText(string(r)), nil
12471247
}
12481248
}
1249+
1250+
// RequestCopilotReview creates a tool to request a Copilot review for a pull request.
1251+
func RequestCopilotReview(getClient GetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1252+
return mcp.NewTool("request_copilot_review",
1253+
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.")),
1254+
mcp.WithString("owner",
1255+
mcp.Required(),
1256+
mcp.Description("Repository owner"),
1257+
),
1258+
mcp.WithString("repo",
1259+
mcp.Required(),
1260+
mcp.Description("Repository name"),
1261+
),
1262+
mcp.WithNumber("pull_number",
1263+
mcp.Required(),
1264+
mcp.Description("Pull request number"),
1265+
),
1266+
),
1267+
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1268+
owner, err := requiredParam[string](request, "owner")
1269+
if err != nil {
1270+
return mcp.NewToolResultError(err.Error()), nil
1271+
}
1272+
repo, err := requiredParam[string](request, "repo")
1273+
if err != nil {
1274+
return mcp.NewToolResultError(err.Error()), nil
1275+
}
1276+
pullNumber, err := RequiredInt(request, "pull_number")
1277+
if err != nil {
1278+
return mcp.NewToolResultError(err.Error()), nil
1279+
}
1280+
1281+
// As of now, GitHub API does not support Copilot as a reviewer programmatically.
1282+
// This is a placeholder for future support.
1283+
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
1284+
}
1285+
}

pkg/github/pullrequests_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,3 +1916,27 @@ func Test_AddPullRequestReviewComment(t *testing.T) {
19161916
})
19171917
}
19181918
}
1919+
1920+
func Test_RequestCopilotReview(t *testing.T) {
1921+
mockClient := github.NewClient(nil)
1922+
tool, handler := RequestCopilotReview(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1923+
1924+
assert.Equal(t, "request_copilot_review", tool.Name)
1925+
assert.NotEmpty(t, tool.Description)
1926+
assert.Contains(t, tool.InputSchema.Properties, "owner")
1927+
assert.Contains(t, tool.InputSchema.Properties, "repo")
1928+
assert.Contains(t, tool.InputSchema.Properties, "pull_number")
1929+
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"})
1930+
1931+
request := createMCPRequest(map[string]interface{}{
1932+
"owner": "owner",
1933+
"repo": "repo",
1934+
"pull_number": float64(42),
1935+
})
1936+
1937+
result, err := handler(context.Background(), request)
1938+
assert.NoError(t, err)
1939+
assert.NotNil(t, result)
1940+
textContent := getTextResult(t, result)
1941+
assert.Contains(t, textContent.Text, "not currently supported by the GitHub API")
1942+
}

0 commit comments

Comments
 (0)