Add mcp labels tool

What does this MR do and why?

Adds a new MCP (Model Context Protocol) tool that enables searching for labels at both the project and group level. This tool returns label metadata including the label ID and title, allowing MCP clients to query label information from a GitLab instance.

The implementation includes:

  • GraphQL-based label search supporting both project and group scopes
  • Flexible search filtering by label title
  • Ancestor and descendant group label inclusion for group-level searches
  • Proper error handling and response formatting

Changes included

  • New Mcp::Tools::Labels::SearchTool GraphQL tool for executing label searches
  • New Mcp::Tools::Labels::GraphqlSearchService service for MCP tool registration
  • Updated Mcp::Tools::Manager to register the search_labels tool
  • Comprehensive test coverage for both service and tool classes
  • Updated MCP tools list specification

References

https://gitlab.com/gitlab-org/gitlab/-/issues/584673

Screenshots or screen recordings

How to set up and validate locally

  1. Connect your GDK as an MCP server to a Claude desktop application (or other app able to communicate with mcp)
  2. Query labels by asking the Claude app about labels in a specific project or group
  3. Verify the response contains:
    • Label IDs (in GraphQL global ID format)
    • Label titles
    • Proper error handling for non-existent projects/groups

Example query parameters:

  • full_path: Project or group full path (e.g., namespace/project)
  • is_project: Boolean flag (true for projects, false for groups)
  • search: Optional search term to filter labels by title

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 Gosia Ksionek

Merge request reports

Loading