Class: ActionMCP::Capability
- Inherits:
-
Object
- Object
- ActionMCP::Capability
- Includes:
- Callbacks, Instrumentation::Instrumentation, Renderable, ActiveModel::Attributes, ActiveModel::Model
- Defined in:
- lib/action_mcp/capability.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#execution_context ⇒ Object
readonly
Returns the value of attribute execution_context.
Class Method Summary collapse
-
.abstract! ⇒ void
Marks this tool as abstract so that it won’t be available for use.
-
.abstract? ⇒ Boolean
Returns whether this tool is abstract.
-
.capability_name ⇒ Object
use _capability_name or default_capability_name.
- .description(text = nil) ⇒ Object
Instance Method Summary collapse
-
#client_supports_ui? ⇒ Boolean
Returns true when the connected client advertises the MCP Apps UI extension.
-
#initialize ⇒ Capability
constructor
A new instance of Capability.
- #session ⇒ Object
- #with_context(context) ⇒ Object
Methods included from Renderable
#render, #render_resource_link
Constructor Details
#initialize ⇒ Capability
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_capability ⇒ Object
45 46 47 |
# File 'lib/action_mcp/capability.rb', line 45 def self.abstract_capability @abstract_capability ||= false # Default to false, unique to each class end |
Instance Attribute Details
#execution_context ⇒ Object (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.
57 58 59 60 61 |
# File 'lib/action_mcp/capability.rb', line 57 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.
66 67 68 |
# File 'lib/action_mcp/capability.rb', line 66 def self.abstract? abstract_capability end |
.capability_name ⇒ Object
use _capability_name or default_capability_name
41 42 43 |
# File 'lib/action_mcp/capability.rb', line 41 def self.capability_name _capability_name || default_capability_name end |
.description(text = nil) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/action_mcp/capability.rb', line 70 def self.description(text = nil) if text self._description = text else _description end end |
Instance Method Details
#client_supports_ui? ⇒ Boolean
Returns true when the connected client advertises the MCP Apps UI extension.
36 37 38 |
# File 'lib/action_mcp/capability.rb', line 36 def client_supports_ui? !session&.client_capabilities&.dig("extensions", Apps::EXTENSION_KEY).nil? end |
#session ⇒ Object
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 |