Skip to content

Add hide_comment and unhide_comment granular tools to issues_granular toolset - #3350

Open
timrogers wants to merge 3 commits into
mainfrom
add-hide-unhide-comment-tools
Open

timrogers wants to merge 3 commits into
mainfrom
add-hide-unhide-comment-tools

Conversation

@timrogers

@timrogers timrogers commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds hide_comment and unhide_comment tools, behind the issues_granular feature flag. They hide (minimize) and unhide comments on issues and pull requests using the GraphQL minimizeComment / unminimizeComment mutations.

Why

The server has no way to hide spam, off-topic, outdated or resolved comments. Hiding is only available through GraphQL; REST has no equivalent. Related: #3321 / #3329, which surface minimized_reason when reading comments.

What changed

  • New hide_comment tool: takes owner, repo, comment_type, comment_id, classifier (all required) and an optional pull_number.
  • New unhide_comment tool: same inputs, without classifier.
  • comment_type is one of issue_comment (issue or PR conversation comment), pull_request_review_comment (inline PR diff comment) or pull_request_review (PR review body, needs pull_number).
  • Callers pass the numeric REST ID returned by the existing read tools. resolveCommentNodeID fetches the matching REST resource to get its GraphQL node_id, then runs the mutation. Each numeric ID type has its own ID space, so comment_type is required rather than guessed.
  • Shared schema properties and handler logic live in pkg/github/comment_minimize.go. The tool constructors live in issues_granular.go alongside the other granular issue tools.
  • Toolsnaps, granular toolset tests and docs/feature-flags.md updated.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Two new write tools, visible only when issues_granular is enabled.

Prompts tested (tool changes only)

End-to-end test against the live API: I built the server, ran it over stdio with --toolsets issues --features issues_granular, and drove it with a small MCP client. It created real content on #3351 (a temporary test issue) and on this PR. For each object, it called hide_comment and then unhide_comment, and checked isMinimized / minimizedReason with an independent GraphQL query after each call:

Object comment_type Classifier Hide Unhide
Issue comment issue_comment SPAM ✅ ✅
PR conversation comment issue_comment OFF_TOPIC ✅ ✅
PR review (inline) comment pull_request_review_comment OUTDATED ✅ ✅
PR review body pull_request_review RESOLVED ✅ ✅

Error cases also behaved correctly against the live API:

  • An issue comment ID sent as pull_request_review_comment returns failed to get comment … 404.
  • pull_request_review without pull_number is rejected before any API call.
  • An invalid classifier is rejected by GraphQL, and the comment is left unchanged.

The test comments have been deleted and #3351 is closed. The test review stays on this PR with its body edited, because GitHub doesn't allow deleting submitted reviews.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Requires the repo scope, like the other granular issue write tools. GitHub itself enforces that the caller has triage/write access or authored the comment; permission errors from the mutation are returned as tool errors.

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Lint was run with Go 1.25 and golangci-lint v2.9.0 to match CI. The new tests cover all three comment types for hide and unhide, GraphQL mutation failures, comment-not-found, missing node ID, and missing or invalid arguments.

Docs

  • Not needed
  • Updated (README / docs / examples)

docs/feature-flags.md regenerated with script/generate-docs. README is unchanged because flag-gated tools aren't listed there.

Add two tools behind the issues_granular feature flag that hide
(minimize) and unhide (unminimize) comments via the GraphQL
minimizeComment/unminimizeComment mutations.

They support issue and pull request conversation comments, pull
request review comments, and pull request review bodies. Callers
pass the numeric REST ID plus a comment_type; the tool resolves the
GraphQL node ID via the matching REST endpoint before mutating.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@timrogers timrogers changed the title Add hide_comment and unhide_comment granular issue tools Add hide_comment and unhide_comment granular tools to issues_granular toolset Sep 30, 2026
Use `pull_request_review` and `pull_request_review_comment` instead of
`review` and `review_comment` so the comment_type values are explicit
about which object they refer to.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@timrogers
timrogers marked this pull request as ready for review September 30, 2026 01:08
@timrogers
timrogers requested a review from a team as a code owner September 30, 2026 01:08
Copilot AI balanced review requested due to automatic review settings September 30, 2026 01:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Runtime validation is missing for classifier values and positive comment IDs.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds feature-flagged tools for minimizing and restoring issue and pull-request comments through GitHub’s GraphQL API.

Changes:

  • Adds hide_comment and unhide_comment.
  • Resolves REST IDs to GraphQL node IDs.
  • Adds schemas, tests, snapshots, and generated documentation.
File Description
pkg/​github/​tools.go Registers both tools.
pkg/​github/​issues_granular.go Defines tool schemas and handlers.
pkg/​github/​comment_minimize.go Implements ID resolution and mutations.
pkg/​github/​comment_minimize_test.go Tests supported targets and failures.
pkg/​github/​granular_tools_test.go Verifies registration and snapshots.
pkg/​github/​__toolsnaps__/​hide_comment.snap Captures the hide tool schema.
pkg/​github/​__toolsnaps__/​unhide_comment.snap Captures the unhide tool schema.
docs/​feature-flags.md Documents both tools.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +80 to +83
commentID, err := RequiredBigInt(args, "comment_id")
if err != nil {
return utils.NewToolResultError(err.Error())
}
Comment on lines +1933 to +1937
classifier, err := RequiredParam[string](args, "classifier")
if err != nil {
return utils.NewToolResultError(err.Error()), nil, nil
}
return setCommentVisibility(ctx, deps, args, true, classifier), nil, nil

@timrogers timrogers left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Left over from the end-to-end test of hide_comment / unhide_comment; submitted reviews can't be deleted.)

GitHub returns minimizedReason in lowercase, hyphenated form (e.g.
"off-topic") rather than echoing the classifier enum, as confirmed by
an end-to-end run against the live API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants