Class: Mewmew::ThorIntrospector

Inherits:
Object
  • Object
show all
Defined in:
lib/mewmew/thor_introspector.rb

Overview

Introspects Thor CLI classes and extracts command information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thor_class) ⇒ ThorIntrospector

Returns a new instance of ThorIntrospector.



16
17
18
19
# File 'lib/mewmew/thor_introspector.rb', line 16

def initialize(thor_class)
  @thor_class = thor_class
  validate_thor_class!
end

Instance Attribute Details

#thor_classObject (readonly)

Returns the value of attribute thor_class.



14
15
16
# File 'lib/mewmew/thor_introspector.rb', line 14

def thor_class
  @thor_class
end

Instance Method Details

#commandsObject

Get all commands from the Thor class



22
23
24
# File 'lib/mewmew/thor_introspector.rb', line 22

def commands
  @commands ||= thor_class.commands.except("help", "mcp")
end

#to_mcp_toolsObject

Convert Thor commands to MCP tools



27
28
29
30
31
# File 'lib/mewmew/thor_introspector.rb', line 27

def to_mcp_tools
  commands.map do |name, command|
    create_tool_class(name, command, thor_class)
  end
end