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, orproject_id. - What:
name(required in the schema),description,display_settings(for example{"viewMode": "board"}),sort, andis_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:
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, notsave_saved_view, becauseMergeRequests::SavedViewalso exists and tool names can't change after release. destructiveHint: true, the same assave_work_itemin #633037 (closed).- Numeric
idin the response. Saved views have no iid, so the global ID is unwrapped. display_settingskeys come fromwork_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. nameis 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.SaveWorkItemSavedViewCommonhas one user here. The update tool in !265189 uses it too.- Governance: the target namespace comes from
url,project_id, orgroup_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_itemdid the same. - Danger
EE: truewarning: the tool works in CE, so the changelog has noEE: true.
References
- Issue: #631461
- Proposal and board approval: #636789
- POC with all three tools: !261265 (closed)
- Follows !265187 (merged) (merged)
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:
-
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.
-
Open the work items list of a project or group that has GitLab Duo turned on, for example
gitlab-org. -
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 -
Approve the save work item saved view tool call.
-
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.
-
Clean up: delete the Board view saved view.
With the Rails console
-
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] -
Check that:
idis a number.displaySettingsis{"viewMode" => "board"}.isPrivateistrueandsortisCREATED_DESC.
-
Open the
shareUrlin the browser. You should see the group's work items on a board, and the view in the saved views bar. -
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)" -
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.