Class: HTM::MCP::GroupRememberTool

Inherits:
FastMcp::Tool
  • Object
show all
Defined in:
lib/htm/mcp/group_tools.rb

Overview

Tool: Remember via group (syncs to all members)

Instance Method Summary collapse

Instance Method Details

#call(group_name:, content:, tags: [], metadata: {}) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/htm/mcp/group_tools.rb', line 235

def call(group_name:, content:, tags: [], metadata: {})
  Session.logger&.info "GroupRememberTool called: group=#{group_name.inspect}, content=#{content[0..50].inspect}..."

  group = GroupSession.get_group(group_name)
  unless group
    return { success: false, error: "Group '#{group_name}' not found in this session" }.to_json
  end

  robot_name = Session.robot_name
  node_id = group.remember(content, originator: robot_name, tags: tags, metadata: )

  Session.logger&.info "Group memory stored: node_id=#{node_id}, group=#{group_name}"

  {
    success:    true,
    node_id:    node_id,
    group_name: group_name,
    originator: robot_name,
    message:    "Memory stored and synced to all group members"
  }.to_json
rescue StandardError => e
  Session.logger&.error "GroupRememberTool error: #{e.message}"
  { success: false, error: e.message }.to_json
end