Class: RosettAi::Mcp::Tools::ValidateTool

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

Overview

MCP tool: validate rai configuration files.

Performs both YAML syntax and JSON Schema validation using the project's Validators::SchemaValidator hierarchy. Read-only operation.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =
'rai_validate'
DESCRIPTION =
'Validate rai configuration files (behaviours, designs, tooling)'
ANNOTATIONS =
{
  'readOnlyHint' => true,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
SCOPE_VALIDATORS =

Maps scope names to their validator classes.

{
  'behaviour' => -> { RosettAi::Validators::BehaviourValidator.new },
  'design' => -> { RosettAi::Validators::DesignValidator.new },
  'tooling' => -> { RosettAi::Validators::ToolingValidator.new }
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(scope: nil) ⇒ Hash

Executes the validation with JSON Schema checking.

Parameters:

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

    optional scope filter ('behaviour', 'design', 'tooling')

Returns:

  • (Hash)

    result with :valid, :errors, :warnings



41
42
43
44
45
46
47
48
# File 'lib/rosett_ai/mcp/tools/validate_tool.rb', line 41

def call(scope: nil)
  results = { valid: true, errors: [], warnings: [] }
  scopes = scope ? [scope] : ['behaviour', 'design']

  scopes.each { |s| validate_scope(s, results) }
  results[:valid] = results[:errors].empty?
  results
end