Skip to content

Commit 91c8a1d

Browse files
committed
feat: implement ResolveReviewThread function
1 parent 25f86d8 commit 91c8a1d

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

pkg/github/pullrequests.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,60 @@ func DeletePendingPullRequestReview(ctx context.Context, client *githubv4.Client
16381638
return utils.NewToolResultText("pending pull request review successfully deleted"), nil
16391639
}
16401640

1641+
// ResolveReviewThread resolves or unresolves a PR review thread using GraphQL mutations.
1642+
func ResolveReviewThread(ctx context.Context, client *githubv4.Client, threadID string, resolve bool) (*mcp.CallToolResult, error) {
1643+
if threadID == "" {
1644+
return utils.NewToolResultError("threadId is required for resolve_thread and unresolve_thread methods"), nil
1645+
}
1646+
1647+
if resolve {
1648+
var mutation struct {
1649+
ResolveReviewThread struct {
1650+
Thread struct {
1651+
ID githubv4.ID
1652+
IsResolved githubv4.Boolean
1653+
}
1654+
} `graphql:"resolveReviewThread(input: $input)"`
1655+
}
1656+
1657+
input := githubv4.ResolveReviewThreadInput{
1658+
ThreadID: githubv4.ID(threadID),
1659+
}
1660+
1661+
if err := client.Mutate(ctx, &mutation, input, nil); err != nil {
1662+
return ghErrors.NewGitHubGraphQLErrorResponse(ctx,
1663+
"failed to resolve review thread",
1664+
err,
1665+
), nil
1666+
}
1667+
1668+
return utils.NewToolResultText("review thread resolved successfully"), nil
1669+
}
1670+
1671+
// Unresolve
1672+
var mutation struct {
1673+
UnresolveReviewThread struct {
1674+
Thread struct {
1675+
ID githubv4.ID
1676+
IsResolved githubv4.Boolean
1677+
}
1678+
} `graphql:"unresolveReviewThread(input: $input)"`
1679+
}
1680+
1681+
input := githubv4.UnresolveReviewThreadInput{
1682+
ThreadID: githubv4.ID(threadID),
1683+
}
1684+
1685+
if err := client.Mutate(ctx, &mutation, input, nil); err != nil {
1686+
return ghErrors.NewGitHubGraphQLErrorResponse(ctx,
1687+
"failed to unresolve review thread",
1688+
err,
1689+
), nil
1690+
}
1691+
1692+
return utils.NewToolResultText("review thread unresolved successfully"), nil
1693+
}
1694+
16411695
// AddCommentToPendingReview creates a tool to add a comment to a pull request review.
16421696
func AddCommentToPendingReview(t translations.TranslationHelperFunc) inventory.ServerTool {
16431697
schema := &jsonschema.Schema{

0 commit comments

Comments
 (0)