Class: KairosMcp::Tools::ContextCreateSubdir

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/kairos_mcp/tools/context_create_subdir.rb

Instance Method Summary collapse

Methods inherited from BaseTool

#initialize, #invoke_tool, #to_full_schema, #to_schema

Constructor Details

This class inherits a constructor from KairosMcp::Tools::BaseTool

Instance Method Details

#call(arguments) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 60

def call(arguments)
  session_id = arguments['session_id']
  name = arguments['name']
  subdir = arguments['subdir']

  return text_content("Error: session_id is required") unless session_id && !session_id.empty?
  return text_content("Error: name is required") unless name && !name.empty?
  return text_content("Error: subdir is required") unless subdir && !subdir.empty?

  manager = ContextManager.new(nil, user_context: @safety&.current_user)
  result = manager.create_subdir(session_id, name, subdir)

  if result[:success]
    text_content("SUCCESS: Created subdirectory\n\n**Path:** `#{result[:path]}`")
  else
    text_content("FAILED: #{result[:error]}")
  end
end

#categoryObject



17
18
19
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 17

def category
  :context
end

#descriptionObject



13
14
15
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 13

def description
  'Create a subdirectory (scripts, assets, or references) in a L2 context.'
end

#examplesObject



25
26
27
28
29
30
31
32
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 25

def examples
  [
    {
      title: 'Create scripts subdirectory',
      code: 'context_create_subdir(session_id: "my_session", name: "my_context", subdir: "scripts")'
    }
  ]
end

#input_schemaObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 38

def input_schema
  {
    type: 'object',
    properties: {
      session_id: {
        type: 'string',
        description: 'The session ID'
      },
      name: {
        type: 'string',
        description: 'The context name'
      },
      subdir: {
        type: 'string',
        description: 'Subdirectory to create: "scripts", "assets", or "references"',
        enum: %w[scripts assets references]
      }
    },
    required: %w[session_id name subdir]
  }
end

#nameObject



9
10
11
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 9

def name
  'context_create_subdir'
end


34
35
36
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 34

def related_tools
  %w[context_save]
end

#usecase_tagsObject



21
22
23
# File 'lib/kairos_mcp/tools/context_create_subdir.rb', line 21

def usecase_tags
  %w[create L2 context subdirectory scripts assets references]
end