home / mcp / nmap mcp server

Nmap MCP Server

This is a Model Control Protocol (MCP) server that provides access to nmap network scanning functionality.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "imjdl-nmap-mcpserver": {
      "command": "python",
      "args": [
        "-m",
        "src.nmap_mcp"
      ]
    }
  }
}

This MCP server provides access to nmap network scanning functionality, letting you run scans, store results, and analyze findings through prompts. It enables automated security assessments by integrating nmap with an MCP client workflow.

How to use

You will use an MCP client to invoke the nmap MCP server. Start by launching the server locally, then issue tools to run scans, view results, and analyze data. The server exposes three core capabilities: running an nmap scan on specified targets, retrieving details for a specific scan, and listing all saved scans. You can also prompt the server to analyze a scan with a focus such as security, services, or an overview.

How to install

Prerequisites you need before installing the server are: Python 3.10 or newer, the python-libnmap package, and nmap installed on your system.

pip install python-libnmap

# Ensure nmap is available on your system:
# On Debian/Ubuntu
sudo apt-get install nmap

# On Fedora/CentOS
sudo dnf install nmap

Running the server locally

You have two practical options to start the MCP server locally. Use whichever path matches how you prefer to run Python-based MCP servers.

# Option 1: Run the server as a module
python -m src.nmap_mcp

# Option 2: Install the package in editable mode and run the CLI
pip install -e .
nmap-mcp

Using the server to manage scans

The server offers three main commands and one prompt for building and analyzing scan data. Use them through your MCP client to perform common tasks.

Available operations include: - Run an nmap scan on targets you specify, with customizable options. - Retrieve detailed information about a particular scan by its ID. - List all saved scans to review historical results. - Analyze a scan with a focus area such as security, services, or an overview.

Docker usage

You can run the MCP server in a Docker container to isolate dependencies and simplify deployment.

# Build the Docker image
docker build -t nmap-mcp-server .

# Run the Docker container
docker run -it --rm nmap-mcp-server

Security considerations

This server executes nmap commands on your system. Exercise caution when scanning networks you do not own or have explicit permission to assess, as unauthorized scanning may be illegal in some regions.

Troubleshooting

If things don’t start or nmap isn’t found, check that nmap is installed and available in your PATH. Review logs to determine which nmap executable is being used, and ensure the server can locate it.

Available tools

run-nmap-scan

Run an nmap scan on specified targets with customizable options to discover hosts, services, and open ports.

get-scan-details

Retrieve detailed information about a specific scan by its scan_id, including parsed results and metadata.

list-all-scans

List all available scan results stored by the server for quick review and management.

analyze-scan

Analyze a selected scan with a focus area such as security, services, or overview to generate insights and prompts.