20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/legion/mcp/tools/team_summary.rb', line 20
def call(team:)
log.info('Starting legion.mcp.tools.team_summary.call')
return error_response('legion-data is not connected') unless data_connected?
workers = Legion::DigitalWorker.by_team(team: team).all
breakdown = workers.each_with_object(Hash.new(0)) { |w, counts| counts[w.values[:lifecycle_state]] += 1 }
text_response({
team: team,
total: workers.size,
lifecycle_states: breakdown,
workers: workers.map do |w|
w.values.slice(:worker_id, :name, :lifecycle_state, :owner_msid, :business_role)
end
})
rescue StandardError => e
handle_exception(e, level: :warn, operation: 'legion.mcp.tools.team_summary.call')
log.warn("TeamSummary#call failed: #{e.message}")
error_response("Failed to fetch team summary: #{e.message}")
end
|