Class: HTM::MCP::GetGroupWorkingMemoryTool

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

Overview

Tool: Get group’s shared working memory contents

Instance Method Summary collapse

Instance Method Details

#call(group_name:) ⇒ Object



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/htm/mcp/group_tools.rb', line 400

def call(group_name:)
  Session.logger&.info "GetGroupWorkingMemoryTool called: group=#{group_name.inspect}"

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

  contents = group.working_memory_contents.map do |node|
    {
      id:         node.id,
      content:    node.content,
      tags:       node.tags.map(&:name),
      created_at: node.created_at.iso8601
    }
  end

  status = group.status

  Session.logger&.info "GetGroupWorkingMemoryTool complete: #{contents.length} nodes"

  {
    success:           true,
    group_name:        group_name,
    count:             contents.length,
    token_count:       status[:working_memory_tokens],
    token_utilization: status[:token_utilization],
    contents:          contents
  }.to_json
end