Skip to main content

mcp-server-nmap

MCP server that exposes the python-nmap library as MCP tools for network scanning operations.

PyPI Python

What is this?

This MCP server wraps the python-nmap library, allowing AI assistants to perform network reconnaissance through MCP tools. It provides three scanning interfaces:

  1. PortScanner (synchronous) - Blocking scans that wait for completion
  2. PortScannerAsync (asynchronous) - Non-blocking scans with callbacks
  3. PortScannerYield (generator) - Streaming results as hosts are discovered

Prerequisites

  • nmap must be installed on the system
  • Python 3.10+

Install

pip install mcp-server-nmap

mcp-name: io.github.daedalus/mcp-server-nmap

MCP Server Registration

Add this to your MCP settings file:

{
  "mcpServers": {
    "mcp-server-nmap": {
      "command": "mcp-server-nmap"
    }
  }
}

Or with custom nmap path:

{
  "mcpServers": {
    "mcp-server-nmap": {
      "command": "mcp-server-nmap",
      "env": {
        "PATH": "/custom/path:$PATH"
      }
    }
  }
}

Available Tools

Initialization

Tool Description
port_scanner_init Initialize synchronous PortScanner
port_scanner_async_init Initialize async PortScannerAsync
port_scanner_yield_init Initialize generator-based PortScannerYield

Scanning

Tool Description
port_scanner_scan Scan hosts with nmap (synchronous)
port_scanner_async_scan Scan hosts (async, non-blocking)
port_scanner_yield_scan Scan with streaming results
port_scanner_listscan List hosts without scanning

Results & State

Tool Description
port_scanner_all_hosts Get all scanned hosts
port_scanner_has_host Check if host was scanned
port_scanner_get_item Get detailed host scan data
port_scanner_scaninfo Get scan configuration info
port_scanner_scanstats Get scan statistics
port_scanner_command_line Get nmap command used
port_scanner_csv Get CSV output
port_scanner_last_output Get raw nmap text output

Async Control

Tool Description
port_scanner_async_still_scanning Check if scan in progress
port_scanner_async_stop Stop running scan
port_scanner_async_wait Wait for scan to complete

XML Parsing

Tool Description
port_scanner_analyse_xml Parse existing nmap XML output

Common Scan Workflows

Basic port scan

# Initialize scanner
port_scanner_init()

# Scan target
port_scanner_scan(hosts="192.168.1.1", ports="22,80,443", arguments="-sV")

# Get results
port_scanner_get_item(host="192.168.1.1")

Service version detection

port_scanner_scan(hosts="scanme.nmap.org", arguments="-sV -sC")

Scan multiple hosts

port_scanner_scan(hosts="192.168.1.1-254", arguments="-sS -p 22")
port_scanner_all_hosts()

Network sweep

port_scanner_scan(hosts="192.168.1.0/24", arguments="-sn")
port_scanner_csv()  # Export to CSV

nmap Arguments Reference

Argument Description
-sn Ping scan (host discovery)
-sS TCP SYN scan
-sT TCP connect scan
-sU UDP scan
-sV Service version detection
-sC Default scripts
-O OS detection
-p Port range
-oA Output all formats

Development

git clone https://github.com/daedalus/mcp-server-nmap.git
cd mcp-server-nmap
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_nmap-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_nmap-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_nmap-0.1.1.tar.gz.

File metadata

  • Download URL: mcp_server_nmap-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_server_nmap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 277036592d3dff0ba1cbe5ec6004a85287ab9bc797cdab1cf1848a89decedcf6
MD5 8a410e107935ae6250cd9774c3b66ffe
BLAKE2b-256 cbdb07828a57ebe2c2a14d059b9f4f0e03720f054dd0ee814d38f95891a4d72f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_nmap-0.1.1.tar.gz:

Publisher: pypi-publish.yml on daedalus/mcp-server-nmap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_nmap-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_nmap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb0ac2f6c3fa39b546fa8c835eb05574477187612c7a40c9da1e87cd8ec021ad
MD5 ff0d36475039577dc4f37d5208d24686
BLAKE2b-256 a7dd1f350695e089717b4664ad2488f6f0aa578f7d2e27d7ca7275a412826028

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_nmap-0.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/mcp-server-nmap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page