Draft: Add MCP tool to fetch saved view work item list

What does this MR do and why?

Implements a new MCP tool get_saved_view_work_items that enables Duo to fetch and reason about saved views and their work items. The tool performs a two-step GraphQL query:

  1. Fetch the saved view using namespace.savedViews to retrieve the view's name, description, filters, and sort configuration
  2. Fetch work items using namespace.workItems with the filters extracted from the saved view

This gives Duo full context about what a saved view contains, including the applied filters and the resulting work items list.

Key changes:

  • New GraphQL tool class (GetSavedViewWorkItemsTool) that chains two GraphQL queries: first fetching the saved view metadata, then querying work items with the saved view's filters applied
  • Service layer (GraphqlGetSavedViewWorkItemsService) that wraps the tool and provides the MCP interface with input schema validation for namespace identification (URL, group_id, project_id), saved view ID, and pagination controls
  • Tool registration in the MCP tools manager, making get_saved_view_work_items available as a read-only tool
  • Comprehensive test coverage for both the tool and service classes

Technical details:

The tool extracts filters from the saved view (labels, assignees, milestones, state, types, etc.) and maps them to the workItems GraphQL query variables. The response combines the saved view metadata with the paginated work items list.

Supported filters in this MR

The following saved view filters are mapped and passed to the work items query in this iteration:

Filter GraphQL Variable
assigneeUsernames $assigneeUsernames
assigneeWildcardId $assigneeWildcardId
authorUsername $authorUsername
confidential $confidential
labelName $labelName
milestoneTitle $milestoneTitle
milestoneWildcardId $milestoneWildcardId
myReactionEmoji $myReactionEmoji
types $types
state $state
not $not
or $or

Hierarchy scoping defaults

The following variables are hardcoded as defaults for the work items query to ensure consistent scoping across the namespace hierarchy:

Variable Default Value Description
includeDescendants true Include work items from descendant namespaces
excludeProjects false Do not exclude project-level work items
excludeGroupWorkItems false Do not exclude group-level work items

Filters to be covered in future iterations

The following filters are supported by saved views (via FilterInputType and FilterSanitizerService) but are not yet handled by this MCP tool. If a saved view contains any of these filters, they will be silently ignored, potentially returning a broader result set than expected.

CE filters:

Filter UI Token Gating
search Search Always available
closedAfter / closedBefore Closed date issue_date_filter feature flag
createdAfter / createdBefore Created date issue_date_filter feature flag
dueAfter / dueBefore Due date issue_date_filter feature flag
updatedAfter / updatedBefore Updated date issue_date_filter feature flag
subscribed Subscribed Logged-in users only
releaseTag / releaseTagWildcardId Release Project-level only
in Search within Always available
crmContactId Contact readCrmContact permission
crmOrganizationId Organization readCrmOrganization permission
hierarchyFilters Parent Always available
fullPath Group Group-level only

EE filters:

Filter UI Token Gating
healthStatusFilter Health status Licensed feature
iterationId / iterationWildcardId Iteration Licensed feature
iterationCadenceId Iteration cadence Licensed feature
weight / weightWildcardId Weight Licensed feature
status Status Licensed feature
customField Custom fields Licensed feature

References

How to set up and validate locally

You can test get_saved_view_work_items tool using MCP inspector.

Example call:

{
  "name": "get_saved_view_work_items",
  "arguments": {
    "group_id": "gitlab-org",
    "saved_view_id": "gid://gitlab/WorkItems::SavedView/123"
  }
}

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 Naman Jagdish Gala

Merge request reports

Loading