Nmap MCP Server
Supports installation and operation on CentOS systems with specific yum/dnf package manager instructions for setting up the required Nmap dependencies.
Supports installation and operation on Debian systems with specific apt package manager instructions for setting up the required Nmap dependencies.
Supports installation and operation on macOS systems through Homebrew package manager, with specific configuration instructions for macOS environments.
Leverages Python for implementation with specific version requirements (Python 3.10+) and dependency management through pip.
Supports installation and operation on Ubuntu systems with specific apt package manager instructions for setting up the required Nmap dependencies.
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 Server scan my local network for 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 Server
A Model Context Protocol (MCP) server that exposes Nmap CLI functionality as MCP tools using FastMCP with stdio transport. This server provides comprehensive network scanning capabilities through the Nmap command-line tool.
🚀 FastMCP Implementation
This server is built using FastMCP, a modern, high-performance MCP framework that provides:
Simplified API: Clean decorator-based tool registration
Type Safety: Full type hints and validation
Stdio Transport: Efficient communication via standard input/output
Async Support: Non-blocking operations with proper error handling
Related MCP server: Nmap MCP Server
Features
The Nmap MCP Server exposes the following tools using FastMCP decorators:
1. Basic Scan (nmap_basic_scan)
Perform basic Nmap scans with different intensity levels:
Quick: Fast scan with high throughput
Comprehensive: Full scan with service detection and OS detection
Stealth: Low-profile scan to avoid detection
2. Service Detection (nmap_service_detection)
Detect services and versions running on target hosts with configurable intensity levels (0-9).
3. OS Detection (nmap_os_detection)
Detect operating systems running on target hosts with configurable retry attempts.
4. Script Scanning (nmap_script_scan)
Run NSE (Nmap Scripting Engine) scripts for advanced reconnaissance and vulnerability assessment.
5. Stealth Scan (nmap_stealth_scan)
Perform SYN scans with minimal detection using configurable timing templates.
6. Comprehensive Scan (nmap_comprehensive_scan)
Perform full-featured scans combining multiple detection methods.
7. Ping Scan (nmap_ping_scan)
Discover live hosts using various ping methods (ICMP, TCP, or both).
8. Port Scan (nmap_port_scan)
Scan specific ports using different methods (SYN, Connect, UDP).
9. Vulnerability Scan (nmap_vulnerability_scan)
Run vulnerability detection scripts with different categories.
10. Network Discovery (nmap_network_discovery)
Discover hosts and services on entire networks.
11. Custom Scan (nmap_custom_scan)
Perform scans with user-defined Nmap options for maximum flexibility.
Prerequisites
Python 3.10 or higher
Nmap installed and available in your system PATH
Installing Nmap
macOS:
brew install nmapUbuntu/Debian:
sudo apt update
sudo apt install nmapCentOS/RHEL:
sudo yum install nmap
# or for newer versions:
sudo dnf install nmapWindows: Download and install from nmap.org
Installation
Clone this repository:
git clone <repository-url>
cd nmap-mcp-serverInstall dependencies:
pip install -e .Usage
Running the FastMCP Server
The server can be run directly with stdio transport:
python server.pyOr using the installed script:
nmap-mcp-serverClaude Desktop Configuration
Add the following configuration to your Claude Desktop MCP settings:
{
"mcpServers": {
"NmapMCP": {
"command": "uv",
"args": [
"--directory",
"/Users/haji/mcp-servers/nmap-mcp-server",
"run",
"server.py"
]
}
}
}Configuration Steps:
Open Claude Desktop
Go to Settings → MCP Servers
Add the JSON configuration above
Restart Claude Desktop
Verify the server is connected
FastMCP Tool Examples
Basic Network Scan
# The tool is called with typed parameters
result = await nmap_basic_scan(
targets="192.168.1.0/24",
ports="common",
scan_type="quick"
)Service Detection
result = await nmap_service_detection(
targets="example.com",
ports="80,443,8080",
intensity=7
)Vulnerability Assessment
result = await nmap_vulnerability_scan(
targets="192.168.1.100",
ports="common",
vuln_category="all"
)Custom Scan
result = await nmap_custom_scan(
targets="example.com",
custom_options="-sS -p 1-1000 -A --script=vuln",
output_format="normal"
)FastMCP Architecture
The server uses FastMCP's clean decorator pattern:
@app.tool(
name="nmap_basic_scan",
description="Perform a basic Nmap scan of specified targets"
)
async def nmap_basic_scan(
targets: str,
ports: str = "common",
scan_type: str = "quick"
) -> str:
"""Perform a basic Nmap scan of specified targets."""
# Implementation here
return resultSecurity Considerations
⚠️ Important Security Notes:
Legal Compliance: Only scan networks and systems you own or have explicit permission to scan.
Network Impact: Some scans can be resource-intensive and may impact network performance.
Detection: Aggressive scans may trigger security systems and firewalls.
Rate Limiting: The server includes timeouts and rate limiting to prevent abuse.
Error Handling
The FastMCP server includes comprehensive error handling for:
Nmap command not found
Command timeouts
Invalid arguments
Network connectivity issues
Permission errors
Logging
The server uses Python's built-in logging system. Logs include:
Command execution details
Error messages
Performance metrics
Testing
Test the FastMCP server:
# Test tool registration and functionality
python test_fastmcp.py
# Test examples
python example_usage.pyContributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This tool is for educational and authorized security testing purposes only. Users are responsible for ensuring they have proper authorization before scanning any network or system.
Support
For issues and questions:
Check the error logs
Verify Nmap is installed and accessible
Ensure you have proper permissions
Open an issue on the repository
Changelog
Version 1.0.0
Initial release with FastMCP implementation
Support for all major Nmap scanning techniques
Comprehensive error handling
Stdio transport mode
Type-safe tool definitions
Claude Desktop configuration with uv
Available Tools
11 toolsnmap_basic_scanC
Perform a basic Nmap scan of specified targets
Inputs: targets (required), ports, scan_type. Returns: result
nmap_comprehensive_scanC
Perform comprehensive scan with all detection methods
Inputs: targets (required), ports, include_scripts. Returns: result
nmap_custom_scanC
Perform custom Nmap scan with user-defined options
Inputs: targets (required), custom_options (required), output_format. Returns: result
nmap_network_discoveryC
Discover hosts and services on a network
Inputs: network (required), discovery_method, include_ports. Returns: result
nmap_os_detectionC
Perform operating system detection scan
Inputs: targets (required), ports, max_retries. Returns: result
nmap_ping_scanC
Perform ping scan to discover live hosts
Inputs: targets (required), ping_type. Returns: result
nmap_port_scanC
Scan specific ports on target hosts
Inputs: targets (required), ports (required), scan_method. Returns: result
nmap_script_scanC
Run NSE (Nmap Scripting Engine) scripts
Inputs: targets (required), scripts, ports. Returns: result
nmap_service_detectionC
Perform service and version detection scan
Inputs: targets (required), ports, intensity. Returns: result
nmap_stealth_scanC
Perform stealth scan (SYN scan) with minimal detection
Inputs: targets (required), ports, timing. Returns: result
nmap_vulnerability_scanC
Run vulnerability detection scripts
Inputs: targets (required), ports, vuln_category. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
The tools have clear distinctions in their primary functions (e.g., ping_scan vs. os_detection), but there is significant overlap in scanning types. For instance, basic_scan, comprehensive_scan, and custom_scan could be confused as they all perform general scans, and network_discovery might overlap with ping_scan. Descriptions help differentiate, but an agent might struggle to choose between similar tools without deeper context.
All tool names follow a consistent 'nmap_' prefix with descriptive snake_case suffixes (e.g., nmap_basic_scan, nmap_os_detection). This pattern is uniform across all 11 tools, making them predictable and easy to parse. There are no deviations in naming conventions, which enhances clarity and usability.
With 11 tools, the count is reasonable for covering Nmap's diverse scanning capabilities. It's well-scoped to include various scan types (e.g., stealth, vulnerability) and detection methods. However, it might be slightly heavy as some tools could be consolidated (e.g., basic and comprehensive scans), but overall, each tool serves a distinct purpose in the domain.
The tool set provides comprehensive coverage of Nmap's core functionalities, including host discovery, port scanning, service detection, OS detection, script execution, and vulnerability scanning. There are no obvious gaps; agents can perform full network reconnaissance workflows from discovery to in-depth analysis, ensuring no dead ends in typical use cases.
Maintenance
Related MCP Connectors
Scans remote MCP servers for protocol, security, and TLS issues; exposes scan tools via MCP.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Free, read-only security scanner for remote MCP servers, before you connect them.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Control Protocol server that provides access to nmap network scanning functionality, allowing users to run customizable scans, store results, and analyze network security using AI prompts.319MIT
- FlicenseNot gradedqualityDmaintenanceEnables network scanning and security assessment using Nmap through MCP, allowing AI assistants to perform port scans, service detection, and network reconnaissance on specified targets with configurable scan parameters.-
- AlicenseNot gradedqualityDmaintenanceEnables network security scanning using Nmap through MCP protocol. Supports quick port scans, full port scans with service detection, and custom Nmap commands with async task management.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables network scanning and reconnaissance through MCP tools, leveraging nmap for port scanning, service detection, and host discovery via synchronous, asynchronous, and streaming interfaces.72 PyPI1MIT