Skip to main content
Glama
Kali Linux MCP Server

Kali Linux MCP Server

by taguianas

πŸ”“ Kali Linux MCP Server

Run professional penetration testing tools through natural language using AI.

A Docker-based MCP (Model Context Protocol) server that wraps Kali Linux security tools and exposes them to AI clients like Claude Code, Cursor, and any MCP-compatible application. Simply ask "scan this target for open ports" and let AI handle the rest.

Docker MCP Kali Linux Python License: MIT


Overview

This project bridges the gap between AI assistants and real security tools. Instead of switching between terminals, remembering complex command flags, and manually parsing scan output, you simply describe what you want in plain English and the AI executes professional-grade security tools on your behalf.

Built with FastMCP 3.x and running inside a Kali Linux Docker container, the server exposes 18+ security tools as MCP endpoints that any compatible AI client can call.

Related MCP server: Kali Tools MCP Server

Demo

You: "Scan scanme.nmap.org for open ports"

Claude Code: Calls nmap_scan tool with target "scanme.nmap.org"

Result:

Port

State

Service

22/tcp

Open

SSH

53/tcp

Open

DNS

80/tcp

Open

HTTP

9929/tcp

Open

Nping Echo

31337/tcp

Open

Elite

5 open ports found on scanme.nmap.org (45.33.32.156) in 4.27 seconds

Features

18+ Security Tools wrapped as MCP endpoints, organized by category:

Network Scanning : nmap full scan, quick scan (top 100 ports), vulnerability scan with NSE scripts, OS detection

Web Application Testing : Nikto web server scanner, Dirb directory brute-forcer, WPScan for WordPress vulnerability detection and enumeration

SQL Injection : SQLMap automated detection and database dumping

Exploit Research : SearchSploit for querying the Exploit Database, with detailed exploit viewing

Reconnaissance : WHOIS lookups, DNS record queries via dig, banner grabbing with netcat, SMB enumeration with enum4linux

Password Testing : Hydra brute-force testing for SSH, FTP, HTTP and other services

Meta : Built-in tool listing with descriptions for all available tools

Architecture

+------------------+         HTTP (Streamable)         +------------------------+
|                  |  --------------------------------> |                        |
|   AI Client      |    MCP Protocol over HTTP         |   Docker Container     |
|                  |    POST /mcp                      |   (Kali Linux)         |
|  - Claude Code   |  <-------------------------------- |                        |
|  - Cursor        |         JSON-RPC 2.0              |  +------------------+  |
|  - Any MCP       |                                   |  | FastMCP Server   |  |
|    Client        |                                   |  | (Python 3.11)    |  |
|                  |                                   |  +--------+---------+  |
+------------------+                                   |           |            |
                                                       |  +--------v---------+  |
                                                       |  | Security Tools   |  |
                                                       |  |                  |  |
                                                       |  | nmap   nikto     |  |
                                                       |  | sqlmap  dirb     |  |
                                                       |  | wpscan  hydra    |  |
                                                       |  | searchsploit     |  |
                                                       |  | whois  dig  nc   |  |
                                                       |  | enum4linux       |  |
                                                       |  +------------------+  |
                                                       +------------------------+
                                                           Port 8000 (SSE/HTTP)

How it works:

  1. The AI client sends a natural language request (e.g., "scan this target")

  2. The AI interprets the request and calls the appropriate MCP tool with parameters

  3. The FastMCP server receives the JSON-RPC call and dispatches it to the corresponding Python function

  4. The Python function sanitizes input, executes the Kali Linux tool via subprocess, and captures the output

  5. Results are returned through the MCP protocol back to the AI client

  6. The AI formats and presents the results in a readable way

Project Structure

kali-mcp-server/
β”œβ”€β”€ kali_server.py              # Main MCP server with all tool definitions
β”œβ”€β”€ run_sse.py                  # SSE/HTTP transport launcher
β”œβ”€β”€ Dockerfile                  # Kali Linux container with all tools installed
β”œβ”€β”€ requirements.txt            # Python dependencies (FastMCP, MCP SDK)
β”œβ”€β”€ custom.yaml                 # Docker MCP Toolkit catalog configuration
β”œβ”€β”€ claude_desktop_config.json  # Claude Desktop configuration template
β”œβ”€β”€ .mcp.json                   # Claude Code project-level MCP config
β”œβ”€β”€ README.md                   # This file
└── LICENSE                     # MIT License

Prerequisites

Before you begin, make sure you have:

  • Docker Desktop installed and running (download here)

  • An MCP-compatible AI client such as Claude Code, Cursor, or any client supporting the MCP protocol

  • Git for cloning the repository

Installation

Step 1: Clone the repository

git clone https://github.com/taguianas/kali-mcp-server.git
cd kali-mcp-server

Step 2: Build the Docker image

docker build -t kali-mcp-server .

This pulls the official Kali Linux rolling image and installs all security tools. The build takes a few minutes on the first run.

Step 3: Run the MCP server

docker run -d \
  --name kali-mcp \
  --privileged \
  --user root \
  -p 8000:8000 \
  kali-mcp-server

