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 state is set, matching the To-Do List. Snoozed to-do items are left out of pending results, because TodosFinder already does that when only pending items are requested.
  • Filters: state, action, type, author_id, project_id, and group_id. The state, action, and type values come from TodoStateEnum, TodoActionEnum, and TodoTargetEnum, so they can't drift from GraphQL.
  • project_id and group_id take an ID or full path and resolve through ResourceFinder, because the todos connection only filters by numeric ID. An inaccessible project or group returns the same error as a missing one.
  • first/after pagination from CursorPagination, returning pageInfo.
  • Each to-do item returns id, action, state, body, createdAt, targetType, targetUrl, the target's name and iid, 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

Screenshots or screen recordings

Not applicable, MCP tool.

How to set up and validate locally

  1. 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.
  2. Call the list_todos MCP tool with no arguments. It returns your pending to-do items with numeric IDs and pageInfo.
  3. Call it with state: "done", type: "MERGEREQUEST", action: "review_requested", or project_id: "<full path>" and check that only the matching to-do items are returned.
  4. 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.

Edited by Arjun Singh

Merge request reports

Loading
Loading