Class: Profiler::MCP::Tools::GetProfileDumps
- Inherits:
-
Object
- Object
- Profiler::MCP::Tools::GetProfileDumps
- Defined in:
- lib/profiler/mcp/tools/get_profile_dumps.rb
Class Method Summary collapse
Class Method Details
.call(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/profiler/mcp/tools/get_profile_dumps.rb', line 7 def self.call(params) token = params["token"] unless token return [{ type: "text", text: "Error: token parameter is required" }] end profile = if token == "latest" Profiler.storage.list(limit: 1).first else Profiler.storage.load(token) end unless profile return [{ type: "text", text: "Profile not found: #{token}" }] end dump_data = profile.collector_data("dump") unless dump_data && dump_data["count"].to_i > 0 return [{ type: "text", text: "No variable dumps found in this profile" }] end [{ type: "text", text: format_dumps(profile, dump_data) }] end |
.format_dumps(profile, dump_data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/profiler/mcp/tools/get_profile_dumps.rb', line 32 def self.format_dumps(profile, dump_data) lines = [] lines << "# Variable Dumps: #{profile.token}\n" lines << "**Request:** #{profile.method} #{profile.path}" lines << "**Total Dumps:** #{dump_data['count']}\n" dump_data["dumps"]&.each_with_index do |dump, index| label = dump['label'] || "Dump #{index + 1}" location = [dump['file'], dump['line']].compact.join(':') lines << "## #{label}" lines << "- **Source:** #{location}" unless location.empty? lines << "- **Timestamp:** #{dump['timestamp']}" if dump['timestamp'] lines << "\n```" lines << (dump['formatted'] || dump['value'].inspect) lines << "```\n" end lines.join("\n") end |