The --privileged flag is required because tools like nmap need raw socket access for SYN scans, OS detection, and other low-level network operations.

Step 4: Verify the server is running

# Check the container is up
docker ps | grep kali

# Check the logs
docker logs kali-mcp

# You should see:
# INFO: Uvicorn running on http://0.0.0.0:8000

Step 5: Test the MCP endpoint

curl -s -X POST http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

You should receive a JSON response containing the server capabilities and tool list.

Connecting to AI Clients

Claude Code (CLI)

claude mcp add -s user --transport http kali-linux http://localhost:8000/mcp

Verify the connection:

claude mcp list
# Should show: kali-linux: http://localhost:8000/mcp (HTTP) - Connected

Claude Code (Desktop App)

Create a .mcp.json file in your project directory:

{
  "mcpServers": {
    "kali-linux": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Then start a new session in the Claude Code desktop app.

Cursor IDE

Add to your Cursor MCP settings (~/.cursor/mcp.json):

{
  "mcpServers": {
    "kali-linux": {
      "transport": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Any MCP Client

The server exposes a standard MCP endpoint at http://localhost:8000/mcp using the Streamable HTTP transport. Any client supporting MCP over HTTP can connect.

Usage Examples

Once connected to your AI client, just ask in natural language:

What you say

What happens

"Scan scanme.nmap.org for open ports"

Runs nmap -F -T4 scanme.nmap.org

"Run a vulnerability scan on 10.0.0.5"

Runs nmap -sV --script=vuln 10.0.0.5

"Detect the OS on 192.168.1.1"

Runs nmap -O -sV 192.168.1.1

"Scan this web server with nikto: http://target.com"

Runs nikto -h http://target.com

"Find hidden directories on http://target.com"

Runs dirb http://target.com

"Check this WordPress site for vulnerable plugins"

Runs wpscan --url http://target.com --enumerate vp

"Test http://target.com/page?id=1 for SQL injection"

Runs sqlmap -u <url> --batch

"Search for Apache 2.4 exploits"

Runs searchsploit apache 2.4

"Do a WHOIS lookup on google.com"

Runs whois google.com

"Get DNS records for example.com"

Runs dig example.com ANY

"List all available tools"

Shows the complete tool catalog

Managing the Server

# Start the server
docker start kali-mcp

# Stop the server
docker stop kali-mcp

# Restart the server
docker restart kali-mcp

# View logs
docker logs kali-mcp --tail 50

# Remove and recreate
docker rm -f kali-mcp
docker run -d --name kali-mcp --privileged --user root -p 8000:8000 kali-mcp-server

Security Considerations

Input Sanitization: All user inputs are sanitized before being passed to system commands. The sanitize_input() function strips dangerous shell metacharacters including ;, &, |, backticks, $, parentheses, braces, redirects, and newlines. This prevents command injection attacks through the MCP interface.

Parameter Validation: Each tool validates its required parameters and returns clear error messages when inputs are missing or invalid.

Authorized Use Only: This tool must only be used against systems you own or have explicit written authorization to test.

Tech Stack

Component

Technology

Base Image

Kali Linux Rolling

MCP Framework

FastMCP 3.1.x

MCP SDK

mcp 1.26.x

HTTP Server

Uvicorn

Language

Python 3.11+

Container

Docker

Transport

Streamable HTTP (MCP)

This tool is provided for educational and authorized security testing purposes only. You must only use these tools against systems that you own or have explicit written permission to test. Unauthorized access to computer systems is illegal under laws including the Computer Fraud and Abuse Act (CFAA), the EU Directive on Attacks Against Information Systems, and applicable national legislation.

The authors are not responsible for any misuse or damage caused by this software.

Contributing

Contributions are welcome! Feel free to:

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/new-tool)

  3. Add your changes

  4. Submit a Pull Request

Ideas for contributions: adding new tools (Gobuster, Masscan, Metasploit integration), adding output formatters, adding authentication for the MCP endpoint, or creating a web dashboard.

Author

Anas TAGUI

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • NetworkChuck for the Docker MCP tutorial that inspired this project

  • Anthropic for the Model Context Protocol

  • Docker for the containerization platform

  • Kali Linux for the security tools distribution

  • The open-source security community for the individual tools (nmap, nikto, sqlmap, etc.)

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables LLMs to execute common security testing tools like nmap, sqlmap, hydra, and metasploit through a secure Docker container. Provides controlled access to penetration testing utilities with configurable timeouts and tool discovery capabilities.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Integrates 7 security tools (nmap, nuclei, dirsearch, sqlmap, hydra, Acunetix, Metasploit) via MCP protocol for AI-assisted penetration testing with enterprise-grade safety features.
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes a hardened Docker container with Kali Linux security tools (nmap, sqlmap, dig, whois, etc.) as MCP tools, enabling network reconnaissance, web analysis, and vulnerability scanning through natural language commands.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to invoke 100+ pre-installed penetration testing tools (e.g., nmap, nuclei, sqlmap) inside a Dockerized Kali Linux environment via MCP, supporting single-turn execution for reconnaissance, scanning, exploitation, and security assessment.
      AGPL 3.0