mirror of
https://github.com/GH05TCREW/pentestagent.git
synced 2026-07-25 02:35:23 -04:00
[PR #17] [MERGED] MCP: Add Metasploit integration, HexStrike parity, auto-start flags and SSETransport improvements #21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/GH05TCREW/pentestagent/pull/17
Author: @giveen
Created: 1/14/2026
Status: ✅ Merged
Merged: 1/14/2026
Merged by: @GH05TCREW
Base:
main← Head:hexstrike-ai-integration📝 Commits (10+)
48cd4f2WIP: prepare for hexstrike subtree9361172Squashed 'third_party/hexstrike/' content from commit 3326704734f1d3Merge commit '93611722c0501d8e1794849bdc4329911284b75a' as 'third_party/hexstrike'a3822e2docs: add HexStrike credit and note TUI fixes704b505ui: open interactive ToolsScreen on /tools; fallback to list if push fails57a0e6echore: add PowerShell installer for vendored HexStrike deps; call from setup.ps197df933mcp: add MetasploitMCP adapter, installer, and config; add LAUNCH_METASPLOIT_MCP env varabaaca1setup: add MetasploitMCP env flag and auto-install step8415d9fscripts: vendor/install MetasploitMCP during setup (setup.sh, setup.ps1)19bdff8mcp: launch MetasploitMCP in stdio transport for manager compatibility📊 Changes
31 files changed (+25455 additions, -59 deletions)
View changed files
📝
.env.example(+66 -1)📝
README.md(+11 -0)📝
pentestagent/interface/main.py(+24 -0)📝
pentestagent/interface/tui.py(+168 -48)➕
pentestagent/mcp/hexstrike_adapter.py(+244 -0)📝
pentestagent/mcp/manager.py(+306 -4)📝
pentestagent/mcp/mcp_servers.json(+27 -1)➕
pentestagent/mcp/metasploit_adapter.py(+341 -0)📝
pentestagent/mcp/transport.py(+210 -5)📝
pyproject.toml(+14 -0)➕
pyrightconfig.json(+4 -0)➕
requirements-hexstrike.txt(+3 -0)➕
scripts/add_hexstrike_subtree.sh(+32 -0)➕
scripts/add_metasploit_subtree.sh(+84 -0)➕
scripts/install_hexstrike_deps.ps1(+45 -0)➕
scripts/install_hexstrike_deps.sh(+42 -0)➕
scripts/install_metasploit_deps.sh(+40 -0)📝
scripts/setup.ps1(+100 -0)📝
scripts/setup.sh(+79 -0)➕
third_party/hexstrike/README.md(+757 -0)...and 11 more files
📄 Description
MCP: Add Metasploit integration, HexStrike parity, auto-start flags and SSETransport improvements
Summary
This PR adds a vendored Metasploit MCP integration and brings it to parity with the existing HexStrike MCP integration. It also improves the MCP transport layer (SSE) to reliably handle HTTP/SSE MCP servers that return 202/async responses.
Key changes
MetasploitAdapterthat can start/stop the vendoredMetasploitMCPserver and optionally startmsfrpcdfor local testing./toolsview.LAUNCH_HEXTRIKE/LAUNCH_HEXSTRIKE— control HexStrike vendored server auto-start behaviorLAUNCH_METASPLOIT_MCP— control Metasploit vendored server auto-start behaviorFORCE_SUBTREE_PULL— helper for scripts that add/update vendoredthird_partysubtreesSSETransport) to:/ssescripts/add_metasploit_subtree.sh,scripts/setup.sh) to vendor/update the Metasploit subtree and provide optional msfrpcd auto-start during setup.Files touched (high level)
pentestagent/mcp/metasploit_adapter.py— new adapter to manage vendored Metasploit MCP and optional msfrpcd.pentestagent/mcp/transport.py— SSETransport enhancements and robustness fixes.pentestagent/mcp/manager.py— LAUNCH env handling, auto-start wiring and connection logic (fixes applied so LAUNCH_* works as expected).pentestagent/mcp/mcp_servers.json— added/updatedmetasploit-localentry in HexStrike-style (--server http://...)..env.example— grouped MCP settings; documentsFORCE_SUBTREE_PULLand LAUNCH flags.scripts/add_metasploit_subtree.sh,scripts/setup.sh— vendoring helpers and optional msfrpcd startup.(See the full commit set on this branch for exact diffs and additional smaller edits.)
Behavior / Usage
pentestagent/mcp/mcp_servers.jsonbut not started unless configured.LAUNCH_*environment variable to a truthy value (e.g.true,1,yes):```bash
export LAUNCH_METASPLOIT_MCP=true
export LAUNCH_HEXTRIKE=true
pentestagent
```
When
LAUNCH_METASPLOIT_MCPis truthy and the manager is started, the manager will attempt to auto-start the vendored Metasploit adapter and connect to it so its tools are registered automatically.If you prefer to run the vendored MCP server manually (recommended for debugging), start it separately and then run PentestAgent/TUI. Example:
```bash
python third_party/MetasploitMCP/MetasploitMCP.py --server http://127.0.0.1:7777 \
How to test
Pull this branch and install dependencies (see
scripts/setup.sh).Manual test:
Start msfrpcd (or configure
MSF_*envs to point to an existing Metasploit RPC)Start the vendored MCP server:
```bash
python third_party/MetasploitMCP/MetasploitMCP.py --server http://127.0.0.1:7777
```
Run the manager test:
```bash
pentestagent mcp test metasploit-local
```
Expected:
+ Connected successfully!and a list of available Metasploit tools.Auto-start test:
LAUNCH_METASPLOIT_MCP=trueand runpentestagent(or the TUI). The manager should auto-start the adapter and register tools so they appear in/tools.Security / Notes
.env(never committed) to provide secrets likeMSF_PASSWORD.msfrpcdwill never invokesudo— it only starts a local msfrpcd process if credentials are present and auto-start is enabled.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.