Class: KairosMcp::Tools::ChainExport
- Inherits:
-
BaseTool
- Object
- BaseTool
- KairosMcp::Tools::ChainExport
show all
- Defined in:
- lib/kairos_mcp/tools/chain_export.rb
Instance Method Summary
collapse
Methods inherited from BaseTool
#initialize, #invoke_tool, #to_full_schema, #to_schema
Instance Method Details
#call(arguments) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
96
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 54
def call(arguments)
unless SkillsConfig.storage_backend_sqlite?
return text_content("Error: chain_export only works with SQLite backend. Current backend: #{SkillsConfig.storage_backend}")
end
require_relative '../storage/exporter'
sqlite_config = SkillsConfig.sqlite_config
db_path = File.expand_path(sqlite_config['path'] || 'storage/kairos.db', base_dir)
output_dir = arguments['output_dir'] || File.expand_path('storage/export', base_dir)
unless File.exist?(db_path)
return text_content("Error: SQLite database not found at #{db_path}")
end
result = Storage::Exporter.export(db_path: db_path, output_dir: output_dir)
if result[:error]
return text_content("Export failed: #{result[:error]}")
end
output = <<~OUTPUT
Export completed successfully!
Output directory: #{output_dir}
Exported:
- Blocks: #{result[:blocks]}
- Action logs: #{result[:action_logs]}
- Knowledge metadata: #{result[:knowledge_meta]}
Files created:
- blockchain.json
- action_log.jsonl
- knowledge_meta.json
- manifest.json
OUTPUT
text_content(output)
end
|
#category ⇒ Object
17
18
19
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 17
def category
:chain
end
|
#description ⇒ Object
13
14
15
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 13
def description
'Export data from SQLite database to human-readable files (blockchain.json, action_log.jsonl, knowledge_meta.json). Only works when using SQLite backend.'
end
|
#examples ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 25
def examples
[
{
title: 'Export to default directory',
code: 'chain_export()'
},
{
title: 'Export to custom directory',
code: 'chain_export(output_dir: "/path/to/export")'
}
]
end
|
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 42
def input_schema
{
type: 'object',
properties: {
output_dir: {
type: 'string',
description: 'Directory to export files to. Defaults to storage/export/'
}
}
}
end
|
#name ⇒ Object
9
10
11
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 9
def name
'chain_export'
end
|
38
39
40
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 38
def related_tools
%w[chain_import chain_status]
end
|
21
22
23
|
# File 'lib/kairos_mcp/tools/chain_export.rb', line 21
def usecase_tags
%w[export backup sqlite files blockchain]
end
|