Class: ActiveMcp::Schema::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_mcp/schema/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contextObject (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_promptsObject



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_templatesObject



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_resourcesObject



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_toolsObject



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