Add resolve_discussion method to save_note MCP tool

What does this MR do and why?

Adds a resolve_discussion method to the save_note MCP tool so agents can resolve or unresolve discussion threads on work items (issues, tasks, epics). Until now, an agent could read and reply to a work item discussion through MCP but had no way to close the loop once it had handled the thread.

The change mirrors the resolve_discussion method of save_merge_request_review:

  • New optional method parameter (create_note, reply_discussion, resolve_discussion). When omitted, the tool behaves as before, so the create_merge_request_note / create_workitem_note aliases keep working.
  • New resolved boolean parameter.
  • discussion_id now accepts a bare discussion ID as well as a global ID.
  • body is no longer required at the schema level; the tool rejects note methods without a body.
  • Reuses the existing discussionToggleResolve operation from app/graphql/queries/mcp/merge_requests/discussion_toggle_resolve.mutation.graphql, which is noteable-agnostic. Authorization stays in the mutation (Discussion#can_resolve?).

Output for resolve_discussion:

{ "method": "resolve_discussion", "discussion_id": "gid://gitlab/Discussion/<id>", "resolved": true, "web_url": "..." }

References

Screenshots or screen recordings

Not applicable, no UI changes.

How to set up and validate locally

  1. Create an issue in a project where you are a Developer and start a discussion thread on it.

  2. In a Rails console, grab the discussion ID:

    issue = Project.find_by_full_path('<group>/<project>').issues.last
    discussion_id = issue.notes.last.discussion_id
  3. Call the tool as that user:

    service = Mcp::Tools::Notes::SaveNoteService.new(name: 'save_note')
    service.set_cred(current_user: User.find_by_username('<you>'))
    service.execute(params: { arguments: { project_id: '<group>/<project>', work_item_iid: issue.iid,
      method: 'resolve_discussion', discussion_id: discussion_id, resolved: true } })
  4. Reload the issue page: the thread shows as resolved. Call again with resolved: false to unresolve it.

  5. Confirm the previous behavior still works by calling without method and with a body.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading