Add save_work_item_saved_view MCP tool for creating saved views

What does this MR do and why?

Adds a new MCP tool, save_work_item_saved_view, that creates a work item saved view in a project or group.

A saved view is a named set of filters, sort, and display settings for the work items list, like "Open bugs for my team".

Today an agent can find saved views with list_work_item_saved_views, but it can't create one. So when a user asks Duo "make me a board view for this group", Duo has to send them to the UI. With this tool, Duo can create the view itself.

The tool takes:

  • Where: exactly one of url, group_id, or project_id.
  • What: name (required in the schema), description, display_settings (for example {"viewMode": "board"}), sort, and is_private.

It returns the saved view with its numeric id, which an agent can pass to get_saved_view_work_items, and a shareUrl. New views are private by default, so an agent can't share a view by mistake.

It also mentions the new tool in the list_work_item_saved_views description.

Not in this MR

Filters. For now the tool saves an empty filter set. The next MRs build on this branch:

  1. This MR: create a saved view.
  2. !265188: adds the filters argument.
  3. !265189: adds update support.
MCP tool review board conditions

The board approved the proposal on 636789 (notes 4110954702, 4125506423, 4127284178, 4124641273) with these conditions:

  • Name is save_work_item_saved_view, not save_saved_view, because MergeRequests::SavedView also exists and tool names can't change after release.
  • destructiveHint: true, the same as save_work_item in #633037 (closed).
  • Numeric id in the response. Saved views have no iid, so the global ID is unwrapped.
  • display_settings keys come from work_item_user_preference_display_settings.json. Unknown keys are rejected, and a spec keeps the keys in sync with the file.
  • No defaults stated in the input schema descriptions.
  • Filters are in !265188.
Notes for reviewers
  • Defaults on create: filters: {}, display_settings: {}, sort: CREATED_DESC, is_private: true. The tool sends all four itself, so it does not depend on the mutation defaults. They are in the docs, not in the schema.
  • name is required in the schema, so a call without it fails before any GraphQL runs. !265189 makes it optional again for update, which is not a breaking change.
  • SaveWorkItemSavedViewCommon has one user here. The update tool in !265189 uses it too.
  • Governance: the target namespace comes from url, project_id, or group_id. These match the default container arguments, so the service declares nothing extra.
  • Versioning: !265188 and !265189 only add optional parameters to the same version 0.1.0, so old calls keep working. save_work_item did the same.
  • Danger EE: true warning: the tool works in CE, so the changelog has no EE: true.

References

Screenshots or screen recordings

Duo Agentic Chat creates a board view with save_work_item_saved_view

The prompt is Create a saved view in group gitlab-org called "Team board" that shows work items on a board. Duo calls the tool, I approve it, and the new private Team board view opens on a board.

How to set up and validate locally

With Duo Agentic Chat

If you have Duo Agentic Chat working locally, you can test the tool from chat:

  1. Make sure the top-level group has Settings > GitLab Duo > External MCP tools turned on. Without it, chat doesn't get the GitLab MCP tools.

  2. Open the work items list of a project or group that has GitLab Duo turned on, for example gitlab-org.

  3. Open GitLab Duo Chat, pick the GitLab Duo agent, and send:

    Create a saved view in group gitlab-org called "Board view" that shows work items on a board
  4. Approve the save work item saved view tool call.

  5. Open the link in Duo's reply. You should see the new private Board view on a board, and the view in the saved views bar.

  6. Clean up: delete the Board view saved view.

With the Rails console

  1. Open a Rails console (gdk rails c):

    user = User.find_by_username('root')
    call = ->(arguments) do
      tool = Mcp::Tools::Manager.new.get_tool(name: 'save_work_item_saved_view')
      tool.set_cred(current_user: user)
      tool.execute(params: { arguments: arguments })
    end
    
    result = call.({ group_id: 'gitlab-org', name: 'Board view', display_settings: { viewMode: 'board' } })
    result[:structuredContent]
  2. Check that:

    • id is a number.
    • displaySettings is {"viewMode" => "board"}.
    • isPrivate is true and sort is CREATED_DESC.
  3. Open the shareUrl in the browser. You should see the group's work items on a board, and the view in the saved views bar.

  4. Check the error cases:

    call.({ group_id: 'gitlab-org' }).dig(:content, 0, :text)
    # => "Validation error: name is missing"
    
    call.({ group_id: 'gitlab-org', name: 'x', display_settings: { layout: 'board' } }).dig(:content, 0, :text)
    # => "Validation error: display_settings/layout is invalid"
    
    call.({ group_id: 'gitlab-org', project_id: 'gitlab-org/gitlab-test', name: 'x' }).dig(:content, 0, :text)
    # => "Validation error: Provide exactly one of url, project_id, or group_id (got project_id, group_id)"
  5. Clean up: delete the Board view saved view from the work items list.

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.

🤖 Generated with Claude Code

Edited by Rajan Mistry

Merge request reports

Loading
Loading