Class: Crumb::MCP::Tools::RecentDeploysTool

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/crumb/mcp/tools/recent_deploys.rb

Class Method Summary collapse

Class Method Details

.call(endpoint: nil, limit: 20, server_context: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/crumb/mcp/tools/recent_deploys.rb', line 15

def call(endpoint: nil, limit: 20, server_context: nil)
  slugs   = endpoint ? [ endpoint ] : Registry.all_slugs
  deploys = []
  errors  = []

  slugs.each do |slug|
    deploys.concat(ApiClient.for(slug).recent(limit: limit))
  rescue => e
    errors << "[#{slug}] error: #{e.message}"
  end

  deploys.sort_by! { |d| d["finished_at"].to_s }.reverse!

  text  = format_deploys(deploys)
  text += "\n\n" + errors.join("\n") unless errors.empty?
  ::MCP::Tool::Response.new([ { type: "text", text: text } ])
end