Paginate the get_work_item notes facet in both directions
What does this MR do and why?
Adds cursor pagination in both directions to the notes facet of the get_work_item MCP tool. Callers can now page forward with notes_first / notes_after, or backward with notes_last / notes_before (for reading the newest notes first), each capped at 100 items per page. The facet response now returns a full pageInfo object (hasNextPage, hasPreviousPage, startCursor, endCursor).
This also rewrites the facet description, which previously told agents to "use get_workitem_notes for full note pagination." That self-referral kept agents on the standalone tool and blocked its retirement.
Closes #622710 (closed) (GA must-have). This removes the capability gap blocking deprecation of the standalone get_workitem_notes tool; the deprecation itself is a separate follow-up.
Documentation updates:
doc/user/model_context_protocol/mcp_server_tools.mdgains the four new parameter rows and a history entry.doc/development/duo_agent_platform/mcp/_index.md's facet-pagination guideline now names the<facet>_first/<facet>_after(plus<facet>_last/<facet>_beforewhere reading from the end matters) pattern, citingget_merge_request(forward-only) andget_work_item(bidirectional) as worked examples.
Design notes
- Backward pagination is included because the standalone tool paginates both directions and "newest notes first" is a common agent read; forward-only parity would not have been enough to retire it.
- When no pagination parameter is given, the facet keeps its previous behavior (first 100 notes), so existing callers see no change.
- Mixing directions (
notes_first/notes_afterwithnotes_last/notes_before) fails fast with a self-correcting validation error instead of surfacing the raw GraphQL connection error. - The EE query override (
ee/app/graphql/queries/mcp/work_items/get_work_item.query.graphql) mirrors the CE file becauseload_graphqlresolves the EE file on EE instances — editing only the CE query silently changes nothing on EE.
How to validate locally
- Check out this branch and restart GDK's rails processes.
- Create a personal access token with
apiandmcpscopes. - Call
tools/callonget_work_itemfor a work item with 3 notes:- Default (no pagination params): returns all three notes.
notes_first: 1: returns the first note withhasNextPage: true.- Add
notes_afterset to the returnedendCursor: returns the second note. notes_last: 1: returns the newest note.- Combine both directions (
notes_first/notes_afterandnotes_last/notes_before): returns the validation error.
The following is the transcript of an end-to-end run against GDK exercising the sequence above:
1. schema has notes params: true
2. default (all 3): isError=false bodies=["n1", "n2", "n3"] pageInfo={"hasNextPage"=>false, "hasPreviousPage"=>false}
3. notes_first 1: bodies=["n1"] hasNext=true
4. after cursor: isError=false bodies=["n2"] pageInfo={"hasNextPage"=>true, "hasPreviousPage"=>true}
5. notes_last 1: isError=false bodies=["n3"] pageInfo={"hasNextPage"=>false, "hasPreviousPage"=>true}
6. both directions: isError=true "Validation error: Provide notes_first/notes_after or notes_last/notes_before, not both directions"