Skip to main content
Glama

MCP-Kali-Server

将 Kali Linux VM 的能力通过 MCP 暴露给 Claude Code 的 API 桥。包含 Kali 侧命令执行服务端(server.py)和 MCP 网关客户端(client.py),配合 execute_command 可执行 Kali 上任意工具。

架构

Claude Code
   │  stdio (client.py)
   ▼
client.py ──HTTP──► server.py (Kali VM, 127.0.0.1:5000)
                        │  subprocess
                        ▼
                  Kali 工具 (nmap/masscan/impacket...)
  • server.py:跑在 Kali VM,Flask HTTP API,执行命令并返回结构化结果

  • client.py:MCP 网关,把工具调用转发到 Kali server

Related MCP server: Kali Linux MCP Server

工具面

12 个专用 MCP 工具nmap_scan / gobuster_scan / dirb_scan / nikto_scan / sqlmap_scan / metasploit_run / hydra_attack / john_crack / wpscan_analyze / enum4linux_scan / server_health / execute_command

通用 kali_tool(tool, params) 调度器:走 TOOL_SPECS 规格表,覆盖 57 工具——

类别

工具

侦察

masscan / netdiscover / theharvester / whatweb / wafw00f / dnsrecon / dnsenum / fierce / amass / subfinder / httpx / dig / whois / dnsx

Web/目录

ffuf / wfuzz / dirsearch / feroxbuster / nuclei / commix / joomscan / arjun

服务枚举

smbclient / smbmap / rpcclient / nbtscan / ldapsearch / snmpwalk / onesixtyone / nmblookup

利用/凭据

msfvenom / searchsploit / hashcat / responder / netexec / secretsdump / hashid / ncrack / cewl

AD/横向

psexec / wmiexec / ntlmrelayx / evil-winrm / xfreerdp / bloodhound

流量

tcpdump / tshark / ngrep / arpspoof / tcpflow

取证

binwalk / exiftool / steghide / foremost

无线

aircrack-ng / airmon-ng / reaver

后渗透

proxychains

每个工具都支持 additional_args 透传,配合 execute_command 可覆盖 Kali 全能力。

本版增强功能

  • 通用工具调度器TOOL_SPECS 规格表 + /api/tools/run,一行规格加一个工具,无需逐个写 wrapper

  • 自动 sudo:需要 root 的工具(masscan/arp-scan/tcpdump/无线类)自动加 sudo -nSUDO_TOOLS),前提是 Kali 侧已配 NOPASSWD sudo

  • 每请求超时:请求体可带 timeout 字段(秒)覆盖默认 180s;execute_command(command, timeout=) / kali_tool(..., params={"timeout": ...}) 均已支持,超时返回 timed_out:true 及部分结果

  • 参数校验:缺失必需参数/未知工具返回明确错误

使用

1. Kali 侧启动 server

python3 server.py --ip 0.0.0.0 --port 5000

2. 注册 MCP client

Claude Code 项目级 .mcp.json(将 <YOUR_KALI_IP> 替换为 Kali 实际 IP):

{
  "mcpServers": {
    "kali": {
      "type": "stdio",
      "command": "python",
      "args": ["/absolute/path/to/MCP-Kali-Server/client.py", "--server", "http://<YOUR_KALI_IP>:5000/"]
    }
  }
}

客户端通过 HTTP 直连 Kali server(NAT/桥接均可),无需 SSH 隧道;改 IP 只动 .mcp.json 一处。

3. 调用示例

# 专用工具
mcp__kali__nmap_scan(target="10.0.0.1", scan_type="-sV")

# 通用调度器
mcp__kali__kali_tool(tool="masscan", params={"target": "10.0.0.0/24", "ports": "80,443"})

# 任意命令
mcp__kali__execute_command(command="whoami", timeout=600)

部署

  • 部署到 Kali:scp server.py kali@<YOUR_KALI_IP>:/home/kali/kali-mcp-server.py(或直接 git clone 后运行)

  • 客户端在本机:pip install -r requirements.txt 后用 python client.py --server http://<YOUR_KALI_IP>:5000/ 启动

  • 含对上游 Wh0am123/MCP-Kali-Server 的针对性增强(通用调度器/超时/sudo)

免责声明

仅供授权测试、CTF、安全教育使用。VM 快照可回溯,故本适配未做安全加固(含 execute_command 任意命令)。

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides Claude Desktop with access to Kali Linux penetration testing tools via a privileged Docker container, enabling network scanning (nmap), web vulnerability scanning (nikto), and custom command execution.
    11
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Connects MCP clients to a Kali Linux terminal for AI-assisted penetration testing and CTF challenge solving by executing commands like Nmap, Metasploit, and custom scripts.
    825
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI-assisted penetration testing by connecting MCP clients to execute terminal commands on a Kali Linux machine, supporting tools like Nmap, Metasploit, and custom commands.
    MIT