Class: Mcp::Tools::Labels::SearchTool

Inherits:
GraphqlTool show all
Includes:
Concerns::Constants
Defined in:
app/services/mcp/tools/labels/search_tool.rb

Constant Summary

Constants included from Concerns::Constants

Concerns::Constants::ALL_TYPES, Concerns::Constants::GROUP_ONLY_TYPES, Concerns::Constants::PROJECT_AND_GROUP_TYPES, Concerns::Constants::URL_PATTERNS, Concerns::Constants::VERSIONS

Constants included from Concerns::Versionable

Concerns::Versionable::VERSION_FORMAT

Instance Attribute Summary

Attributes inherited from GraphqlTool

#current_user, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GraphqlTool

#execute, #graphql_operation, #initialize

Methods included from Concerns::Versionable

#description, #graphql_operation, #initialize_version, #input_schema, #version

Constructor Details

This class inherits a constructor from Mcp::Tools::GraphqlTool

Class Method Details

.build_queryObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/services/mcp/tools/labels/search_tool.rb', line 10

def build_query
  <<~GRAPHQL
  query searchLabels($fullPath: ID!, $search: String, $isProject: Boolean = false) {
    group(fullPath: $fullPath) @skip(if: $isProject) {
      id
      labels(
        searchTerm: $search
        includeAncestorGroups: true
        includeDescendantGroups: true
      ) {
        nodes {
          ... on Label {
            id
            title
          }
        }
      }
    }
    project(fullPath: $fullPath) @include(if: $isProject) {
      id
      labels(searchTerm: $search, includeAncestorGroups: true) {
        nodes {
          ... on Label {
            id
            title
          }
        }
      }
    }
  }
  GRAPHQL
end

Instance Method Details

#build_variablesObject



48
49
50
51
52
53
54
# File 'app/services/mcp/tools/labels/search_tool.rb', line 48

def build_variables
  {
    isProject: params[:is_project],
    fullPath: params[:full_path],
    search: params[:search]
  }.compact
end

#operation_nameObject



56
57
58
# File 'app/services/mcp/tools/labels/search_tool.rb', line 56

def operation_name
  params[:is_project] ? 'project' : 'group'
end