Kali MCP Server
Enables LLMs to execute Kali Linux security tools like nmap, sqlmap, and hydra in a secure, sandboxed environment. Provides both MCP and HTTP API interfaces for penetration testing and security assessment tasks.
README
Kali MCP Server
A secure, production-ready Model Context Protocol (MCP) server that exposes Kali Linux security tools for use with Large Language Models (LLMs). This server provides both MCP and HTTP API interfaces, allowing LLMs to leverage powerful security tools in a controlled, sandboxed environment.
🚀 Features
Core Functionality
- Dual Interface: Both MCP and HTTP API support
- Tool Management: Dynamic tool discovery and metadata
- Security First: Comprehensive input validation and sandboxing
- Async Support: High-performance async/await implementation
- Production Ready: Docker, monitoring, logging, and health checks
Security Features
- Input Sanitization: Prevents command injection and path traversal
- Tool Whitelisting: Only approved tools can be executed
- Sandboxed Execution: Isolated environment for tool execution
- Resource Limits: Timeout and output size restrictions
- Audit Logging: Comprehensive security event logging
Supported Tools
The server supports a curated set of Kali Linux security tools:
Network Scanning & Enumeration
nmap- Network mappergobuster- Directory/file brute-forcerdirb- Web content scannerwfuzz- Web application fuzzernikto- Web vulnerability scanner
Password Attacks
hydra- Network login crackerjohn- Password crackerhashcat- Advanced password recoverymedusa- Parallel login brute-forcerncrack- Network authentication tool
Web Application Testing
sqlmap- SQL injection toolcewl- Custom word list generator
Wireless Security
aircrack-ng- Wireless security suite
Exploitation Framework
metasploit-framework- Penetration testing platform
System & Network Utilities
enum4linux- SMB enumerationsmbclient- SMB clientrpcclient- RPC clientldapsearch- LDAP search utilitydig- DNS lookup utilitynslookup- DNS lookup utilitywhois- WHOIS lookuptraceroute- Network path tracerping- Network connectivity testnetstat- Network statisticsss- Socket statistics
📋 Prerequisites
- Docker and Docker Compose
- Python 3.8+ (for local development)
- Git
🛠️ Installation
Quick Start with Docker
-
Clone the repository
git clone https://github.com/your-org/kali-mcp-server.git cd kali-mcp-server -
Build and run with Docker Compose
docker-compose up -d -
Verify the installation
curl http://localhost:5000/health
Manual Docker Build
-
Build the Docker image
docker build -t kali-mcp-server . -
Run the container
docker run -d \ --name kali-mcp-server \ -p 5000:5000 \ -p 8000:8000 \ -e MAX_TIMEOUT=300 \ -e DEFAULT_TIMEOUT=60 \ kali-mcp-server
Local Development
-
Install dependencies
pip install -r requirements.txt -
Run the server
python server.py
🔧 Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
MAX_TIMEOUT |
300 | Maximum execution timeout (seconds) |
DEFAULT_TIMEOUT |
60 | Default execution timeout (seconds) |
MAX_OUTPUT_SIZE |
1048576 | Maximum output size (bytes) |
ENABLE_HTTP |
true | Enable HTTP API |
ENABLE_HTTPS |
false | Enable HTTPS |
SSL_CERT |
null | SSL certificate path |
SSL_KEY |
null | SSL private key path |
LOG_LEVEL |
INFO | Logging level |
ENABLE_CORS |
true | Enable CORS |
WORKING_DIRECTORY |
/tmp/kali-mcp | Working directory for tools |
ENABLE_SANDBOX |
true | Enable sandboxing |
EXTRA_TOOLS |
null | Comma-separated list of additional tools |
Configuration File
The server supports YAML configuration files. See config.yaml for all available options.
📚 API Documentation
HTTP API Endpoints
Health Check
GET /health
Returns server health status.
List Available Tools
GET /tools
Returns a list of all available tools with metadata.
Get Tool Information
GET /tools/{tool_name}
Returns detailed information about a specific tool.
Execute Tool
POST /run
Content-Type: application/json
{
"tool": "nmap",
"args": "-sS -O 192.168.1.1",
"timeout": 60,
"working_dir": "/tmp/scan"
}
Get Metrics
GET /metrics
Returns server metrics and statistics.
MCP Tools
list_tools()
Returns a list of available tools.
get_tool_info(tool: str)
Returns detailed information about a specific tool.
run_tool(tool: str, args: str = None, timeout: int = None, working_dir: str = None)
Executes a tool with the specified arguments.
🔒 Security Considerations
Input Validation
- All tool names are validated against a whitelist
- Command arguments are sanitized to prevent injection
- File paths are sanitized to prevent directory traversal
Sandboxing
- Tools execute in isolated environments
- Dangerous environment variables are removed
- Working directories are restricted
Resource Limits
- Execution timeouts prevent hanging processes
- Output size limits prevent memory exhaustion
- CPU and memory limits via Docker
Audit Logging
- All tool executions are logged
- Security events are tracked
- Failed attempts are recorded
🧪 Testing
Run Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=server --cov-report=html
# Run security tests only
pytest tests/test_security.py -v
# Run integration tests
pytest tests/test_server.py::TestIntegration -v
Test Categories
- Unit Tests: Individual function testing
- Security Tests: Security validation testing
- Integration Tests: End-to-end workflow testing
- API Tests: HTTP endpoint testing
🚀 Deployment
Production Deployment
-
Enable HTTPS
# Generate SSL certificates openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes # Update docker-compose.yml - ENABLE_HTTPS=true - SSL_CERT=/opt/certs/cert.pem - SSL_KEY=/opt/certs/key.pem -
Use Nginx reverse proxy
docker-compose --profile production up -d -
Configure monitoring
- Set up log aggregation
- Configure alerting
- Monitor resource usage
Docker Compose Profiles
- Default: Basic HTTP server
- Production: Includes Nginx reverse proxy with SSL
📊 Monitoring
Health Checks
- HTTP endpoint:
GET /health - Docker health check configured
- Metrics endpoint:
GET /metrics
Logging
- Structured JSON logging
- Log rotation configured
- Security event logging
Metrics
- Tool execution counts
- Execution times
- Error rates
- Resource usage
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
Development Setup
# Clone and setup
git clone https://github.com/your-org/kali-mcp-server.git
cd kali-mcp-server
# Install development dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run tests
pytest
# Run linting
flake8 server.py tests/
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
- Issues: GitHub Issues
- Documentation: Wiki
- Security: Security Policy
🔗 Related Projects
📈 Roadmap
- [ ] Web UI for tool management
- [ ] Plugin system for custom tools
- [ ] Advanced monitoring dashboard
- [ ] Multi-tenant support
- [ ] Tool execution scheduling
- [ ] Result caching
- [ ] Integration with popular LLM frameworks
🙏 Acknowledgments
- Kali Linux team for the excellent security tools
- FastMCP team for the MCP framework
- The open-source community for inspiration and contributions
⚠️ Security Warning: This server provides access to powerful security tools. Use responsibly and ensure proper access controls are in place. Never expose this server to untrusted networks without proper authentication and authorization.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。