pentestMCP
An MCP server that exposes over 20 standard penetration testing utilities, such as Nmap, SQLMap, and OWASP ZAP, as callable tools for AI agents. It enables natural language control over complex security workflows for automated and interactive penetration testing.
README
pentestMCP: AI-Powered Penetration Testing via MCP
<!-- Example badges (replace placeholders/add relevant ones) -->
<!--
-->
<!--
-->
<!--
-->
<!--
-->
pentestMCP provides a powerful bridge between Large Language Models (LLMs) and practical penetration testing tools through the Model Context Protocol (MCP). This project functions as an MCP Server, exposing a curated suite of over 20 standard security assessment utilities (Nmap, Nuclei, ZAP, SQLMap, etc.) as callable 'tools'. This allows AI agents within MCP-compatible clients (like Claude Desktop or specific VS Code setups) to leverage these utilities for automated and interactive security analysis tasks.
The goal is to enable natural language control over complex security workflows, making pentesting capabilities more accessible and integrated into AI-driven environments. This work is inspired by Laurie Kirk's GhidraMCP.
Table of Contents
- Core Concepts & Architecture
- Key Features
- Prerequisites
- Installation & Setup
- Client Host Integration
- Tool Reference
- Security Considerations
- Contributing
- License
- Disclaimer
- Acknowledgements
Video Demo
https://github.com/user-attachments/assets/930c879a-5cb4-478a-b033-f30df0e770a6
Core Concepts & Architecture
pentestMCP strictly adheres to the MCP specification, functioning solely as an MCP Server. It does not embed or directly communicate with any specific LLM. The interaction flow is mediated by an MCP Client Host application:
- Client Host Application (e.g., Claude Desktop, custom agent): Connects to pentestMCP (typically via
stdiobrokered by Docker), manages user interaction, and interfaces with a chosen LLM. - LLM: Receives user prompts and tool definitions (from pentestMCP via the Client Host). It decides which tools to invoke based on the context.
- pentestMCP Server (This Project): Runs within a Docker container. Listens for
tools/callrequests from the Client Host, executes the corresponding underlying tool (e.g.,nmap), and returns the results. - External Tools: The actual command-line utilities encapsulated within the Docker image.
The server is built using the Python MCP SDK (mcp.server.fastmcp.FastMCP) and features:
- Tool Discovery: Utilizes Python type hints and docstrings for automatic MCP tool schema generation.
- Concurrency Control: A
threading.Semaphorelimits simultaneous execution of resource-intensive scans. - Asynchronous Scan Pattern: Implements launch/fetch methods for long-running tasks (Nmap, Nuclei, SQLMap, Gobuster) to avoid blocking the MCP connection.
sequenceDiagram
participant User
participant ClientHost as Client Host (Claude, VS Code)
participant LLM
participant PentestMCP as pentestMCP Server (Docker via stdio)
participant ExtTool as External Tool (e.g., Nmap)
User->>ClientHost: "Perform Nmap service scan on scanme.nmap.org"
ClientHost->>PentestMCP: tools/list Request
PentestMCP-->>ClientHost: List of Tools (including 'run_nmap_scan')
ClientHost->>LLM: User Prompt + Available Tools Description
LLM-->>ClientHost: Decision: Use 'run_nmap_scan', target='scanme.nmap.org', args='-sV'
ClientHost->>PentestMCP: tools/call (name='run_nmap_scan', args={...})
Note over PentestMCP, ExtTool: pentestMCP executes 'nmap -sV scanme.nmap.org' internally
PentestMCP-->>ClientHost: tools/call Result (pid, output_path for async or direct output)
ClientHost->>LLM: Tool Execution Result
LLM-->>ClientHost: Formulate Final Response
ClientHost-->>User: "Nmap scan launched/completed. Results..."
Key Features
- Comprehensive Toolset: Integrates over 20 essential penetration testing tools via MCP.
- Standardized Access: Enables any MCP client supporting
stdioserver launching to utilize complex pentesting workflows. - Non-Blocking Scans: Efficiently handles long-running scans without locking up the interaction flow.
- Resource Management: Implements basic concurrency limiting for scans.
- Portable & Reproducible: Dockerized environment ensures all dependencies and tools are available consistently across platforms (Windows, macOS, Linux).
- Web Scanner Integration: Provides direct control over OWASP ZAP Active Scan and AJAX Spider functionalities.
Prerequisites
- Docker: Requires Docker Desktop (Windows/macOS) or Docker Engine (Linux) to be installed and running. Ensure the Docker daemon is active.
- Git: Needed only if building the image locally (
git clonestep). - (Optional but Recommended) OWASP ZAP Instance: For using ZAP-related tools (
run_zap_*,run_active_scan_*,run_ajax_*). This ZAP instance needs to be running and network-accessible from inside the pentestMCP Docker container (see Client Host Integration section for configuration).
Installation & Setup
The recommended way to use pentestMCP is via the pre-built Docker image.
Using Pre-built Docker Image (Recommended)
This avoids local build times and dependency issues.
- Pull the image from Docker Hub:
(This image name needs to exist on Docker Hub for this command to work)docker pull ramgameer/pentest-mcp:latest
Building Docker Image Locally
(Before Installing, NOTE THAT THIS CODE WILL BE ONLY EFFICIENT IN LINUX ONLY)
Use this option if you want to modify the code, use the absolute latest version, or the pre-built image is unavailable.
-
Clone the repository:
git clone https://github.com/ramkansal/pentestMCP.git cd pentestMCP -
Build the Docker image:
docker build -t pentest-mcp-server:custom . -
NOTE: FOR SCANS THAT REQUIRE WORDLISTS, YOU MUST CLONE THE SECLISTS REPO AS FOLLOW
git clone https://github.com/danielmiessler/SecLists.git seclists
Client Host Integration
pentestMCP runs inside Docker and communicates with the Client Host via stdio. You configure your host (e.g., Claude Desktop, VS Code) to launch the server using docker run -i ....
Claude Desktop Integration
-
Locate/Create Config File:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Edit Config: Add/update the
mcpServerssection. Use the correct image name (ramgameer/pentest-mcp:latestor your custom tag) .{ "mcpServers": { "pentestMCP": { "command": "docker", "args": [ "run", "--rm", "-i", "ramgameer/pentest-mcp:latest" ] } } } -
Restart Claude Desktop fully.
-
Verify: Look for the <img src="https://mintlify.s3.us-west-1.amazonaws.com/mcp/images/claude-desktop-mcp-hammer-icon.svg" style="display: inline; margin: 0; height: 1.3em;" /> icon. Clicking it should list the pentesting tools.
-
Interact: Ask Claude to use the tools (see examples in the draft).
VS Code Copilot Chat Integration
Integration requires configuring VS Code's settings to define the MCP server for Copilot Chat agents that support MCP.
-
Install Prerequisite: Ensure Github Copilot extension and relevant GitHub Copilot extensions are installed.
-
Configure VS Code Settings: Open your User or Workspace
settings.jsonfile (Command Palette: "Preferences: Open Settings (JSON)"). Add the MCP server configuration under the appropriate path (this path might change depending on the specific Copilot Chat agent implementation, check its documentation):"pentest-mcp": { "type": "stdio", "command": "docker", "args": [ "run", "-i", "--rm", "ramgameer/pentest-mcp:latest" ] } -
Reload VS Code / Agent: Restart VS Code or use relevant commands to reload the Copilot agent's configuration for the changes to take effect. Consult the specific Copilot agent's documentation for details.
-
Interact: Use the Copilot Chat interface, potentially invoking tools via mentions if the agent supports it, or let the agent invoke them based on your prompts.
Tool Reference
The server exposes a variety of tools categorized by function:
- Reconnaissance & Enumeration:
run_subfinder: Discovers subdomains using ProjectDiscovery's Subfinder.run_nmap_scan/fetch_nmap_results: Executes Nmap network scans and retrieves results asynchronously.run_gobuster_scan/check_gobuster_status: Performs directory/file/DNS bruteforcing with Gobuster asynchronously.run_dig_tool: Executes DNSdigqueries.fetch_whois_data: Retrieves WHOIS information for a domain.run_curl: Executes cURL commands for HTTP interaction.
- Vulnerability Scanning:
launch_nuclei_scan/fetch_nuclei_results: Runs template-based vulnerability scans with ProjectDiscovery's Nuclei asynchronously.run_wpscan: Performs WordPress vulnerability scans using WPScan.
- Web Application Scanning (ZAP):
run_zap_tool: (Potentially a general ZAP command executor - verify implementation).run_zap_active_scan/check_scan_status/active_scan_results: Manages ZAP's active scanner.run_ajax_spider/check_ajax_spider_status/get_ajax_spider_results: Manages ZAP's AJAX Spider for SPAs.
- Exploitation Support:
run_searchsploit: Searches the local Exploit-DB database using Searchsploit.run_sqlmap_tool/check_sqlmap_status: Executes SQLmap for SQL injection testing asynchronously.
Security Considerations
- Execution Permissions: Tools run as
appuserwithin Docker, but Docker itself runs with host privileges. Be cautious with tools that modify files or require elevated system access. - Target Authorization: CRITICAL: Only use these tools against systems for which you have explicit, prior, written authorization. Unauthorized scanning is illegal and unethical.
- Network Exposure: If mapping ZAP's port (
-p 8888:8888), ensure your host firewall restricts access if the machine is on an untrusted network. The configured ZAP API key provides control over the instance. - Input Validation: Although MCP provides structured input, the underlying tools might still be vulnerable to crafted arguments if not handled robustly within the Python wrapper functions.
Contributing
Contributions are highly encouraged! Fork the repository, create a feature branch, and submit a pull request. Please ensure adherence to ethical testing guidelines in all contributions. Bug reports and feature suggestions are welcome via GitHub Issues.
License
This project is distributed under the terms of the MIT License.
Disclaimer
This software is intended SOLELY for educational purposes and authorized, ethical security testing. Any use against systems without explicit permission is strictly prohibited and illegal. The authors and contributors assume NO liability for misuse or damage resulting from this program. Use at your own risk and ensure compliance with all applicable laws and agreements.
Acknowledgements
Profound inspiration for this project comes from Laurie Kirk's groundbreaking work on GhidraMCP.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
