Class: ZeroMcp::Scanner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Scanner

Returns a new instance of Scanner.



9
10
11
12
# File 'lib/zeromcp/scanner.rb', line 9

def initialize(config)
  @config = config
  @tools = {}
end

Instance Attribute Details

#toolsObject (readonly)

Returns the value of attribute tools.



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

def tools
  @tools
end

Instance Method Details

#scanObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/zeromcp/scanner.rb', line 14

def scan
  @tools.clear
  dirs = @config.tools_dir
  dirs = [dirs] unless dirs.is_a?(Array)

  dirs.each do |d|
    dir = File.expand_path(d)
    unless Dir.exist?(dir)
      $stderr.puts "[zeromcp] Cannot read tools directory: #{dir}"
      next
    end
    scan_dir(dir, dir)
  end
  @tools
end