Class: Msf::MCP::Tools::ModuleInfo

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

Overview

MCP Tool: Get Metasploit Module Information

Retrieves detailed information about a specific Metasploit module including options, targets, references, and compatibility details.

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(type:, name:, server_context:) ⇒ MCP::Tool::Response

Execute module info retrieval

Parameters:

  • type (String)

    Type of module

  • name (String)

    Name/path of module

  • server_context (Hash)

    Server context with msf_client, rate_limiter, config

Returns:

  • (MCP::Tool::Response)

    Structured response with module details



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/msf/core/mcp/tools/module_info.rb', line 97

def call(type:, name:, server_context:)
  with_tool_context(server_context, 'module_info') do |msf_client|
    # Validate inputs
    Msf::MCP::Security::InputValidator.validate_module_type!(type)
    Msf::MCP::Security::InputValidator.validate_module_name!(name)

    # Call Metasploit API
    raw_module_info, elapsed = Rex::Stopwatch.elapsed_time do
      msf_client.module_info(type, name)
    end

    # Transform response
    transformed = Metasploit::ResponseTransformer.transform_module_info(raw_module_info)

    # Build metadata
     = {
      query_time: elapsed.round(3)
    }

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