Hercules MCP
Enables AI agents to perform professional penetration testing through a containerized Kali Linux environment, exposing industry-standard offensive security tools as structured MCP tools.
README
<p align="center"> <img src="assets/logo.svg" alt="Hercules MCP" width="220" style="margin-bottom: 20px;"/> </p>
<h1 align="center">Hercules MCP</h1>
<p align="center"> <em>Offensive Security for AI Agents — through the Model Context Protocol</em> </p>
<p align="center"> <img src="https://img.shields.io/badge/python-3.11+-3776AB?logo=python&logoColor=white" alt="Python" /> <img src="https://badge.mcpx.dev?status=on" title="MCP Enabled" /> <img src="https://img.shields.io/badge/Docker-Kali_Linux-2496ED?logo=docker&logoColor=white" alt="Docker" /> <img src="https://img.shields.io/badge/license-MIT-F57C00" alt="License" /> </p>
Hercules MCP is a Model Context Protocol server that gives AI agents the ability to perform professional penetration testing. It orchestrates a fully containerized Kali Linux environment, exposing industry-standard offensive security tools as structured MCP tools that any MCP-compatible agent can reason about and drive autonomously.
<p align="center"> <img src="assets/architecture.png" alt="Architecture" width="720" /> </p>
Why Hercules?
🐳 Sandbox-First Architecture
Every command executes inside an ephemeral Docker container based on kalilinux/kali-rolling. Your host machine is never exposed — tools, exploits, and payloads stay isolated. Containers are created per-session and destroyed on shutdown by default.
🤖 Agent-Managed Sessions: The AI agent can fully manage its own Docker sessions directly, allowing it to start, stop, and control multiple environments dynamically.
📂 Persistent Workspaces: Session files, downloaded loot, and tool outputs are automatically stored locally in the workspace/ directory at the project root. This ensures the agent maintains persistent access to scan results and artifacts between sessions while keeping the host system completely isolated.
⚡ Token-Cost Optimized
Hercules is designed for AI agents, not humans. Tool outputs are parsed and structured — raw XML, verbose banners, and redundant data are stripped before reaching the model. Only the information the agent needs is returned, saving thousands of tokens per interaction.
🔌 Works With Any MCP Client
Built on the open MCP standard. Connect it to any MCP-compatible agent or client — Claude Code, Cursor, Windsurf, Gemini CLI, or your own custom agent — with a single JSON config.
Tooling
Hercules bundles the most widely-used offensive security tools, pre-installed and ready to use. To prevent agent tool confusion and hallucination, Hercules strictly limits access only to necessary and well-structured tools:
| Category | Tools |
|---|---|
| Reconnaissance | Nmap, Amass, dnsx, Whois, dig |
| Web Scanning | Nikto, Nuclei, WhatWeb, WPScan, Wafw00f, httpx, Arjun, Gobuster |
| Exploitation | Metasploit Framework, SQLMap, SearchSploit |
| Password Cracking | John the Ripper, Hydra |
| Networking | Ncat, curl, hping3 |
| Post-Exploitation | linPEAS, winPEAS, PowerUp, GTFOBins, LOLBAS |
| CTF / Forensics | Binwalk, Steghide, ExifTool |
| System & Shell | Full Kali Linux shell access (shell_exec), background jobs |
All tools are accessed through structured MCP tool calls with typed parameters, parsed outputs, and built-in concurrency control.
Quick Start
[!IMPORTANT] Docker is required. Before running the setup script, ensure you have Docker installed locally and the Docker daemon is up and running.
Prerequisites
- Docker (Engine or Desktop)
- Python 3.11+
- uv (recommended)
1. Clone & Install
git clone https://github.com/<your-username>/hercules-mcp.git
cd hercules-mcp
uv sync
2. Build the Environment
python hercules_setup.py
This builds the hercules-kali Docker image and downloads wordlists (SecLists, rockyou.txt). One-time operation, ~10 minutes.
3. Configure
cp .env.example .env
Key settings:
| Variable | Default | Description |
|---|---|---|
MSF_PASSWORD |
hercules |
Metasploit RPC password |
SKIP_METASPLOIT |
false |
Skip Metasploit for faster startup |
ALLOWED_TARGETS |
(empty) | Restrict scanning to specific targets |
BLOCKED_TARGETS |
(empty) | Block specific targets |
See .env.example for all options.
4. Start the Server
uv run hercules
Connect to Your AI Agent
To connect Hercules to any MCP-compatible AI agent or client (such as Claude Code, Claude Desktop, Cursor, Windsurf, or your own custom agent), add the following server configuration to your client's MCP configuration file (e.g., claude_desktop_config.json or .cursor/mcp.json):
{
"mcpServers": {
"hercules": {
"command": "uv",
"args": ["run", "hercules"],
"cwd": "/absolute/path/to/hercules-mcp"
}
}
}
Design Principles
<table> <tr> <td width="50%">
🔒 Sandboxed Execution
All tools run inside Docker. The host filesystem, network stack, and processes are never touched. Containers are ephemeral and destroyed after each session.
</td> <td width="50%">
📊 Structured Output
Nmap returns parsed JSON, not 11KB of raw XML. Metasploit uses native RPC, not console scraping. Every tool returns clean, typed data the agent can reason about.
</td> </tr> <tr> <td>
⚖️ Concurrency Control
Heavy operations (aggressive scans, exploits) and light operations (DNS lookups, file reads) are separated by async semaphores. No resource starvation.
</td> <td>
🛡️ Safety Controls
Target allow/block lists, configurable resource limits, and full audit logging. Every command is logged with timestamp, tool, target, and result.
</td> </tr> <tr> <td>
🌐 Cross-Platform Compatibility
Hercules natively supports Windows, macOS, and Linux out of the box. Automatic VPN detection, LHOST recommendation, and Docker port forwarding ensure that reverse shells and network scanners work flawlessly on any operating system without manual configuration.
</td> <td>
🧹 Token Optimization
Raw output is parsed, filtered, and compressed before reaching the LLM. Useless interfaces, verbose XML, and redundant data are stripped — keeping context windows lean.
</td> </tr> </table>
Project Structure
hercules-mcp/
├── hercules/ # Python package
│ ├── main.py # FastMCP server entry point
│ ├── core/ # Docker manager, config, concurrency
│ ├── tools/ # MCP tool implementations
│ └── resources/ # Post-exploitation scripts
├── docker/ # Container entrypoint
├── Dockerfile # Kali container definition
├── hercules_setup.py # First-time setup script
├── hercules-mcp.json # MCP client manifest
├── pyproject.toml # Project metadata
└── .env.example # Configuration template
Security
⚠️ Authorized Use Only
Hercules is built for authorized penetration testing, security research, CTF competitions, and lab environments. Never use it against systems without explicit written permission.
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。