Class: Msf::MCP::Tools::SessionStop
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- Msf::MCP::Tools::SessionStop
- Extended by:
- ToolHelper
- Defined in:
- lib/msf/core/mcp/tools/session_stop.rb
Overview
MCP Tool: Stop an Active Session
Wraps the ‘session.stop` RPC endpoint to terminate a running Metasploit session.
Constant Summary
Constants included from ToolHelper
ToolHelper::DANGEROUS_MODE_DISABLED_MESSAGE
Class Method Summary collapse
-
.call(session_id:, server_context:) ⇒ MCP::Tool::Response
Stop a session.
Methods included from ToolHelper
dangerous_mode_required!, tool_error_response, with_tool_context
Class Method Details
.call(session_id:, server_context:) ⇒ MCP::Tool::Response
Stop a session
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/msf/core/mcp/tools/session_stop.rb', line 62 def call(session_id:, server_context:) with_tool_context(server_context, 'session_stop', dangerous: true) do |msf_client| Msf::MCP::Security::InputValidator.validate_session_id!(session_id) raw_result, elapsed = Rex::Stopwatch.elapsed_time do msf_client.session_stop(session_id) end data = { result: raw_result['result'] } = { query_time: elapsed.round(3) } ::MCP::Tool::Response.new( [{ type: 'text', text: JSON.generate(metadata: , data: data) }], structured_content: { metadata: , data: data } ) end end |