RequestCopilotReview creates a tool to request a Copilot review for a pull request. Note that this tool will not work on GHES where this feature is unsupported. In future, we should not expose this tool if the configured host does not support it.
(t translations.TranslationHelperFunc)
| 459 | // Note that this tool will not work on GHES where this feature is unsupported. In future, we should not expose this |
| 460 | // tool if the configured host does not support it. |
| 461 | func RequestCopilotReview(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 462 | schema := &jsonschema.Schema{ |
| 463 | Type: "object", |
| 464 | Properties: map[string]*jsonschema.Schema{ |
| 465 | "owner": { |
| 466 | Type: "string", |
| 467 | Description: "Repository owner", |
| 468 | }, |
| 469 | "repo": { |
| 470 | Type: "string", |
| 471 | Description: "Repository name", |
| 472 | }, |
| 473 | "pullNumber": { |
| 474 | Type: "number", |
| 475 | Description: "Pull request number", |
| 476 | }, |
| 477 | }, |
| 478 | Required: []string{"owner", "repo", "pullNumber"}, |
| 479 | } |
| 480 | |
| 481 | return NewTool( |
| 482 | ToolsetMetadataCopilot, |
| 483 | mcp.Tool{ |
| 484 | Name: "request_copilot_review", |
| 485 | Description: t("TOOL_REQUEST_COPILOT_REVIEW_DESCRIPTION", "Request a GitHub Copilot code review for a pull request. Use this for automated feedback on pull requests, usually before requesting a human reviewer."), |
| 486 | Icons: octicons.Icons("copilot"), |
| 487 | Annotations: &mcp.ToolAnnotations{ |
| 488 | Title: t("TOOL_REQUEST_COPILOT_REVIEW_USER_TITLE", "Request Copilot review"), |
| 489 | ReadOnlyHint: false, |
| 490 | }, |
| 491 | InputSchema: schema, |
| 492 | }, |
| 493 | []scopes.Scope{scopes.Repo}, |
| 494 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 495 | owner, err := RequiredParam[string](args, "owner") |
| 496 | if err != nil { |
| 497 | return utils.NewToolResultError(err.Error()), nil, nil |
| 498 | } |
| 499 | |
| 500 | repo, err := RequiredParam[string](args, "repo") |
| 501 | if err != nil { |
| 502 | return utils.NewToolResultError(err.Error()), nil, nil |
| 503 | } |
| 504 | |
| 505 | pullNumber, err := RequiredInt(args, "pullNumber") |
| 506 | if err != nil { |
| 507 | return utils.NewToolResultError(err.Error()), nil, nil |
| 508 | } |
| 509 | |
| 510 | client, err := deps.GetClient(ctx) |
| 511 | if err != nil { |
| 512 | return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil |
| 513 | } |
| 514 | |
| 515 | _, resp, err := client.PullRequests.RequestReviewers( |
| 516 | ctx, |
| 517 | owner, |
| 518 | repo, |