Class: Msf::MCP::Tools::ModuleInfo
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- Msf::MCP::Tools::ModuleInfo
- 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.
Class Method Summary collapse
-
.call(type:, name:, server_context:) ⇒ MCP::Tool::Response
Execute module info retrieval.
Methods included from ToolHelper
Class Method Details
.call(type:, name:, server_context:) ⇒ MCP::Tool::Response
Execute module info retrieval
94 95 96 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 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/msf/core/mcp/tools/module_info.rb', line 94 def call(type:, name:, server_context:) start_time = Time.now # Extract dependencies from server context msf_client = server_context[:msf_client] rate_limiter = server_context[:rate_limiter] # Check rate limit rate_limiter.check_rate_limit!('module_info') # Validate inputs Msf::MCP::Security::InputValidator.validate_module_type!(type) Msf::MCP::Security::InputValidator.validate_module_name!(name) # Call Metasploit API raw_module_info = msf_client.module_info(type, name) # Transform response transformed = Metasploit::ResponseTransformer.transform_module_info(raw_module_info) # Build metadata = { query_time: (Time.now - start_time).round(3) } # Return MCP response ::MCP::Tool::Response.new( [ { type: 'text', text: JSON.generate( metadata: , data: transformed ) } ], structured_content: { metadata: , data: transformed } ) rescue Msf::MCP::Security::RateLimitExceededError => e tool_error_response("Rate limit exceeded: #{e.}") rescue Msf::MCP::Metasploit::AuthenticationError => e tool_error_response("Authentication failed: #{e.}") rescue Msf::MCP::Metasploit::APIError => e tool_error_response("Metasploit API error: #{e.}") rescue Msf::MCP::Security::ValidationError => e tool_error_response(e.) end |