nmap-mcp
Click on "Deploy 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., "@nmap-mcp scan 192.168.1.10 for the top 100 open ports"
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.
nmap-mcp
A scoped MCP server that lets an AI assistant run nmap
scans — but only against networks you are authorized to test, using a fixed,
non-extensible set of tools instead of raw nmap flags.
⚠️ Authorization notice
Only scan networks and hosts you own or have explicit written authorization to test. Unauthorized scanning of third-party networks may violate the Computer Fraud and Abuse Act (US), the Computer Misuse Act (UK), or equivalent laws elsewhere, and may violate your ISP's or employer's acceptable-use policy. This server enforces a scope allowlist (
NMAP_ALLOWED_TARGETS) as a technical safeguard, but you are responsible for having authorization before you set it.
Related MCP server: Security MCP Server
Why this exists
An AI assistant with unrestricted nmap access is a liability: it could be
steered (by a prompt injection, a typo, or its own mistake) into scanning a
network you don't own, writing files outside the sandbox, or running an
intrusive/exploit script. This server closes those doors structurally:
The AI never supplies raw nmap flags — every tool builds its own fixed argv from validated scalar parameters.
Every target is checked against an allowlist (and an optional deny-list carve-out) before anything runs; hostnames are resolved and pinned to their IP so DNS can't move the target after the check.
Every NSE script or category is resolved against an allowlist derived from nmap's own
script.db, sodos/exploit/brute/malware/fuzzerscripts can never run, andvuln/intrusivescripts only run (invuln_scan) if you explicitly opt in.No output-file flags, no evasion flags (decoys, spoofing, fragmentation, proxies), no
-T5.The container runs as a non-root user with just the capabilities nmap needs (
cap_net_raw,cap_net_admin) — not root.
Architecture
┌─────────────────────────┐
AI assistant │ server.py │ thin MCP tool layer;
(Claude, etc.) │ (FastMCP tool defs) │ no validation/nmap logic
│ └───────────┬──────────────┘
│ stdio/MCP │ calls into
▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐
│ scope.py │ │scripts.py│ │runner.py │ │ parser.py │ │history.py│
│ allowlist│ │ NSE │ │ argv │ │ nmap XML │ │ SQLite │
│ + DNS │ │ allowlist│ │ templates│ │ -> typed │ │ history │
│ pinning │ │from │ │ + sandbox│ │ models │ │ + diff │
│ │ │script.db │ │ subprocess│ │ │ │ │
└──────────┘ └──────────┘ └────┬─────┘ └───────────┘ └──────────┘
│ asyncio.create_subprocess_exec
▼
┌──────────┐
│ nmap │
└──────────┘server.py never talks to nmap directly. runner.py is the only module
that invokes a subprocess, always via create_subprocess_exec (never a
shell), always with -oX -, always under a hard timeout.
Tools
Tool | What it does |
| Show configured scope, limits, and whether intrusive scripts are enabled |
| Ping-sweep ( |
| Scan the N most common TCP ports |
| SYN / connect / UDP scan of specific ports |
| Service/version detection |
| OS fingerprinting |
| Run allowlisted NSE scripts/categories |
| Two-phase sweep + service scan of live hosts |
| OS + ports + versions + default scripts, as a report |
| Certificate, cipher suites, clock skew |
| Title, headers, server banner, methods, robots.txt |
| Algorithm support, host key fingerprints |
| SMB protocol versions, security mode |
| RDP encryption level, NTLM info |
| Open recursion, NSID (no zone transfer/brute unless intrusive) |
| Exposed MySQL/MSSQL/MongoDB/Redis info (no brute) |
|
|
| Recent scan history |
| Full stored result for one scan |
| Diff two scans: hosts/ports/OS changes |
| Diff the two most recent scans of a target |
Configuration (environment variables)
Var | Default | Purpose |
| (empty → refuse all scans) | Comma-separated CIDRs/IPs you're authorized to scan |
| (empty) | CIDRs/IPs carved out of the allowlist |
|
| Max addresses per scan |
|
| Hard kill, seconds, per scan |
|
| Concurrent scans |
|
| Highest allowed |
|
|
|
|
| SQLite history file (mount a volume over it) |
|
| Truncate tool output beyond this |
The effective config is logged to stderr at startup.
Install (Docker; Windows 11 + WSL2 walkthrough)
0. Prerequisites — Docker (on Windows: WSL2 and Docker Desktop). Install both first:
wsl --install # installs a default Linux distro + WSL2 kernel
# reboot if prompted, then open the new Linux distro once to finish setupInstall Docker Desktop for Windows, and in Settings → General confirm "Use the WSL 2 based engine" is checked, and in Settings → Resources → WSL Integration enable integration with your distro. Verify from a Windows terminal:
wsl -l -v # your distro should show VERSION 2
docker version # should succeed, not "command not found"1. Build the image (from this project directory, in PowerShell or WSL):
docker build -t nmap-mcp .2. Create the history volume (persists history.db across container restarts):
docker volume create nmap-mcp-data3. Decide your authorized ranges. NMAP_ALLOWED_TARGETS is empty by
default, and every scan tool refuses with a clear error until you set it.
Pick the CIDR(s)/IP(s) you own or are explicitly authorized to test, e.g.
192.168.1.0/24.
4. Claude Code:
claude mcp add nmap -- docker run -i --rm --network host \
--cap-add NET_RAW --cap-add NET_ADMIN \
-v nmap-mcp-data:/data \
-e NMAP_ALLOWED_TARGETS=<your-authorized-ranges> \
nmap-mcp5. Claude Desktop — add to claude_desktop_config.json
(%APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"nmap": {
"command": "docker",
"args": [
"run", "-i", "--rm", "--network", "host",
"--cap-add", "NET_RAW", "--cap-add", "NET_ADMIN",
"-v", "nmap-mcp-data:/data",
"-e", "NMAP_ALLOWED_TARGETS=<your-authorized-ranges>",
"nmap-mcp"
]
}
}
}6. Optional: Docker MCP Toolkit gateway catalog entry. Honest answer:
use the direct method above instead. The Toolkit gateway's
custom.yaml/registry.yaml catalog format doesn't have a way to express
--cap-add NET_RAW, --cap-add NET_ADMIN, or --network host on the
container it launches — without raw-socket capabilities nmap falls back to
slow, less-accurate connect-scan-only behavior, and without host
networking on Linux you'd only see the container's own virtual network.
If you want to try it anyway, the catalog entry would look like:
# custom.yaml
registry:
nmap:
description: Scoped nmap scanning, restricted to authorized targets
title: nmap-mcp
image: nmap-mcp:latest
dateAdded: "2026-11-07T00:00:00Z"
tools:
- get_scope
- discover_hosts
- quick_scan
- port_scan
- service_scan
- os_detect
- script_scan
- network_inventory
- host_summary
- ssl_audit
- http_audit
- ssh_audit
- smb_audit
- rdp_audit
- dns_audit
- database_audit
- vuln_scan
- list_scans
- get_scan
- diff_scans
- diff_latestbut expect degraded scan capability versus the direct docker run method.
7. Networking caveat on Docker Desktop (WSL2 backend). --network host
is accepted but behaves differently than on native Linux: Docker Desktop's
WSL2 VM sits between the container and your real LAN, so:
Works well: TCP connect scans (
port_scan scan_type=connect), service/version detection, OS/protocol audits against targets you can already reach by IP.May not work or may be inaccurate: ARP-based host discovery (
discover_hostsmay need to fall back to ICMP/TCP probing), raw SYN scans and OS fingerprinting (-sS,-O) depending on Docker Desktop version and WSL2 kernel capabilities.Fallback: if LAN visibility is unreliable through Docker Desktop, run the server natively instead:
uv sync && uv run nmap-mcpdirectly inside your WSL2 distro (with realnmapinstalled there viasudo apt install nmap), which has an unvirtualized view of the network. You lose the container's non-root/capability sandboxing in exchange for full nmap fidelity — a reasonable trade for a machine you control.
Example prompts
"What's my scan scope?"
"Discover live hosts on my LAN."
"Run a quick scan on 192.168.1.10 and tell me what's open."
"Give me a host summary for my router."
"Diff the last two scans of 192.168.1.10 — what changed?"
Development
uv sync
uv run pytest -m "not live"See CLAUDE.md for the safety invariants any change must keep, DECISIONS.md for design rationale, and CONTRIBUTING.md / SECURITY.md.
Live tests (opt-in, require a real nmap binary and loopback access):
uv run pytest -m liveLicense
Available Tools
21 toolsdatabase_auditB
Check for exposed MySQL, MSSQL, MongoDB, and Redis instances on a target (no brute force).
Inputs: target (required). Returns: result
diff_latestA
Diff the two most recent scans of the same target and tool.
Inputs: target (required). Returns: result
diff_scansA
Diff two previously run scans by id: hosts up/down, port and OS changes.
Inputs: scan_id_a (required), scan_id_b (required). Returns: result
discover_hostsA
Ping-sweep a target (IP, CIDR, or hostname) to find live hosts without port scanning.
Inputs: target (required). Returns: result
dns_auditB
Check whether a target's DNS service allows open recursion and expose its NSID.
Inputs: target (required). Returns: result
get_scanA
Retrieve the full stored result for a previously run scan by its id.
Inputs: scan_id (required). Returns: result
get_scopeA
Show the configured scan scope, limits, and whether intrusive scripts are enabled.
Inputs: no named parameters. Returns: result
host_summaryC
Produce a readable report for a target: OS guess, open ports, versions, default script findings.
Inputs: target (required). Returns: result
http_auditC
Check HTTP title, headers, server banner, allowed methods, and robots.txt on a target.
Inputs: target (required), ports. Returns: result
list_scansA
List recent scans, optionally filtered by target, newest first.
Inputs: limit, target. Returns: result
network_inventoryB
Sweep a target for live hosts, then run a quick service scan on just the hosts that respond.
Inputs: target (required). Returns: result
os_detectB
Guess the target's operating system using TCP/IP stack fingerprinting.
Inputs: target (required). Returns: result
port_scanC
Scan specific TCP/UDP ports on a target; scan_type is one of syn, connect, udp.
Inputs: ports (required), target (required), scan_type. Returns: result
quick_scanB
Scan the N most common TCP ports (default 100, max 1000) on a target.
Inputs: target (required), top_ports. Returns: result
rdp_auditC
Check RDP encryption level and NTLM identity info exposed by a target.
Inputs: target (required). Returns: result
script_scanC
Run allowlisted NSE scripts or categories (comma-separated) against a target.
Inputs: target (required), scripts (required), ports. Returns: result
service_scanB
Detect service names/versions on open ports (intensity 0-9, higher is slower but more accurate).
Inputs: target (required), ports, intensity. Returns: result
smb_auditC
Check SMB protocol versions and security mode settings on a target.
Inputs: target (required). Returns: result
ssh_auditC
Check SSH algorithm support and host key fingerprints on a target.
Inputs: target (required), ports. Returns: result
ssl_auditC
Check TLS/SSL configuration (certificate, cipher suites, clock skew) on a target.
Inputs: target (required), ports. Returns: result
vuln_scanB
Run vulnerability-detection scripts: safe-tagged only, or full vuln category if NMAP_ALLOW_INTRUSIVE=1.
Inputs: target (required), ports. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
The core nmap primitives (discover_hosts, quick_scan, port_scan, service_scan, os_detect, script_scan) each target a distinct scanning stage, and the *_audit family clearly owns protocol-specific checks. Minor overlap exists: quick_scan is a port_scan subset, host_summary/network_inventory are aggregations of other tools, and diff_scans vs diff_latest differ only by argument source, but descriptions make the intended choice clear.
Everything is snake_case and follows recognizable families: verb_noun prefixes (get_scope, list_scans, get_scan, diff_scans) plus consistent suffix conventions (<thing>_scan and <protocol>_audit). There are a few noun-first outliers (os_detect, host_summary, network_inventory), but they remain readable and predictable.
21 tools sits at the upper edge of comfortable, but nmap's surface genuinely spans discovery, port/service/OS scanning, NSE scripting, vulnerability checks, seven protocol audits, and scan history. Nothing looks redundant enough to cut except possibly merging the two diff tools.
Coverage is strong end-to-end: discovery, port scanning (TCP/UDP), service/OS detection, scripted and vulnerability scanning, protocol audits, plus persistence via list_scans/get_scan and change tracking via diffs. Gaps are modest — no scan cancellation/progress polling for long runs, no traceroute or NSE script discovery, and no output export beyond stored results.
Maintenance
Related MCP Connectors
AI pentesting: run scans, triage vulnerabilities, review PRs, manage schedules and assets.
Scan websites and code for security, performance and SEO issues from your AI assistant.
Authorized security scans, evidence, fix prompts and retests for AI-built web apps.
AI smart contract security audits by Nethermind. Run scans and pull findings into your agent.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables AI assistants to perform network scanning operations using NMAP, offering a standardized interface for network analysis and security assessments through AI conversations.49MIT
- FlicenseNot gradedqualityDmaintenanceProvides AI agents like Claude with secure, controlled access to network security tools like nmap for scanning private networks and lab environments. Features comprehensive safety controls, circuit breakers, and production-ready monitoring.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform authorized security testing and penetration testing operations including SSL/TLS analysis, port scanning, vulnerability scanning, and HTTP security header audits through natural language interactions.1MIT
- FlicenseNot gradedqualityDmaintenanceProvides AI agents with standardized security scanning capabilities for authorized assessments, including host detection, port scanning, service fingerprinting, web vulnerability scanning, CVE verification, and report generation, all with unified JSON output and strict compliance controls.-