Class: Crumb::MCP::Tools::CompareDeploysTool

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

Class Method Summary collapse

Class Method Details

.call(endpoint:, from_id:, to_id:, server_context: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/crumb/mcp/tools/compare_deploys.rb', line 17

def call(endpoint:, from_id:, to_id:, server_context: nil)
  client = ApiClient.for(endpoint)
  from   = client.detail(from_id)
  to     = client.detail(to_id)

  all_commits = (Array(from["commits"]) + Array(to["commits"]))
    .uniq { |c| c["sha"] }
  all_files   = (Array(from["changed_files"]) + Array(to["changed_files"]))
    .uniq { |f| f["path"] }

  text = "Comparison between deploy ##{from_id} and ##{to_id} on #{endpoint}\n\n"
  text += "Commits (#{all_commits.size} unique):\n"
  all_commits.each { |c| text += "  #{c["sha"].to_s[0, 8]} #{c["author"]}#{c["message"]}\n" }
  text += "\nChanged files (#{all_files.size} unique):\n"
  all_files.each { |f| text += "  #{f["change_type"]} #{f["path"]}\n" }

  ::MCP::Tool::Response.new([ { type: "text", text: text } ])
end