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 =

Returns MCP tool identifier string.

Returns:

  • (String)

    MCP tool identifier string.

'rai_comply'
DESCRIPTION =

Returns Human-readable description of this tool.

Returns:

  • (String)

    Human-readable description of this tool.

'Run rosett-ai compliance checks (CRA, license, SPDX headers)'
ANNOTATIONS =

Returns MCP protocol annotations describing tool capabilities.

Returns:

  • (Hash)

    MCP protocol annotations describing tool capabilities.

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

Returns JSON Schema defining the tool input parameters.

Returns:

  • (Hash)

    JSON Schema defining the tool input parameters.

{
  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



61
62
63
64
65
66
67
68
# File 'lib/rosett_ai/mcp/tools/comply_tool.rb', line 61

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