Nmap MCP Server
Uses SQLite for task management and storage of scan results, tracking scanning task status and history.
Click on "Install 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 Serverquick scan of 192.168.1.1"
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
An Nmap scanning service developed based on the FastMCP framework, providing remote invocation capabilities via the Streamable HTTP protocol and supporting MCP (Model Context Protocol) client integration.
Screenshot Preview
Using Nmap MCP Server for port scanning in DeepSOC:

Related MCP server: Nmap MCP Server
Features
Quick Scan - Scans common ports (approx. 100) on the target host
Full Scan - Scans all 65,535 ports, with support for service version detection
Custom Scan - Supports arbitrary Nmap command arguments
Async Tasks - Long-running scans are automatically converted to background tasks, with results queryable via task ID
Token Authentication - Supports both URL parameter and Bearer Token authentication methods
Structured Output - Quick/Full scans return structured data in JSON format
Mechanism
┌─────────────┐ HTTP/MCP ┌─────────────────┐
│ MCP Client │ ◄───────────────► │ Nmap MCP Server │
└─────────────┘ └────────┬────────┘
│
▼
┌─────────────────┐
│ Task Manager │
│ (SQLite) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Scanner │
│ (Nmap + XML) │
└─────────────────┘Request Handling: MCP Client sends a scan request via the Streamable HTTP protocol
Task Scheduling: The server creates a task record and stores it in an SQLite database
Synchronous Waiting: Attempts to complete the scan within the configured timeout (default 30 seconds)
Async Fallback: If not completed within the timeout, the task is moved to background execution, returning a task ID for subsequent queries
Result Parsing: Nmap outputs in XML format, which the server parses and returns as structured JSON
Installation
Prerequisites
Python 3.10+
Nmap (must be installed on the system)
Installation Steps
# 克隆项目
git clone <repository-url>
cd nmap-mcp-http
# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate # Linux/macOS
# 或 venv\Scripts\activate # Windows
# 安装依赖
pip install -r requirements.txt
# 生成配置文件模板
python server.py --init
# 编辑配置文件
cp config.example.json config.json
vim config.json # 修改 token 等配置Configuration
Example config.json configuration file:
{
"host": "0.0.0.0",
"port": 3004,
"path": "/mcp",
"token": "your_secret_token_here",
"sync_timeout": 30,
"max_concurrent_tasks": 10,
"db_path": "nmap_tasks.db",
"nmap_path": "nmap"
}Parameter | Description | Default Value |
| Listening address |
|
| Listening port |
|
| MCP service path |
|
| Authentication token | Auto-generated |
| Sync wait timeout (seconds) |
|
| Max concurrent tasks |
|
| SQLite database path |
|
| Nmap executable path |
|
Docker Deployment
The project provides a Dockerfile and docker-compose.yml for direct containerized execution.
Method A: Build and run from source (docker compose)
1) Prepare runtime files
# 初始化配置文件(请修改 token)
cp config.example.json config.json
# 预创建 SQLite 文件,避免被 Docker 识别成目录
touch nmap_tasks.db2) Build and start
docker compose up -d --build3) View logs
docker compose logs -f nmap-mcp-server4) Stop service
docker compose downMethod B: Pull and run GHCR image directly (docker pull + docker run)
Suitable for scenarios where you don't want to pull the source code and just want to run the container directly.
Prepare local directory and configuration file:
mkdir -p nmap-mcp-data
cd nmap-mcp-data
cat > config.json <<'EOF'
{
"host": "0.0.0.0",
"port": 3004,
"path": "/mcp",
"token": "replace_with_your_token",
"sync_timeout": 30,
"max_concurrent_tasks": 10,
"db_path": "nmap_tasks.db",
"nmap_path": "nmap"
}
EOF
touch nmap_tasks.dbPull the image (prioritize organization repository):
docker pull ghcr.io/flagify-com/nmap-mcp-http:latest
# fallback:
# docker pull ghcr.io/wzfukui/nmap-mcp-http:latestStart the container:
docker run -d \
--name nmap-mcp-server \
-p 3004:3004 \
-v "$(pwd)/config.json:/app/config.json:ro" \
-v "$(pwd)/nmap_tasks.db:/app/nmap_tasks.db" \
--restart always \
ghcr.io/flagify-com/nmap-mcp-http:latestView logs:
docker logs -f nmap-mcp-serverStop and remove the container:
docker rm -f nmap-mcp-serverCommon Mount Error Troubleshooting
If the logs show the following error:
IsADirectoryError: [Errno 21] Is a directory: '/app/config.json'It usually means the config.json does not exist on the host, and Docker automatically created a directory with the same name and mounted it into the container.
You can execute the following command to fix it (in the host's runtime directory):
docker rm -f nmap-mcp-server
rm -rf config.json
test -d nmap_tasks.db && rm -rf nmap_tasks.db
cat > config.json <<'EOF'
{
"host": "0.0.0.0",
"port": 3004,
"path": "/mcp",
"token": "replace_with_your_token",
"sync_timeout": 30,
"max_concurrent_tasks": 10,
"db_path": "nmap_tasks.db",
"nmap_path": "nmap"
}
EOF
touch nmap_tasks.dbThen re-execute docker run ... to start the container.
GitHub Actions (Docker Publish)
The repository has added .github/workflows/docker-publish.yml, with the following trigger conditions:
push to
mainpush
v*tag (e.g.,v1.0.0)manual trigger
workflow_dispatch
The Workflow will automatically:
Log in to GHCR (
ghcr.io)Build the Docker image
Push the image to
ghcr.io/<owner>/<repo>
Example image address:
# preferred (org):
ghcr.io/flagify-com/nmap-mcp-http:latest
ghcr.io/flagify-com/nmap-mcp-http:main
ghcr.io/flagify-com/nmap-mcp-http:sha-<commit>
# fallback (personal):
ghcr.io/wzfukui/nmap-mcp-http:latest
ghcr.io/wzfukui/nmap-mcp-http:main
ghcr.io/wzfukui/nmap-mcp-http:sha-<commit>Usage
Start Service
# 使用默认配置文件 (config.json)
python server.py
# 指定配置文件
python server.py -c /path/to/config.json
# 生成配置模板
python server.py --initMCP Client Configuration
After the service starts, it will print the MCP client configuration, supporting two authentication methods:
Method 1: URL Token
{
"mcpServers": {
"nmap-scanner": {
"name": "Nmap Scanner",
"type": "streamableHttp",
"description": "Nmap 端口扫描服务",
"isActive": true,
"baseUrl": "http://127.0.0.1:3004/mcp?token=your_token"
}
}
}Method 2: Bearer Token
{
"mcpServers": {
"nmap-scanner": {
"name": "Nmap Scanner",
"type": "streamableHttp",
"description": "Nmap 端口扫描服务",
"isActive": true,
"baseUrl": "http://127.0.0.1:3004/mcp",
"headers": {
"Authorization": "Bearer your_token"
}
}
}
}Testing and Verification
The project comes with a test client program to quickly verify if the MCP Server is working properly.
# 激活虚拟环境
source venv/bin/activate
# 运行测试(需要先启动服务)
python test_client.py <your_token>
# 示例
python test_client.py your_secret_token_hereTest content includes:
URL Token authentication method
HTTP Header Bearer Token authentication method
No Token request (verify rejection)
Invalid Token request (verify rejection)
The test program will automatically call the quick scan tool and query the task status to ensure all functions are running normally.
Available Tools
List of tools provided by Nmap MCP Server:

quick_scan
Quickly scan common ports (approx. 100) on the target host.
Parameters:
target(required): Target IP, domain, or CIDR formattimeout(optional): Sync wait timeout, 5-300 seconds
Example:
{"target": "192.168.1.1"}
{"target": "example.com", "timeout": 60}full_scan
Full scan of all ports (1-65535) on the target host, including service version detection.
Parameters:
target(required): Target IP, domain, or CIDR formattimeout(optional): Sync wait timeout, 5-600 seconds
Example:
{"target": "10.0.0.1", "timeout": 300}custom_scan
Execute custom Nmap commands.
Parameters:
command(required): Nmap command arguments (excluding thenmapcommand itself)timeout(optional): Sync wait timeout, 5-600 seconds
Example:
{"command": "-sS -p 80,443,8080 192.168.1.1"}
{"command": "-sV -sC -p 22 example.com"}
{"command": "--script vuln 192.168.1.1", "timeout": 120}get_task_status
Query the status of a scan task.
Parameters:
task_id(required): Task ID (UUID format)
Return Status:
pending: Waiting to executerunning: Scanningcompleted: Scan completedfailed: Scan failed
get_task_result
Get the full results of a scan task.
Parameters:
task_id(required): Task ID (UUID format)
Return Result Example
Synchronous Completion
{
"status": "completed",
"task_id": "550e8400-e29b-41d4-a716-446655440000",
"result": {
"target": "192.168.1.1",
"scan_time": 2.5,
"hosts": [
{
"address": "192.168.1.1",
"status": "up",
"ports": [
{
"port": 22,
"protocol": "tcp",
"state": "open",
"service": "ssh",
"version": "OpenSSH 8.0"
},
{
"port": 80,
"protocol": "tcp",
"state": "open",
"service": "http",
"version": "nginx 1.18.0"
}
]
}
]
}
}Async Task
{
"status": "pending",
"task_id": "550e8400-e29b-41d4-a716-446655440000",
"message": "扫描任务已提交,请使用 get_task_status 或 get_task_result 查询结果"
}Notes
Security
Token Protection: Please be sure to change the default Token to avoid unauthorized access
Network Isolation: It is recommended to run in a trusted network environment or use with a firewall
Permission Control: This service does not restrict scan targets; please ensure it is used only for authorized security testing
Command Injection: The
custom_scantool accepts arbitrary Nmap arguments; please assess the risks
Performance
Concurrency Limit: Default maximum of 10 concurrent tasks; requests will be rejected if exceeded
Timeout Settings: Full scans take a long time; it is recommended to use the async task mode
Resource Usage: Large-scale scans (e.g., /16 subnets) will consume significant system resources
Deployment Suggestions
Containerized Deployment: Docker deployment is recommended for easy isolation and management
Log Monitoring: It is recommended to configure log collection to monitor scanning activities
Regular Cleanup: The SQLite database will continue to grow; it is recommended to clean up historical tasks regularly
Project Structure
nmap-mcp-http/
├── .github/workflows/
│ └── docker-publish.yml # GitHub Actions Docker 构建与发布
├── .dockerignore # Docker 构建忽略规则
├── Dockerfile # 容器镜像构建文件
├── server.py # MCP 服务器主程序
├── config.py # 配置管理模块
├── models.py # 数据模型定义
├── scanner.py # Nmap 扫描器封装
├── task_manager.py # 任务管理器(SQLite)
├── auth.py # Token 鉴权中间件
├── test_client.py # 测试客户端
├── config.json # 配置文件(需自行创建)
├── config.example.json # 配置文件模板
├── requirements.txt # Python 依赖
├── docker-compose.yml # 本地容器编排
├── VERSION # 版本号
├── LICENSE # MIT 开源许可证
├── README.md # 项目说明
└── images/ # 截图资源
├── deepsoc-with-nmap-mcp.png
└── nmap-mcp-available-tools.pngContribution
Issues and Pull Requests are welcome! This project is fully open source, and we look forward to community participation and contributions.
License
This project is licensed under the MIT License.
Copyright (c) 2025 Shanghai Wuzhi Intelligent Technology Co., Ltd.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables AI assistants to perform network scanning operations using NMAP, offering a standardized interface for network analysis and security assessments through AI conversations.3248MIT
- FlicenseBqualityDmaintenanceExposes Nmap network scanning capabilities through a Model Context Protocol (MCP) server, allowing users to perform various types of network scans including vulnerability assessment, service detection, and OS fingerprinting.115
- 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 gradedqualityCmaintenanceEnables network scanning and reconnaissance through MCP tools, leveraging nmap for port scanning, service detection, and host discovery via synchronous, asynchronous, and streaming interfaces.MIT
Related MCP Connectors
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Scans MCP servers for tool poisoning, prompt injection and supply chain risks.
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/flagify-com/nmap-mcp-http'
If you have feedback or need assistance with the MCP directory API, please join our Discord server