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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。