Add list_work_item_saved_views MCP tool
What does this MR do and why?
Agents can already open one saved view with get_saved_view_work_items, but they need its ID first. There is no tool to find out which saved views exist in a project or group, so the agent has to ask the user for the ID.
This MR adds a read-only list_work_item_saved_views MCP tool to the work_items toolset. It returns the saved views in a project or group and supports search, subscribed_only, sort, and cursor pagination.
All of this comes from the existing namespace.savedViews GraphQL field, so the tool is a thin wrapper around that field and adds no new finder or query logic.
This is MR 1 of 3:
- This MR:
list_work_item_saved_views - !265188:
save_work_item_saved_viewfor creating a saved view - !265189:
save_work_item_saved_viewfor updating a saved view
Merge request saved views exist too (MergeRequests::SavedView), so the name says which saved views it lists. The MCP tool review board approved the tool name and the integer ID output:
Blocked by !267626 (merged)
This tool returns numeric saved view IDs, for example 42. get_saved_view_work_items accepts numeric IDs only after !267626 (merged) merges. If this MR merges first, list → get fails in between, so please merge !267626 (merged) first.
A quick intro to saved views
If you haven't worked with saved views before, here is the short version.A saved view is a named set of filters, sort, and display settings for the work items list. For example, "Open bugs for my team". It belongs to a group or a project.
- Private or shared: a private view is visible only to its author. A shared view is visible to everyone who can see the namespace (
SavedView.visible_to). - Subscribed: when a user subscribes to a view, it shows up as a tab on their work items list. Subscriptions live in
user_saved_views, which also stores the user's own tab order inrelative_position. - Name and description: both are 140 characters max.
searchmatches either of them.
What the tool returns
Each row has id, name, description, sort, isPrivate, subscribed, shareUrl, and updatedAt, plus pageInfo for the next page.
id is a plain integer, not a global ID. Saved views have no iid, so the MCP ID rules say to unwrap the global ID, the same way list_projects and list_groups do. The agent can pass id straight to get_saved_view_work_items and save_work_item_saved_view.
Notes for reviewers
- No
filtersin the list. ThefiltersandfilterWarningsfields can resolve for only one saved view per request, so the list leaves them out. Agents useget_saved_view_work_itemsfor those. - Only three sort values.
WorkItemsSavedViewsSortalso inherits the generic created and updated values fromTypes::SortEnum, but the finder ignores them and falls back to ID. So the tool offers onlyID,NAME_ASC, andRELATIVE_POSITION. RELATIVE_POSITIONneedssubscribed_only: true. The position is per user and stored on the subscription, so withoutsubscribed_onlythe finder would quietly sort by ID (SavedView.sort_by_attributes). The tool returns a validation error instead, the same way it handles more than one parent identifier.IDsort is newest first (id DESC).- Exactly one of
url,project_id, orgroup_id. If you pass more than one, the tool returns an error instead of quietly picking one.
References
- Issue: #631461
- MCP Tool Proposal answers: #633661 (closed)
- POC with all three tools: !261265 (closed)
Screenshots or screen recordings
Not a UI change, but here is the tool working end to end in GDK with Duo Agentic Chat. I created three saved views in gitlab-org (two shared, one private) and subscribed to one of them. Then I asked "List the saved views in group gitlab-org, and tell me which ones I'm subscribed to". Chat calls the tool once (it was still named list_saved_views when this was recorded), lists all three views, and picks out the one I'm subscribed to.
How to set up and validate locally
-
Make sure
gitlab-orghas a few saved views. If it has none, open its work items list, change some filters, and click Save view. Save at least one as private and subscribe to one. -
Open a Rails console (
gdk rails c):user = User.find_by_username('root') call = ->(arguments) do tool = Mcp::Tools::Manager.new.get_tool(name: 'list_work_item_saved_views') tool.set_cred(current_user: user) tool.execute(params: { arguments: arguments })[:structuredContent] end call.({ group_id: 'gitlab-org', first: 3 })You should get up to 3
saved_viewsand apageInfo. If there are more views,hasNextPageistrue. -
Get the next page by passing the cursor back:
cursor = call.({ group_id: 'gitlab-org', first: 3 })['pageInfo']['endCursor'] call.({ group_id: 'gitlab-org', first: 3, after: cursor }) -
Try the other options:
call.({ group_id: 'gitlab-org', search: 'bug' }) call.({ group_id: 'gitlab-org', subscribed_only: true, sort: 'RELATIVE_POSITION' }) -
Check that a sort outside the three values, and
RELATIVE_POSITIONwithoutsubscribed_only, are rejected:tool = Mcp::Tools::Manager.new.get_tool(name: 'list_work_item_saved_views') tool.set_cred(current_user: user) tool.execute(params: { arguments: { group_id: 'gitlab-org', sort: 'CREATED_DESC' } }).dig(:content, 0, :text) # => "Validation error: Invalid sort: 'CREATED_DESC'. Must be one of: ID, NAME_ASC, RELATIVE_POSITION" tool.execute(params: { arguments: { group_id: 'gitlab-org', sort: 'RELATIVE_POSITION' } }).dig(:content, 0, :text) # => "Validation error: sort RELATIVE_POSITION requires subscribed_only: true" -
Optional: connect a real MCP client to GDK as described in MCP server development, then ask "List the saved views in group gitlab-org".
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.