msf-mcp
A minimal MCP server that exposes Metasploit Framework tools to LLMs via msfrpcd, enabling automated penetration testing and exploitation.
README
msf-mcp
A minimal MCP (Model Context Protocol) server that exposes the Metasploit Framework to Claude Code (or any MCP-compatible client) through msfrpcd.
⚠️ Use only in environments you are authorized to test — your own lab, your own infrastructure, or an engagement you have explicit written permission for. This project is a thin wrapper around Metasploit's own documented RPC API; it doesn't add capability beyond what your installed Metasploit already has, but it does let an LLM drive it, so treat it with the same care you'd give any pentest tooling.
How it works
The project is split into two scripts, on purpose:
| Script | Runs as | Needs sudo? | Purpose |
|---|---|---|---|
setup.py |
you, manually | yes | Starts msfrpcd. If it's already running, stops it and starts a fresh instance; otherwise just starts it. |
server.py |
Claude Code | no | Connects to the already-running msfrpcd over RPC and exposes it as MCP tools. |
you --sudo--> setup.py --spawns--> msfrpcd
^
| RPC (msgpack)
|
Claude Code --stdio--> server.py -------┘
Keeping the privileged piece (setup.py) separate from the MCP server (server.py) means Claude Code never needs to run with elevated privileges, and the process an LLM is driving has no more access than a normal RPC client would.
Requirements
- Metasploit Framework installed, with
msfrpcdonPATH - Python 3.9+
pip install -r requirements.txt(installsmcpandpymetasploit3)
Installation
git clone https://github.com/IMApurbo/msf-mcp.git
cd msf-mcp
pip install -r requirements.txt
Configure
Both setup.py and server.py have a CONFIG block near the top:
RPC_HOST = "127.0.0.1"
RPC_PORT = 55553
RPC_PASSWORD = "change-me-123"
USE_SSL = True
Edit both files and make sure these four values match in each. There's no shared config file on purpose — it keeps each script standalone and easy to read.
Start msfrpcd
sudo python3 setup.py
This will:
- start
msfrpcdif it isn't running, or - stop and cleanly restart it if it already is
Logs go to /var/log/msf_setup.log and to stdout. You can also run explicit actions:
sudo python3 setup.py status
sudo python3 setup.py start
sudo python3 setup.py stop
sudo python3 setup.py restart
Register the MCP server with Claude Code
claude mcp add metasploit -- python3 /full/path/to/server.py
Using a virtualenv? Just point at that interpreter instead:
claude mcp add metasploit -- /path/to/venv/bin/python /full/path/to/server.py
Check it registered:
claude mcp list
Verifying it works
Ask Claude Code:
Use the metasploit debug_connection_check tool and tell me the result.
A healthy response looks like:
{
"configured_host": "127.0.0.1",
"configured_port": 55553,
"tcp_port_reachable": true,
"rpc_login_ok": true,
"rpc_error": null,
"log_file": "/tmp/msf_mcp_server.log"
}
tcp_port_reachable: false→msfrpcdisn't running — runsudo python3 setup.py.tcp_port_reachable: truebutrpc_login_ok: false→ something's listening on that port, but login failed — usually aRPC_PASSWORDmismatch betweensetup.pyandserver.py. Checkrpc_errorfor details.
Available tools
| Tool | Description |
|---|---|
debug_connection_check |
Reports whether the server can reach and authenticate to msfrpcd |
debug_tail_log |
Returns the last N lines of the server's own log file |
list_module_names |
List module names by type (exploit/auxiliary/post/payload/encoder/nop) |
search_modules |
Keyword search across Metasploit modules |
module_info |
Description, options, and targets for a module |
run_module |
Configure and execute an exploit/auxiliary/post module |
list_jobs / kill_job |
Manage background jobs (handlers, running scans) |
list_sessions |
List active shell/meterpreter sessions |
session_run_command |
Send a command to a session and read the output |
session_kill |
Terminate a session |
console_execute |
Run a raw msfconsole command (fallback for anything not covered above) |
console_list / console_destroy |
Manage msfconsole instances |
Debugging
server.py logs everything to /tmp/msf_mcp_server.log and to stderr — never stdout, since Claude Code uses stdout for the MCP protocol itself. If a tool call fails or behaves unexpectedly:
tail -f /tmp/msf_mcp_server.log
or ask Claude directly to call the debug_tail_log tool — no terminal access needed.
setup.py logs to /var/log/msf_setup.log.
Project structure
msf-mcp/
├── setup.py # privileged: starts/stops/restarts msfrpcd (run manually with sudo)
├── server.py # unprivileged: MCP server exposing Metasploit as tools (added to Claude Code)
├── requirements.txt
└── README.md
License
MIT
Author
IMApurbo
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.