Class: KairosMcp::Tools::ContextSave
- Inherits:
-
BaseTool
- Object
- BaseTool
- KairosMcp::Tools::ContextSave
show all
- Defined in:
- lib/kairos_mcp/tools/context_save.rb
Instance Method Summary
collapse
Methods inherited from BaseTool
#initialize, #invoke_tool, #to_full_schema, #to_schema
Instance Method Details
#call(arguments) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 68
def call(arguments)
name = arguments['name']
content = arguments['content']
session_id = arguments['session_id']
create_subdirs = arguments['create_subdirs'] || false
return text_content("Error: name is required") unless name && !name.empty?
return text_content("Error: content is required") unless content && !content.empty?
manager = ContextManager.new(nil, user_context: @safety&.current_user)
if session_id.nil? || session_id.empty?
session_id = manager.generate_session_id
end
result = manager.save_context(session_id, name, content, create_subdirs: create_subdirs)
if result[:success]
output = "SUCCESS: Context #{result[:action]}\n\n"
output += "**Session:** #{session_id}\n"
output += "**Name:** #{name}\n"
output += "\nNo blockchain recording (L2 is free modification)."
text_content(output)
else
text_content("FAILED: #{result[:error]}")
end
end
|
#category ⇒ Object
18
19
20
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 18
def category
:context
end
|
#description ⇒ Object
14
15
16
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 14
def description
'Save (create or update) a L2 context. No blockchain recording - free modification for temporary work.'
end
|
#examples ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 26
def examples
[
{
title: 'Save a hypothesis',
code: 'context_save(name: "auth_hypothesis", content: "---\nname: auth_hypothesis\ndescription: Trying new auth approach\n---\n# Auth Hypothesis\n...")'
},
{
title: 'Save with session ID',
code: 'context_save(session_id: "debug_session_123", name: "debug_notes", content: "...")'
}
]
end
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 43
def input_schema
{
type: 'object',
properties: {
session_id: {
type: 'string',
description: 'The session ID (will be auto-generated if not provided for new sessions)'
},
name: {
type: 'string',
description: 'Context name'
},
content: {
type: 'string',
description: 'Full content including YAML frontmatter'
},
create_subdirs: {
type: 'boolean',
description: 'Create scripts/assets/references subdirectories (default: false)'
}
},
required: %w[name content]
}
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 10
def name
'context_save'
end
|
39
40
41
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 39
def related_tools
%w[context_create_subdir skills_promote knowledge_update]
end
|
22
23
24
|
# File 'lib/kairos_mcp/tools/context_save.rb', line 22
def usecase_tags
%w[save temporary L2 context hypothesis memo scratch]
end
|