Nmap Scanner MCP server

Provides a secure, controlled interface for network administrators and security researchers to perform targeted network reconnaissance and analysis using nmap scans with built-in rate limiting and security safeguards.
Back to servers
Provider
imjdl
Release date
Mar 26, 2025
Language
Python
Stats
4 stars

The Nmap Model Control Protocol (MCP) server provides access to nmap network scanning functionality, allowing you to run scans on specified targets, store results, and analyze them using AI prompts - all through a standardized protocol interface.

Installation Requirements

Before installing the MCP server, ensure you have:

  • Python 3.10 or higher
  • python-libnmap library
  • nmap utility installed on your system

Installing Dependencies

Install the required Python library:

pip install python-libnmap

Install nmap on your system:

# On Debian/Ubuntu
sudo apt-get install nmap

# On Fedora/CentOS
sudo dnf install nmap

Running the Server

You can run the server in two different ways:

Running Directly from Source

python -m src.nmap_mcp

Installing and Running as a Command

pip install -e .
nmap-mcp

Using the MCP Server

The Nmap MCP server provides several tools and prompts that you can use.

Available Tools

run-nmap-scan

Run an nmap scan on specified targets.

Parameters:

  • target: Target host or network (e.g., 192.168.1.1 or 192.168.1.0/24)
  • options: Nmap options (e.g., -sV -p 1-1000)

get-scan-details

Get detailed information about a specific scan.

Parameters:

  • scan_id: ID of the scan to retrieve

list-all-scans

List all available scan results.

No parameters required.

Available Prompts

analyze-scan

Analyze an nmap scan result with AI assistance.

Parameters:

  • scan_id: ID of the scan to analyze
  • focus: Focus area (security/services/overview)

Working with Resources

Scan results are available as resources with the nmap://scan/{scan_id} URI scheme.

Example Workflow

1. Running a Scan

Call tool: run-nmap-scan
Parameters: {"target": "192.168.1.0/24", "options": "-sV -p 22,80,443"}

2. Getting Scan Details

Call tool: get-scan-details
Parameters: {"scan_id": "<scan_id from previous step>"}

3. Listing All Scans

Call tool: list-all-scans

4. Analyzing Scan Results

Get prompt: analyze-scan
Parameters: {"scan_id": "<scan_id>", "focus": "security"}

Docker Usage

For easier deployment, you can run the MCP server in a Docker container:

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

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

Troubleshooting

If you encounter errors related to nmap:

  • Verify that nmap is installed and available in your PATH
  • Check the logs to see which nmap executable is being used
  • The server attempts to use the full path to nmap to avoid conflicts

Security Considerations

Be aware that this server executes nmap commands on your system. Only scan networks you own or have permission to scan, as unauthorized scanning may be illegal in some jurisdictions.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later