Class: ActionMCP::Capability

Inherits:
Object
  • Object
show all
Includes:
Callbacks, Instrumentation::Instrumentation, Renderable, ActiveModel::Attributes, ActiveModel::Model
Defined in:
lib/action_mcp/capability.rb

Direct Known Subclasses

Prompt, Tool

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Renderable

#render, #render_resource_link

Constructor Details

#initializeCapability

Returns a new instance of Capability.



19
20
21
22
# File 'lib/action_mcp/capability.rb', line 19

def initialize(*)
  super
  @execution_context = {}
end

Class Attribute Details

.abstract_capabilityObject



38
39
40
# File 'lib/action_mcp/capability.rb', line 38

def self.abstract_capability
  @abstract_capability ||= false # Default to false, unique to each class
end

Instance Attribute Details

#execution_contextObject (readonly)

Returns the value of attribute execution_context.



17
18
19
# File 'lib/action_mcp/capability.rb', line 17

def execution_context
  @execution_context
end

Class Method Details

.abstract!void

This method returns an undefined value.

Marks this tool as abstract so that it won’t be available for use. If the tool is registered in ToolsRegistry, it is unregistered.



50
51
52
53
54
# File 'lib/action_mcp/capability.rb', line 50

def self.abstract!
  self.abstract_capability = true
  # Unregister from the appropriate registry if already registered
  unregister_from_registry
end

.abstract?Boolean

Returns whether this tool is abstract.

Returns:

  • (Boolean)

    true if abstract, false otherwise.



59
60
61
# File 'lib/action_mcp/capability.rb', line 59

def self.abstract?
  abstract_capability
end

.capability_nameObject

use _capability_name or default_capability_name



34
35
36
# File 'lib/action_mcp/capability.rb', line 34

def self.capability_name
  _capability_name || default_capability_name
end

.description(text = nil) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/action_mcp/capability.rb', line 63

def self.description(text = nil)
  if text
    self._description = text
  else
    _description
  end
end

Instance Method Details

#sessionObject



29
30
31
# File 'lib/action_mcp/capability.rb', line 29

def session
  execution_context[:session]
end

#with_context(context) ⇒ Object



24
25
26
27
# File 'lib/action_mcp/capability.rb', line 24

def with_context(context)
  @execution_context = context
  self
end