Class: RailsAiBridge::Doctor::Checkers::StimulusMcpToolChecker

Inherits:
BaseChecker
  • Object
show all
Defined in:
lib/rails_ai_bridge/doctor/checkers/stimulus_mcp_tool_checker.rb

Overview

Ensures +rails_get_stimulus+ is registered when Stimulus files and introspection matter.

Instance Attribute Summary

Attributes inherited from BaseChecker

#app

Instance Method Summary collapse

Methods inherited from BaseChecker

#initialize

Constructor Details

This class inherits a constructor from RailsAiBridge::Doctor::Checkers::BaseChecker

Instance Method Details

#callDoctor::Check

Returns +:pass+, +:warn+, or +:fail+ depending on Stimulus files and tool registration.

Returns:

  • (Doctor::Check)

    +:pass+, +:warn+, or +:fail+ depending on Stimulus files and tool registration



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_ai_bridge/doctor/checkers/stimulus_mcp_tool_checker.rb', line 9

def call
  unless stimulus_files_present?
    return new_check(name: 'Stimulus MCP tool', status: :pass,
                     message: 'No Stimulus controllers detected; stimulus MCP tool not required', fix: nil)
  end

  unless RailsAiBridge.configuration.introspectors.include?(:stimulus)
    return new_check(
      name: 'Stimulus MCP tool',
      status: :warn,
      message: 'Stimulus controllers detected but :stimulus introspector is disabled',
      fix: 'Enable it with `RailsAiBridge.configure { |c| c.introspectors |= [:stimulus] }`'
    )
  end

  check(
    'Stimulus MCP tool',
    tool_registered?('rails_get_stimulus'),
    pass: { message: 'rails_get_stimulus available for Hotwire UI inspection' },
    fail: { status: :fail, message: 'rails_get_stimulus is not registered', fix: 'Register `RailsAiBridge::Tools::GetStimulus` in the MCP server' }
  )
end