Add a list_todos MCP tool
What does this MR do and why?
The MCP server had no way to read the to-do items of the authenticated user, so an agent couldn't find the review requests, assignments, and mentions waiting on them.
This MR adds the first of the two tools planned in #598281 (closed), list_todos, following the plan in the issue. save_todo will follow in a separate MR, as agreed in this comment.
list_todos is a GraphqlTool on currentUser.todos, in the core toolset:
- It returns pending to-do items unless
stateis set, matching the To-Do List. Snoozed to-do items are left out of pending results, becauseTodosFinderalready does that when only pending items are requested. - Filters:
state,action,type,author_id,project_id, andgroup_id. Thestate,action, andtypevalues come fromTodoStateEnum,TodoActionEnum, andTodoTargetEnum, so they can't drift from GraphQL. project_idandgroup_idtake an ID or full path and resolve throughResourceFinder, because thetodosconnection only filters by numeric ID. An inaccessible project or group returns the same error as a missing one.first/afterpagination fromCursorPagination, returningpageInfo.- Each to-do item returns
id,action,state,body,createdAt,targetType,targetUrl, the target'snameandiid, the author, and the project or group. To-do, project, and group IDs are unwrapped to numbers, so they can be passed back into other tools.
The tool is registered in Mcp::Tools::Manager and added to both list_tools specs, the Duo Workflow read-only tool lists, and the governance argument list. It isn't added to the AI Catalog built-in tools.
References
- Part of #598281 (closed)
Screenshots or screen recordings
Not applicable, MCP tool.
How to set up and validate locally
- Create a few to-do items: request your review on a merge request, assign yourself to an issue, and mark one to-do item as done.
- Call the
list_todosMCP tool with no arguments. It returns your pending to-do items with numeric IDs andpageInfo. - Call it with
state: "done",type: "MERGEREQUEST",action: "review_requested", orproject_id: "<full path>"and check that only the matching to-do items are returned. - Call it with the full path of a private project you can't access. It returns
not found or inaccessible.
Specs:
bin/rspec spec/services/mcp/tools/todos/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.