Skip to content

feat: Add tools for discussion comment write operations#2427

Open
RossTarrant wants to merge 3 commits intomainfrom
rosstarrant/add-discussion-comment-write-ops
Open

feat: Add tools for discussion comment write operations#2427
RossTarrant wants to merge 3 commits intomainfrom
rosstarrant/add-discussion-comment-write-ops

Conversation

@RossTarrant
Copy link
Copy Markdown
Contributor

Summary

Adds four write operation tools to the discussions toolset:

  • add_discussion_comment
  • update_discussion_comment
  • delete_discussion_comment
  • set_discussion_comment_answer

enabling AI agents to participate in GitHub Discussions, not just read them. Also enhances get_discussion_comments to optionally include nested replies.

Why

The discussions toolset previously only supported read operations. AI agents could read discussion threads but had no way to post, edit, or delete comments, or mark an answer. The add_issue_comment tool returns 404 for Discussions because they use GraphQL, not the REST Issues API.

Fixes #1908

What changed

  • Added AddDiscussionComment tool in pkg/github/discussions.go
  • Added UpdateDiscussionComment tool in pkg/github/discussions.go
  • Added DeleteDiscussionComment tool in pkg/github/discussions.go
  • Added SetDiscussionCommentAnswer tool in pkg/github/discussions.go
  • Enhanced GetDiscussionComments with optional includeReplies parameter and richer response shape (ID, isAnswer, nested replies)
  • Added MinimalDiscussionComment type in pkg/github/minimal_types.go
  • Registered all four new tools in pkg/github/tools.go
  • Updated toolsnaps in pkg/github/__toolsnaps__/
  • Updated README.md via script/generate-docs

MCP impact

  • New tool added

    Four new write tools added: add_discussion_comment, update_discussion_comment, delete_discussion_comment,
    set_discussion_comment_answer. The existing get_discussion_comments tool schema was also extended with the includeReplies parameter and now returns richer comment objects (ID, isAnswer, optional replies). Toolsnaps updated with UPDATE_TOOLSNAPS=true go test ./....

Prompts tested (tool changes only)

  • "Add a comment to discussion #XXX in the github-mcp-server repo saying 'Thanks for the update!'"
  • "Update my comment on discussion #XXX to fix the typo"
  • "Delete my last comment on discussion #XXX"
  • "Mark the most helpful comment as the answer on discussion #XXX"
  • "List all comments on discussion #XXX, including their replies"

Security / limits

  • Auth / permissions considered

Write operations require a token with write:discussion scope. The tools use the existing githubv4 GraphQL client and follow the same auth patterns as other write tools in the codebase.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

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

Docs

  • Updated (README / docs / examples)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@RossTarrant RossTarrant marked this pull request as ready for review May 5, 2026 12:26
@RossTarrant RossTarrant requested a review from a team as a code owner May 5, 2026 12:26
Copilot AI review requested due to automatic review settings May 5, 2026 12:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the Discussions toolset so the MCP server can write discussion comments, edit/delete them, mark answers, and optionally return nested replies from get_discussion_comments.

Changes:

  • Added four new discussion comment write tools and registered them in the global tool inventory.
  • Extended discussion comment responses with IDs, answer state, and optional nested replies.
  • Updated tests, toolsnaps, and generated README documentation to reflect the new Discussions API surface.
Show a summary per file
File Description
README.md Documents the new discussion comment tools and includeReplies option.
pkg/github/tools.go Registers the new Discussions tools in AllTools.
pkg/github/minimal_types.go Adds the minimal response type for discussion comments.
pkg/github/discussions.go Implements new discussion comment mutations and reply-aware comment fetching.
pkg/github/discussions_test.go Adds/updates unit tests for the new discussion comment behavior.
pkg/github/__toolsnaps__/add_discussion_comment.snap Snapshot for the add-comment tool schema.
pkg/github/__toolsnaps__/delete_discussion_comment.snap Snapshot for the delete-comment tool schema.
pkg/github/__toolsnaps__/get_discussion_comments.snap Snapshot update for the new includeReplies input.
pkg/github/__toolsnaps__/set_discussion_comment_answer.snap Snapshot for the answer-toggle tool schema.
pkg/github/__toolsnaps__/update_discussion_comment.snap Snapshot for the update-comment tool schema.

Copilot's findings

Comments suppressed due to low confidence (2)

pkg/github/discussions.go:752

  • This handler never validates its required fields after weak-decoding, so an omitted or empty commentNodeID/body is passed straight through to the mutation. That produces confusing GraphQL failures instead of the normal local missing required parameter error path used by the repo's other write tools.
			var params struct {
				CommentNodeID string
				Body          string
			}
			if err := mapstructure.WeakDecode(args, &params); err != nil {

pkg/github/discussions.go:820

  • This has the same required-parameter hole as the other new discussion write tools: commentNodeID is only weak-decoded, so missing or blank values are sent to GitHub instead of being rejected up front with a missing required parameter tool error.
			var params struct {
				CommentNodeID string
			}
			if err := mapstructure.WeakDecode(args, &params); err != nil {
				return utils.NewToolResultError(err.Error()), nil, nil
  • Files reviewed: 10/10 changed files
  • Comments generated: 6

Comment thread pkg/github/minimal_types.go
Comment thread pkg/github/discussions.go
Comment thread pkg/github/discussions.go
Comment thread pkg/github/discussions.go
Comment thread pkg/github/discussions.go Outdated
Comment thread README.md Outdated
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.

Add discussion comment write operations to discussions toolset

2 participants