Loading
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
discussionsfield 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,resolvedand its notes nested inside, the same shape as thediscussionsfacet ofget_merge_request. discussions_firstanddiscussions_aftercome fromCursorPagination.input_schema_params. The field only pages forward, so there is nolastorbefore, and a thread is never split across pages. Unlikeget_merge_request, which always fetches the first 50 discussions, callers can page through all of them.discussions_filtertakesall_notes,only_commentsoronly_activity, derived fromUserPreference::NOTES_FILTERSand upcased for GraphQL, so it can't drift fromNotesFilterType.- The discussions variables are only sent when
discussionsis ininclude, 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_itemqueries scored 260 against the default limit of 250. Their limits inee/spec/graphql/all_queries_spec.rbmove to 261, the same false positive already recorded forget_merge_request. - There is no
sortparameter for now, and theincludedescription keeps pointing callers atnotes_lastfor the newest notes.
The docs list the new parameters and document discussion.id on the notes facet.
References
- Closes #597686 (closed)
Screenshots or screen recordings
Not applicable, MCP tool change.
How to set up and validate locally
- Add a few threads to an issue, resolve one of them, and add a reply to another.
- Call the
get_work_itemMCP tool withinclude: ["discussions"]anddiscussions_first: 1. TheNOTESwidget returns one discussion with all its notes, andpageInfo.hasNextPageistrue. - Call it again with
discussions_afterset topageInfo.endCursorto get the next thread. The resolved thread hasresolved: true. - Call it with
discussions_filter: "only_comments"and check that system notes are left out. - Call it with
include: ["notes"]and check that each note hasdiscussion.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.rbMR 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