Kali Linux MCP Server

Kali Linux MCP Server

Provides secure access to Kali Linux security tools through a dockerized environment for authorized penetration testing and defensive security. Enables network scanning, web application testing, system enumeration, and credential testing with built-in input sanitization and network restrictions.

Category
访问服务器

README

Kali Linux MCP Server (Dockerized)

A dockerized Model Context Protocol (MCP) server that provides secure access to Kali Linux security tools for defensive security and authorized penetration testing.

Features

Network Scanning

  • nmap_scan: Network discovery and port scanning
  • gobuster_dir: Directory and file enumeration

Web Application Testing

  • wpscan_scan: WordPress security scanning
  • sqlmap_test: SQL injection testing
  • dirb_scan: Web content discovery

System Enumeration

  • enum4linux_scan: SMB/NetBIOS enumeration
  • searchsploit_query: Exploit database search

Credential Testing

  • crackmapexec_smb: SMB credential testing
  • john_crack: Password cracking with John the Ripper
  • hashcat_crack: GPU-accelerated password cracking

Utilities

  • netcat_connect: Network connectivity testing
  • bloodhound_py: Active Directory enumeration

Security Features

  • Input Sanitization: All inputs are validated against strict patterns
  • Network Restrictions: Configurable allowed target networks
  • Non-root Execution: Runs with minimal privileges using Linux capabilities
  • Timeout Protection: Commands have configurable execution limits
  • Output Limiting: Response sizes are capped for safety

Docker Installation & Usage

Prerequisites

  • Docker and Docker Compose installed
  • Sufficient disk space for Kali Linux image

Quick Start

# Build and start the container (MCP server starts automatically)
docker compose up --build

# Or run in background
docker compose up -d --build

# The MCP server runs inside the container with STDIO transport
# Integration with Claude Desktop uses a wrapper script

Container Usage

# View server logs
docker compose logs -f kali-mcp-container

# Access the running container (for debugging/development)
docker compose exec kali-mcp-container bash

# The MCP server is already running automatically
# Check server status inside container:
# ps aux | grep python

Container Management

# Stop the container and MCP server
docker compose down

# View real-time server logs
docker compose logs -f kali-mcp-container

# Restart the container
docker compose restart

# Rebuild container (after code changes)
docker compose build --no-cache

# For development: override auto-start to get shell access
# Temporarily modify docker-compose.yml: command: /bin/bash

Claude Desktop Integration (Automatic)

# The MCP server uses STDIO transport for Claude Desktop
# Integration happens via the wrapper script

# Container starts automatically when you run:
docker compose up -d --build

# Check if container is running:
docker compose ps | grep kali-mcp-container

Configuration

Environment Variables

  • MCP_HOST: Server host (default: 127.0.0.1)
  • MCP_PORT: Server port (default: 8000)
  • MCP_MAX_EXEC_TIME: Command timeout in seconds (default: 300)
  • MCP_OUTPUT_LIMIT: Maximum output size in bytes (default: 10000)
  • MCP_ALLOWED_NETWORKS: Comma-separated list of allowed target networks
  • WPSCAN_API_TOKEN: Optional WPScan API token for vulnerability data

Network Restrictions

For production use, configure MCP_ALLOWED_NETWORKS to restrict scanning targets:

# Example: Only allow internal networks
MCP_ALLOWED_NETWORKS=192.168.0.0/16,10.0.0.0/8,172.16.0.0/12

Usage Examples (Inside Container)

Automatic Server Startup

# The MCP server starts automatically when you run:
docker compose up --build

# Server is available at localhost:8000
# No manual startup required!

# To verify server is running:
docker compose logs kali-mcp-container

Testing Tools Directly (Optional)

# Access container for direct tool testing
docker compose exec kali-mcp-container bash

# Inside container:
nmap --version
gobuster version
wpscan --version
ls /usr/share/wordlists/

MCP Tool Usage (via Claude Desktop)

Once connected to Claude Desktop, you can use tools like:

# Network scanning
nmap_scan("192.168.1.1", scan_type="basic")

# Directory enumeration
gobuster_dir("http://example.com")

# WordPress scanning
wpscan_scan("http://wordpress.example.com")

# SQL injection testing
sqlmap_test("http://example.com/page?id=1")

Claude Desktop Integration

Configuration Steps

  1. Start the containerized MCP server:

    docker compose up -d --build
    
  2. The integration uses a wrapper script (kali_mcp_wrapper.py) that connects Claude Desktop to the containerized server via STDIO transport.

  3. Configure Claude Desktop:

    {
      "mcpServers": {
        "kali-security": {
          "command": "python3",
          "args": ["/home/pellax/Documents/myfirstclaudecode/kali_mcp_wrapper.py"]
        }
      }
    }
    
  4. Restart Claude Desktop to load the configuration.

Container Features

  • Automatic startup: MCP server starts when container boots
  • Data persistence: ./data directory mounted from host
  • Real-time logs: docker compose logs -f kali-mcp-container
  • Environment configuration: All variables in docker-compose.yml
  • Port mapping: localhost:8000 automatically mapped

Security Considerations

Authorized Use Only

This tool is designed for:

  • Authorized penetration testing
  • Security assessments
  • Educational purposes
  • Defensive security research

Network Security

  • Configure network restrictions in production
  • Use firewall rules to limit access
  • Monitor tool usage and logs
  • Implement proper authentication

User Permissions

  • Run as dedicated service user (not root)
  • Use Linux capabilities for network tools
  • Restrict file system access
  • Enable audit logging

Requirements

Host System

  • Docker and Docker Compose
  • 4GB+ free disk space for Kali image
  • Network access for tool downloads

Container Environment

  • Kali Linux rolling base image
  • Python 3.8+ (included)
  • All Kali security tools (pre-installed)
  • Virtual environment with Python dependencies

Python Dependencies (Auto-installed in container)

  • fastmcp >= 0.4.0
  • pydantic >= 2.0.0
  • Built-in Python modules (asyncio, subprocess, etc.)

Development

Project Structure

myfirstclaudecode/
├── kali_mcp_server/
│   ├── __init__.py
│   └── server.py              # Main server implementation
├── kali_mcp_wrapper.py        # Claude Desktop integration wrapper
├── Dockerfile                 # Container definition
├── docker-compose.yml         # Container orchestration
├── start_server.sh           # Container startup script
├── .dockerignore             # Docker build exclusions
├── claude_desktop_config.md  # Claude Desktop setup guide
├── demo_server.py           # Demo/testing server
├── requirements.txt        # Python dependencies
├── pyproject.toml         # Package configuration
├── data/                  # Persistent data directory
└── README.md             # This file

Wrapper Script Integration

The kali_mcp_wrapper.py script enables Claude Desktop integration by:

  • Connecting to the running Docker container via docker exec
  • Providing STDIO transport bridge between Claude Desktop and the containerized MCP server
  • Automatically handling container communication and error reporting

Adding New Tools

  1. Add tool function with @mcp.tool() decorator
  2. Implement input sanitization
  3. Use run_tool() helper for execution
  4. Add proper error handling
  5. Update documentation

License

MIT License - See LICENSE file for details

Disclaimer

This software is provided for educational and authorized testing purposes only. Users are responsible for complying with applicable laws and regulations. The authors are not responsible for misuse of this tool.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选