Class: ActiveMcp::Schema::Base
- Inherits:
-
Object
- Object
- ActiveMcp::Schema::Base
- Defined in:
- lib/active_mcp/schema/base.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(context: {}) ⇒ Base
constructor
A new instance of Base.
- #visible_prompts ⇒ Object
- #visible_resource_templates ⇒ Object
- #visible_resources ⇒ Object
- #visible_tools ⇒ Object
Constructor Details
#initialize(context: {}) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/active_mcp/schema/base.rb', line 6 def initialize(context: {}) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/active_mcp/schema/base.rb', line 4 def context @context end |
Instance Method Details
#visible_prompts ⇒ Object
30 31 32 33 34 |
# File 'lib/active_mcp/schema/base.rb', line 30 def visible_prompts prompts&.filter do |resource| !resource.respond_to?(:visible?) || resource.visible?(context: @context) end end |
#visible_resource_templates ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/active_mcp/schema/base.rb', line 16 def visible_resource_templates resource_instances = resources&.filter do |resource| resource.class.respond_to?(:uri_template) && (!resource.respond_to?(:visible?) || resource.visible?(context: @context)) end resource_instances.map(&:class).uniq end |
#visible_resources ⇒ Object
10 11 12 13 14 |
# File 'lib/active_mcp/schema/base.rb', line 10 def visible_resources resources&.filter do |resource| !resource.respond_to?(:visible?) || resource.visible?(context: @context) end end |
#visible_tools ⇒ Object
24 25 26 27 28 |
# File 'lib/active_mcp/schema/base.rb', line 24 def visible_tools tools&.filter do |tool| !tool.respond_to?(:visible?) || tool.visible?(context: @context) end end |