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 =

Returns MCP tool identifier string.

Returns:

  • (String)

    MCP tool identifier string.

'rai_retrofit'
DESCRIPTION =

Returns Human-readable description of this tool.

Returns:

  • (String)

    Human-readable description of this tool.

'Scan and convert native AI configs to rosett-ai format'
ANNOTATIONS =

Returns MCP protocol annotations describing tool capabilities.

Returns:

  • (Hash)

    MCP protocol annotations describing tool capabilities.

{
  'readOnlyHint' => false,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
VALID_ACTIONS =

Returns Set of permitted action values.

Returns:

  • (Array)

    Set of permitted action values.

['engines', 'scan', 'convert'].freeze
INPUT_SCHEMA =

Returns JSON Schema defining the tool input parameters.

Returns:

  • (Hash)

    JSON Schema defining the tool input parameters.

{
  type: 'object',
  properties: {
    action: {
      type: 'string',
      enum: ['engines', 'scan', 'convert'],
      description: 'Retrofit action (default: scan)'
    },
    engine: {
      type: 'string',
      description: 'Engine to retrofit from'
    },
    simulate: {
      type: 'boolean',
      description: 'Dry-run mode (default: true)'
    }
  }
}.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



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rosett_ai/mcp/tools/retrofit_tool.rb', line 59

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