Nmap
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.
claude mcp add --transport stdio mohdhaji87-nmap-mcp-server uvx run server.py
How to use
This MCP server exposes a suite of Nmap-based tools accessible via FastMCP over stdio. It wraps the Nmap command-line interface into typed, decorator-registered tools that can be invoked asynchronously from a client that speaks MCP. The server supports a variety of scanning capabilities including basic scans, service and OS detection, NSE script scanning, stealth and comprehensive scans, ping and port scans, vulnerability checks, network discovery, and user-defined custom scans. Each tool takes target hosts or networks and relevant options, then returns the Nmap results in a structured or serialized form suitable for downstream processing.
To use the tools, connect to the MCP server using the FastMCP client API and call the registered tools by name (for example, nmap_basic_scan, nmap_service_detection, etc.). Pass parameters such as targets, ports, scan types, intensity levels, and any script or timing options as defined by each tool. The server handles command execution, timeouts, and error reporting, returning results or error messages that can be consumed by your application or automation workflow.
How to install
Prerequisites:
- Python 3.10 or higher
- Nmap installed and available in your system PATH
Installation steps:
-
Clone the repository: git clone <repository-url> cd nmap-mcp-server
-
Install Python dependencies in editable mode (so you can run from source): pip install -e .
-
Ensure Nmap is installed and accessible from the command line. On macOS/Linux you can typically install via package manager (e.g., brew install nmap or sudo apt install nmap). On Windows, install from nmap.org and ensure nmap.exe is in your PATH.
-
Run the server locally (examples shown in the README): python server.py OR nmap-mcp-server
-
(Optional) Configure Claude Desktop or your MCP client to connect to the server using the provided configuration snippet.
Note: If you modify dependencies or the server entrypoint, reinstall with pip install -e . to pick up changes.
Additional notes
Tips and considerations:
- Make sure Nmap is permitted to run on the target networks and that you have authorization to scan them.
- The server uses stdio transport; ensure your MCP client is configured to communicate via stdio when running the process.
- Review error handling for common issues such as Nmap not found, timeouts, or invalid arguments.
- Environment variables can be used to customize logging levels or paths if needed; add them under the env section in mcp_config.
- The included Claude Desktop configuration demonstrates how to launch the UDP/uv-based server runner; adapt the path to server.py as appropriate for your environment.
- For large or network-wide scans, consider using appropriate timing templates and rate-limiting in your client to avoid overwhelming the network or triggering protections.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP