Module: Msf::MCP::Tools::ToolHelper

Included in:
CredentialInfo, HostInfo, LootInfo, ModuleInfo, NoteInfo, SearchModules, ServiceInfo, VulnerabilityInfo
Defined in:
lib/msf/core/mcp/tools/tool_helper.rb

Overview

Shared helper methods for MCP tools.

Provides a standard way to build error responses that comply with the MCP protocol, returning a normal result with ‘isError: true` instead of raising exceptions that the MCP server would wrap as internal errors.

Instance Method Summary collapse

Instance Method Details

#tool_error_response(message) ⇒ ::MCP::Tool::Response

Build a standard MCP error response.

Parameters:

  • message (String)

    Human-readable error message

Returns:

  • (::MCP::Tool::Response)

    Response with isError flag set



19
20
21
22
23
24
# File 'lib/msf/core/mcp/tools/tool_helper.rb', line 19

def tool_error_response(message)
  ::MCP::Tool::Response.new(
    [{ type: 'text', text: message }],
    error: true
  )
end