Add a discussions facet to the get_work_item MCP tool

What does this MR do and why?

get_work_item can return the notes on a work item as a flat list, but not the threads they belong to. An agent can't tell which threads exist or which of them are still unresolved, which it needs to work through review feedback on an issue or epic.

This adds a discussions facet to include, following the direction in #597686 (comment 3938778103):

  • The facet reads the discussions field of the notes widget, the same field the work item page uses. It works for group-level work items such as epics.
  • Each discussion returns id, resolvable, resolved and its notes nested inside, the same shape as the discussions facet of get_merge_request.
  • discussions_first and discussions_after come from CursorPagination.input_schema_params. The field only pages forward, so there is no last or before, and a thread is never split across pages. Unlike get_merge_request, which always fetches the first 50 discussions, callers can page through all of them.
  • discussions_filter takes all_notes, only_comments or only_activity, derived from UserPreference::NOTES_FILTERS and upcased for GraphQL, so it can't drift from NotesFilterType.
  • The discussions variables are only sent when discussions is in include, like the notes variables, so stray parameters from an earlier call are ignored.
  • The complexity analyzer scores every facet at once, although a call enables only one, so both get_work_item queries scored 260 against the default limit of 250. Their limits in ee/spec/graphql/all_queries_spec.rb move to 261, the same false positive already recorded for get_merge_request.
  • There is no sort parameter for now, and the include description keeps pointing callers at notes_last for the newest notes.

The docs list the new parameters and document discussion.id on the notes facet.

References

Screenshots or screen recordings

Not applicable, MCP tool change.

How to set up and validate locally

  1. Add a few threads to an issue, resolve one of them, and add a reply to another.
  2. Call the get_work_item MCP tool with include: ["discussions"] and discussions_first: 1. The NOTES widget returns one discussion with all its notes, and pageInfo.hasNextPage is true.
  3. Call it again with discussions_after set to pageInfo.endCursor to get the next thread. The resolved thread has resolved: true.
  4. Call it with discussions_filter: "only_comments" and check that system notes are left out.
  5. Call it with include: ["notes"] and check that each note has discussion.id.

Specs:

bin/rspec spec/services/mcp/tools/work_items/get_work_item_tool_spec.rb spec/services/mcp/tools/work_items/get_work_item_service_spec.rb ee/spec/services/mcp/tools/work_items/get_work_item_tool_spec.rb

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.

Edited by Arjun Singh

Merge request reports

Loading
Loading