Runs security testing tools in a containerized Kali Linux environment, providing isolated execution of penetration testing utilities
Exposes penetration testing tools through HTTP API endpoints, enabling programmatic access to security scanning capabilities
Automates Docker image building and deployment pipeline for continuous integration of the pentesting server
Provides access to specialized penetration testing tools including nmap, nikto, sqlmap, wpscan, dirb, and searchsploit for security assessments
Kali MCP Pentest Server
A Model Context Protocol (MCP) server that provides access to essential penetration testing tools through a standardized interface. Built on Kali Linux and designed for integration with AI assistants and automation platforms.
Overview
This project packages essential security testing tools into an MCP server running in a containerized Kali Linux environment. It uses the FastMCP framework to expose security tools with proper input validation, timeout handling, and safety controls.
Available Tools
The server provides the following security testing tools via MCP:
Tool | Purpose | Parameter | Example Command |
| Network port scanning |
(hostname/IP) |
|
| Web server vulnerability scanning |
(hostname/IP) |
|
| SQL injection testing |
(URL) |
|
| WordPress security scanning |
(WordPress URL) |
|
| Directory/file enumeration |
(URL) |
|
| Directory/file brute force |
(URL) |
|
| DNS subdomain brute force |
(domain) |
|
| Virtual host brute force |
(URL) |
|
| Exploit database search |
(search term) |
|
| Username reconnaissance across social networks |
(username to search) |
|
| Web technology identification |
(URL) |
|
| Network connectivity test |
(hostname/IP) |
|
| Network path tracing |
(hostname/IP) |
|
| TCP connectivity test |
(hostname/IP) |
|
| TCP port scanning |
(hostname/IP) |
|
| TCP traceroute |
(hostname/IP) |
|
| ARP ping for Layer 2 connectivity |
(hostname/IP) |
|
| Web crawler for OSINT reconnaissance |
(URL) |
|
Architecture
Base: Kali Linux (
kalilinux/kali-rolling
) Docker containerFramework: FastMCP for MCP protocol implementation
Transport: StreamableHTTP (supports SSE and HTTP endpoints)
Security: Non-root execution with minimal required capabilities
Dependencies: Python virtual environment with required packages
Quick Start
Using Docker Compose (Recommended)
Using Docker
Using Pre-built Image
MCP Integration
Protocol Details
Server Name:
kali-mcp-pentest-server
Transport: StreamableHTTP
Host:
0.0.0.0
Port:
8080
Endpoints:
MCP Protocol:
http://localhost:8080/mcp
Server-Sent Events:
http://localhost:8080/sse
Status Check:
http://localhost:8080/
Client Configuration
For MCP clients like N8N:
Testing MCP Connection
Security Features
Input Validation
Sanitizes all user inputs to prevent command injection
Blocks dangerous characters:
;&|$
`\n\r`Validates tool names against allowed list
Runtime Security
Runs as non-root user (
kaliuser
)Uses Python virtual environment for dependency isolation
Required Linux capabilities:
NET_RAW
,NET_ADMIN
,NET_BIND_SERVICE
Tool execution timeout: 120 seconds
Tool Restrictions
Only whitelisted tools can be executed
Fixed command-line arguments prevent arbitrary command execution
Subprocess isolation with proper error handling
Development
Local Development
Dependencies
fastapi
- Web frameworkuvicorn
- ASGI serverpython-multipart
- Form data handlingmcp>=1.15.0
- Model Context Protocol implementation
Testing
The project includes a comprehensive testing suite that validates all MCP tools and security features.
Quick Testing
Using Make (Recommended)
Test Categories
The test suite includes:
Unit Tests (
tests/test_utils.py
): Test core utility functions like input sanitization and tool executionMCP Tool Tests (
tests/test_mcp_tools.py
): Test all 18 MCP tool functions with mock executionServer Integration Tests (
tests/test_mcp_server.py
): Test MCP server initialization and configurationEnd-to-End Integration Tests (
tests/test_integration.py
): Test complete workflows and error handling
Test Coverage
Maintains 97%+ code coverage with a minimum threshold of 85%
Tests all 18 security tools exposed via MCP protocol
Validates input sanitization and command injection prevention
Tests error handling for timeouts, permissions, and missing tools
Ensures tool whitelisting security controls
GitHub Actions CI/CD
Tests run automatically on:
Every push to the
main
branchEvery pull request targeting the
main
branchSupports Python 3.11 and 3.12
Includes security scanning with bandit
Generates coverage reports
Container Build Process
The Dockerfile performs these steps:
Starts with Kali Linux rolling release
Installs security tools and Python dependencies
Creates non-root user with sudo privileges
Sets up proper file ownership and capabilities
Creates Python virtual environment
Installs Python packages in isolated environment
Exposes port 8080 and runs the MCP server
CI/CD Pipeline
The GitHub Actions workflow (.github/workflows/docker-build.yml
):
Triggers: Push to
main
branch (after PR merge), weekly schedule (Sundays at 2:00 AM UTC)Build: Multi-architecture (linux/amd64, linux/arm64)
Registry: GitHub Container Registry (
ghcr.io
)Deployment: Automatic on merge to
main
or weekly schedule
Security Considerations
⚠️ Educational Use Only: This tool is intended for learning and authorized testing only.
Important Notes
Always obtain proper authorization before testing targets
Use only on systems you own or have explicit permission to test
The container requires elevated network capabilities for certain tools
Input validation helps prevent command injection but shouldn't be your only security layer
Monitor logs for suspicious activity
Capabilities Required
The container needs these Linux capabilities:
NET_RAW
: For raw socket operations (nmap, ping)NET_ADMIN
: For network administration tasksNET_BIND_SERVICE
: For binding to privileged ports if needed
License
This project is for educational purposes. Users are responsible for compliance with applicable laws and regulations.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables users to perform security testing and penetration testing tasks through a Docker-based API that provides access to popular security tools like nmap, nikto, sqlmap, wpscan, dirb, and searchsploit. Designed for educational purposes with input sanitization and non-root execution for safer pentesting workflows.