mirror of
https://github.com/GH05TCREW/MetasploitMCP.git
synced 2026-07-19 21:43:37 -04:00
parse args before running
Otherwise for `--help` to work, need to have a server already running
This commit is contained in:
+7
-7
@@ -1704,13 +1704,6 @@ def find_available_port(start_port, host='127.0.0.1', max_attempts=10):
|
||||
return start_port
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Initialize MSF Client - Critical for server function
|
||||
try:
|
||||
initialize_msf_client()
|
||||
except (ValueError, ConnectionError, RuntimeError) as e:
|
||||
logger.critical(f"CRITICAL: Failed to initialize Metasploit client on startup: {e}. Server cannot function.")
|
||||
sys.exit(1) # Exit if MSF connection fails at start
|
||||
|
||||
# --- Setup argument parser for transport mode and server configuration ---
|
||||
import argparse
|
||||
|
||||
@@ -1727,6 +1720,13 @@ if __name__ == "__main__":
|
||||
parser.add_argument('--find-port', action='store_true', help='Force finding an available port starting from --port or 8085')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Initialize MSF Client - Critical for server function
|
||||
try:
|
||||
initialize_msf_client()
|
||||
except (ValueError, ConnectionError, RuntimeError) as e:
|
||||
logger.critical(f"CRITICAL: Failed to initialize Metasploit client on startup: {e}. Server cannot function.")
|
||||
sys.exit(1) # Exit if MSF connection fails at start
|
||||
|
||||
if args.transport == 'stdio':
|
||||
logger.info("Starting MCP server in STDIO transport mode.")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user