Nmap Scoped Discovery MCP Server
Policy-gated network service enumeration server enforcing strict target CIDR allowlists and non-destructive timing.
Prerequisites & Step-by-Step Installation
Copy & run inside isolated labBefore You Start (Prerequisites)
- + Nmap >= 7.94 installed on your authorized assessment host
- + Read-only CIDR scope file (/etc/mcp/allowed-cidrs.txt)
- + MCP client (Claude Code or Codex CLI)
Install Nmap and lock down the target CIDR allowlist
sudo apt-get install -y nmap
sudo mkdir -p /etc/mcp && echo '192.168.56.0/24' | sudo tee /etc/mcp/allowed-cidrs.txt
Server rejects any scan target outside /etc/mcp/allowed-cidrs.txt.
Register Nmap MCP with arbitrary CLI argument injection disabled
claude mcp add nmap-mcp -- nmap-mcp --scope-file /etc/mcp/allowed-cidrs.txt --no-raw-args
--no-raw-args blocks --script=vuln or OS command execution flags from model prompts.
nmap --version | head -n 2 && cat /etc/mcp/allowed-cidrs.txt
Client Integration & Configuration Files
Review scope limits before wiringclaude mcp add nmap-discovery-mcp-server -- nmap-mcp --scope-file /etc/mcp/allowed-cidrs.txt --no-raw-args
{
"mcpServers": {
"nmap-discovery-mcp-server": {
"command": "nmap-mcp",
"args": [
"--scope-file",
"/etc/mcp/allowed-cidrs.txt",
"--no-raw-args"
],
"env": {
"TOOLWAR_SAFE_MODE": "strict",
"AUTH_TOKEN": "YOUR_SCOPED_TOKEN_HERE"
}
}
}
}
{
"mcpServers": {
"nmap-discovery-mcp-server": {
"command": "nmap-mcp",
"args": [
"--scope-file",
"/etc/mcp/allowed-cidrs.txt",
"--no-raw-args"
]
}
}
}
services:
nmap-discovery-mcp-server:
image: toolwar-sandbox/mcp-runner:latest
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
How to Use & Defensive Workflow
Authorized assessment protocolTypical Scenario: Run safe TCP connect/SYN service discovery across an authorized staging subnet and generate a structured open-port inventory table.
- 01. Confirm your lab subnet is listed in /etc/mcp/allowed-cidrs.txt.
- 02. Invoke the typed discover_services MCP tool with top-1000 ports only.
- 03. Review parsed XML output for unexpected management services or unencrypted protocols.
Enumerate open TCP services on 192.168.56.0/24 using safe version detection (-sV) and produce a host-by-port Markdown inventory.
Bind the MCP server exclusively inside a read-only workspace or isolated container (`read_only: true`, `--cap-drop=ALL`). Enforce strict CIDR/directory allowlists and never expose local MCP stdio or SSE ports on untrusted network interfaces without mutual authentication.
Technical Architecture & Deployment Brief
Overview & Role in Security Engineering
Nmap Scoped Discovery MCP Server (Security MCP Server) is engineered to support practitioners focused on authorized lab port inventory, service version banner parsing, and XML-to-Markdown asset reporting without arbitrary CLI flag injection. Within the ToolWar ecosystem, it serves as an explicit bridge between AI reasoning layers and verifiable cybersecurity telemetry.
Technical Architecture & Data Flow
The Model Context Protocol (MCP) separates the language model reasoning layer from privileged binary execution. Rather than letting an AI assistant invoke unconstrained shell commands, this server exposes typed, schema-validated read/inspection tools with explicit scope boundaries.
Unlike ad-hoc prompt wrappers that execute unconstrained strings directly in a shell, structured integration enforces typed parameter validation, bounded scope allowlists, and explicit separation between untrusted analyzed artifacts (source files, telemetry logs, network banners, or binary samples) and system-level control instructions.
Recommended Deployment Practice
- Isolate the Execution Boundary: Deploy integrations inside ephemeral containers or dedicated analysis VMs so untrusted repositories, binaries, or HTTP responses cannot affect primary workstations.
- Enforce Least-Privilege Scoping: Use read-only filesystem mounts, non-privileged service tokens, and target CIDR allowlists before enabling interactive assistant sessions.
- Verify Outputs Deterministically: Pair this connector with least-privilege runtime profiles and inspect every returned JSON schema before forwarding findings into automated tickets or dashboards.
Integration & Operational Caveats
- Treat all external content ingested by an LLM (including code comments, HTML titles, log lines, and MCP responses) as potential prompt-injection vectors.
- Review configuration JSON and
SKILL.mdmanifests carefully before binding credentials or running inside automated CI/CD pipelines.