Class: RosettAi::Mcp::Tools::ComplyTool

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

Overview

MCP tool: run rosett-ai compliance checks.

Executes CRA, license, and SPDX header checks. Read-only operation — does not modify any files.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =
'rai_comply'
DESCRIPTION =
'Run rosett-ai compliance checks (CRA, license, SPDX headers)'
ANNOTATIONS =
{
  'readOnlyHint' => true,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
INPUT_SCHEMA =
{
  type: 'object',
  properties: {
    cra: {
      type: 'boolean',
      description: 'Run CRA-specific checks only (default: false)'
    },
    license: {
      type: 'boolean',
      description: 'Run license audit checks only (default: false)'
    },
    headers: {
      type: 'boolean',
      description: 'Run SPDX header checks only (default: false)'
    },
    format: {
      type: 'string',
      enum: ['json', 'text'],
      description: 'Output format (default: json)'
    }
  }
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(cra: false, license: false, headers: false, format: 'json') ⇒ Hash

Executes compliance checks.

Parameters:

  • cra (Boolean) (defaults to: false)

    run CRA checks only

  • license (Boolean) (defaults to: false)

    run license checks only

  • headers (Boolean) (defaults to: false)

    run SPDX header checks only

  • format (String) (defaults to: 'json')

    output format ('json' or 'text')

Returns:

  • (Hash)

    compliance results



57
58
59
60
61
62
63
64
# File 'lib/rosett_ai/mcp/tools/comply_tool.rb', line 57

def call(cra: false, license: false, headers: false, format: 'json')
  checks = filter_checks(cra: cra, license: license, headers: headers)
  results = run_checks(checks)
  violations = results.select { |r| r[:status] == 'fail' }
  { compliant: violations.empty?, results: results, violations: violations, format: format }
rescue StandardError => e
  ResponseHelper.error("Compliance check failed: #{e.message}")
end