Class: Msf::MCP::Tools::RunningStats

Inherits:
MCP::Tool
  • Object
show all
Extended by:
ToolHelper
Defined in:
lib/msf/core/mcp/tools/running_stats.rb

Overview

MCP Tool: List Running Module Stats

Wraps the ‘module.running_stats` RPC endpoint and returns the UUIDs of module runs currently in each lifecycle state (waiting, running, results).

Constant Summary

Constants included from ToolHelper

ToolHelper::DANGEROUS_MODE_DISABLED_MESSAGE

Class Method Summary collapse

Methods included from ToolHelper

dangerous_mode_required!, tool_error_response, with_tool_context

Class Method Details

.call(server_context:) ⇒ MCP::Tool::Response

Execute running stats lookup

Parameters:

  • server_context (Hash)

    Server context with msf_client, rate_limiter

Returns:

  • (MCP::Tool::Response)

    Structured response with running stats



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/msf/core/mcp/tools/running_stats.rb', line 55

def call(server_context:)
  with_tool_context(server_context, 'running_stats') do |msf_client|
    raw_result, elapsed = Rex::Stopwatch.elapsed_time do
      msf_client.running_stats
    end

    data = {
      waiting: raw_result['waiting'] || [],
      running: raw_result['running'] || [],
      results: raw_result['results'] || []
    }

     = { query_time: elapsed.round(3) }

    ::MCP::Tool::Response.new(
      [{ type: 'text', text: JSON.generate(metadata: , data: data) }],
      structured_content: { metadata: , data: data }
    )
  end
end