Class: RosettAi::Mcp::Tools::BehaviourManageTool

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

Overview

MCP tool: manage behaviour files.

Add, modify, or delete behaviour configurations. Write operation — destructive when action is 'delete'.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =

Returns MCP tool identifier string.

Returns:

  • (String)

    MCP tool identifier string.

'rai_behaviour_manage'
DESCRIPTION =

Returns Human-readable description of this tool.

Returns:

  • (String)

    Human-readable description of this tool.

'Add, modify, or delete rai behaviour files'
ANNOTATIONS =

Returns MCP protocol annotations describing tool capabilities.

Returns:

  • (Hash)

    MCP protocol annotations describing tool capabilities.

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

Returns Set of permitted action values.

Returns:

  • (Array)

    Set of permitted action values.

['add', 'modify', 'delete'].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: ['add', 'modify', 'delete'],
      description: 'Management action to perform'
    },
    name: {
      type: 'string',
      description: 'Behaviour name'
    },
    description: {
      type: 'string',
      description: 'Behaviour description (for add/modify)'
    },
    force: {
      type: 'boolean',
      description: 'Skip confirmation for delete (default: false)'
    }
  },
  required: ['action', 'name']
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(action:, name:, description: nil, force: false) ⇒ Hash

Executes the behaviour management operation.

Parameters:

  • action (String)

    one of 'add', 'modify', 'delete'

  • name (String)

    behaviour name

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

    behaviour description (for add/modify)

  • force (Boolean) (defaults to: false)

    skip confirmation for delete

Returns:

  • (Hash)

    operation result



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rosett_ai/mcp/tools/behaviour_manage_tool.rb', line 65

def call(action:, name:, description: nil, force: false)
  return ResponseHelper.error("Invalid action: #{action}") unless VALID_ACTIONS.include?(action)
  return ResponseHelper.error('Name is required') if name.nil? || name.empty?

  case action
  when 'add' then action_add(name, description: description)
  when 'modify' then action_modify(name, description: description)
  when 'delete' then action_delete(name, force: force)
  end
rescue StandardError => e
  ResponseHelper.error("Behaviour #{action} failed: #{e.message}")
end