Class: RosettAi::Mcp::Tools::RetrofitTool

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/mcp/tools/retrofit_tool.rb

Overview

MCP tool: retrofit native configurations.

Scan and convert native AI tool configs to Rosett-AI YAML. Write operation for convert action.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =
'rai_retrofit'
DESCRIPTION =
'Scan and convert native AI configs to rosett-ai format'
ANNOTATIONS =
{
  'readOnlyHint' => false,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
VALID_ACTIONS =
['engines', 'scan', 'convert'].freeze

Instance Method Summary collapse

Instance Method Details

#call(action: 'scan', engine: nil, simulate: true) ⇒ Hash

Executes the retrofit operation.

Parameters:

  • action (String) (defaults to: 'scan')

    one of 'engines', 'scan', 'convert'

  • engine (String, nil) (defaults to: nil)

    specific engine for conversion

  • simulate (Boolean) (defaults to: true)

    dry-run mode for convert

Returns:

  • (Hash)

    retrofit results



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rosett_ai/mcp/tools/retrofit_tool.rb', line 35

def call(action: 'scan', engine: nil, simulate: true)
  return ResponseHelper.error("Invalid action: #{action}") unless VALID_ACTIONS.include?(action)

  retrofitter = RosettAi::Retrofit::Scanner.new
  case action
  when 'engines' then { parsers: retrofitter.available_parsers }
  when 'scan' then { findings: retrofitter.scan }
  when 'convert' then action_convert(retrofitter, engine, simulate)
  end
rescue StandardError => e
  ResponseHelper.error("Retrofit #{action} failed: #{e.message}")
end