Class: ZeroMcp::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/zeromcp/tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description: '', input: {}, permissions: {}, &block) ⇒ Tool

Returns a new instance of Tool.



9
10
11
12
13
14
15
16
# File 'lib/zeromcp/tool.rb', line 9

def initialize(name:, description: '', input: {}, permissions: {}, &block)
  @name = name
  @description = description
  @input = input
  @permissions = permissions
  @execute_block = block
  @cached_schema = Schema.to_json_schema(@input)
end

Instance Attribute Details

#cached_schemaObject (readonly)

Returns the value of attribute cached_schema.



7
8
9
# File 'lib/zeromcp/tool.rb', line 7

def cached_schema
  @cached_schema
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/zeromcp/tool.rb', line 7

def description
  @description
end

#execute_blockObject (readonly)

Returns the value of attribute execute_block.



7
8
9
# File 'lib/zeromcp/tool.rb', line 7

def execute_block
  @execute_block
end

#inputObject (readonly)

Returns the value of attribute input.



7
8
9
# File 'lib/zeromcp/tool.rb', line 7

def input
  @input
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/zeromcp/tool.rb', line 7

def name
  @name
end

#permissionsObject (readonly)

Returns the value of attribute permissions.



7
8
9
# File 'lib/zeromcp/tool.rb', line 7

def permissions
  @permissions
end

Instance Method Details

#call(args, ctx = {}) ⇒ Object



18
19
20
# File 'lib/zeromcp/tool.rb', line 18

def call(args, ctx = {})
  @execute_block.call(args, ctx)
end