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



47
48
49
# File 'lib/action_mcp/capability.rb', line 47

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.



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

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.



68
69
70
# File 'lib/action_mcp/capability.rb', line 68

def self.abstract?
  abstract_capability
end

.capability_nameObject

use _capability_name or default_capability_name



43
44
45
# File 'lib/action_mcp/capability.rb', line 43

def self.capability_name
  _capability_name || default_capability_name
end

.description(text = nil) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/action_mcp/capability.rb', line 72

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

Instance Method Details

#client_supports_ui?Boolean Also known as: client_supports_mcp_app?

Returns true when the connected client advertises the MCP Apps UI extension and supports ActionMCP’s HTML app resource MIME type.

Returns:

  • (Boolean)


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

def client_supports_ui?
  Apps.client_supports?(session&.client_capabilities)
end

#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