- Notifications
You must be signed in to change notification settings - Fork3.1k
feat: Add mark_pr_ready_for_review tool#423
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
0f56b45d25c98d6325c03eae41f8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1607,3 +1607,127 @@ func newGQLIntPtr(i *int32) *githubv4.Int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gi := githubv4.Int(*i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &gi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SetPRStatus creates a tool to set pull request status between draft and ready-for-review states. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This uses the GraphQL API because the REST API does not support changing PR draft status. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func SetPRStatus(getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return mcp.NewTool("set_pr_status", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.WithDescription(t("TOOL_SET_PR_STATUS_DESCRIPTION", "Set pull request status between draft and ready-for-review states. Use this to change a pull request from draft to ready-for-review or vice versa.")), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.WithToolAnnotation(mcp.ToolAnnotation{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Title: t("TOOL_SET_PR_STATUS_USER_TITLE", "Set pull request status"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReadOnlyHint: ToBoolPtr(false), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.WithString("owner", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Required(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Description("Repository owner"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.WithString("repo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Required(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Description("Repository name"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.WithNumber("pullNumber", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Required(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Description("Pull request number"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.WithString("status", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Required(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Description("Target status for the pull request"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp.Enum("draft", "ready_for_review"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var params struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Owner string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Repo string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PullNumber int32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Status string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err := mapstructure.Decode(request.Params.Arguments, ¶ms); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return mcp.NewToolResultError(err.Error()), nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate status parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if params.Status != "draft" && params.Status != "ready_for_review" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CopilotAI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return mcp.NewToolResultError("status must be either 'draft' or 'ready_for_review'"), nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines +1639 to +1653 CopilotAI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| varparamsstruct { | |
| Ownerstring | |
| Repostring | |
| PullNumberint32 | |
| Statusstring | |
| } | |
| iferr:=mapstructure.Decode(request.Params.Arguments,¶ms);err!=nil { | |
| returnmcp.NewToolResultError(err.Error()),nil | |
| } | |
| // Validate status parameter | |
| ifparams.Status!="draft"&¶ms.Status!="ready_for_review" { | |
| returnmcp.NewToolResultError("status must be either 'draft' or 'ready_for_review'"),nil | |
| } | |
| owner,err:=request.Params.GetString("owner") | |
| iferr!=nil { | |
| returnmcp.NewToolResultError(fmt.Sprintf("invalid owner parameter: %v",err)),nil | |
| } | |
| repo,err:=request.Params.GetString("repo") | |
| iferr!=nil { | |
| returnmcp.NewToolResultError(fmt.Sprintf("invalid repo parameter: %v",err)),nil | |
| } | |
| pullNumber,err:=request.Params.GetNumber("pullNumber") | |
| iferr!=nil { | |
| returnmcp.NewToolResultError(fmt.Sprintf("invalid pullNumber parameter: %v",err)),nil | |
| } | |
| status,err:=request.Params.GetString("status") | |
| iferr!=nil { | |
| returnmcp.NewToolResultError(fmt.Sprintf("invalid status parameter: %v",err)),nil | |
| } |
Uh oh!
There was an error while loading.Please reload this page.