Class: LinearToonMcp::Tools::List

Inherits:
Base
  • Object
show all
Defined in:
lib/linear_toon_mcp/tools/list.rb

Overview

Base class for list tools. Queries a top-level GraphQL connection and returns its nodes + pageInfo. The connection name derives from the class name:

ListTeams.connection_name        # => "teams"
ListIssueLabels.connection_name  # => "issueLabels"

Override with List.connection when the GraphQL field diverges (e.g., ListIssueStatusesworkflowStates).

Subclasses define the QUERY constant and override #variables to compute GraphQL variables from inputs.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call, #call, error_response, success_response

Class Method Details

.connection(name) ⇒ Object

Overrides the derived GraphQL connection name.



20
21
22
# File 'lib/linear_toon_mcp/tools/list.rb', line 20

def connection(name)
  @connection = name.to_s
end

.connection_nameObject

Returns the GraphQL connection field name.



25
26
27
# File 'lib/linear_toon_mcp/tools/list.rb', line 25

def connection_name
  @connection ||= derive_connection_name
end

.query_stringObject

Returns the GraphQL query — the QUERY constant on the subclass.



30
31
32
# File 'lib/linear_toon_mcp/tools/list.rb', line 30

def query_string
  const_get(:QUERY)
end

Instance Method Details

#perform(**params) ⇒ Object

Queries query_string with #variables and extracts the connection field.

Raises:

  • (Error)

    when the connection field is missing



46
47
48
49
# File 'lib/linear_toon_mcp/tools/list.rb', line 46

def perform(**params)
  data = client.query(self.class.query_string, variables: variables(**params))
  data[self.class.connection_name] or raise Error, "Unexpected response: missing #{self.class.connection_name} field"
end

#variablesObject

Subclass hook. Returns the GraphQL variables hash for #perform. Defaults to no variables.



53
54
55
# File 'lib/linear_toon_mcp/tools/list.rb', line 53

def variables(**)
  {}
end