Class: RosettAi::Mcp::Tools::HooksStatusTool

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

Overview

MCP tool: show git hooks status.

Lists configured hooks and their installation status. Read-only operation.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =

Returns MCP tool identifier string.

Returns:

  • (String)

    MCP tool identifier string.

'rai_hooks_status'
DESCRIPTION =

Returns Human-readable description of this tool.

Returns:

  • (String)

    Human-readable description of this tool.

'Show git hooks list and installation status'
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
VALID_ACTIONS =

Returns Set of permitted action values.

Returns:

  • (Array)

    Set of permitted action values.

['list', 'status'].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: ['list', 'status'],
      description: 'Hooks action (default: status)'
    }
  }
}.freeze
HOOK_PHASES =

Known overcommit hook phases.

[
  'PreCommit', 'CommitMsg', 'PrePush', 'PreRebase',
  'PostCheckout', 'PostCommit', 'PostMerge', 'PostRewrite'
].freeze

Instance Method Summary collapse

Instance Method Details

#call(action: 'status') ⇒ Hash

Executes the hooks query.

Parameters:

  • action (String) (defaults to: 'status')

    one of 'list' or 'status'

Returns:

  • (Hash)

    hooks information



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rosett_ai/mcp/tools/hooks_status_tool.rb', line 55

def call(action: 'status')
  return ResponseHelper.error("Invalid action: #{action}") unless VALID_ACTIONS.include?(action)

  hooks_config = RosettAi.root.join('.overcommit.yml')
  return ResponseHelper.error('No .overcommit.yml found') unless hooks_config.exist?

  data = YAML.safe_load_file(hooks_config, permitted_classes: [Symbol])
  {
    action: action,
    installed: RosettAi.root.join('.git', 'hooks', 'overcommit-hook').exist?,
    hooks: extract_hooks(data)
  }
rescue Psych::SyntaxError => e
  ResponseHelper.error("Hooks config parse error: #{e.message}")
end