loading…
Search for a command to run...
loading…
This is a Linux OS hardening tool. Take a fresh install and immediately harden the heck out of it using just your favourite LLM agent and natural language promp
This is a Linux OS hardening tool. Take a fresh install and immediately harden the heck out of it using just your favourite LLM agent and natural language prompts. "Make my system secure" or "Do a full security audit of my system."
Smithery npm version License: MIT Sponsor on GitHub Support on Ko-fi
31 defensive security tools. 250+ actions. One MCP server.
A Model Context Protocol (MCP) server that gives AI assistants access to 31 defensive security tools (with 250+ actions) on Linux. Connect it to Claude Desktop, Cursor, Smithery, or any MCP-compatible client to harden systems, manage firewalls, scan for vulnerabilities, and enforce compliance — all through natural language conversation.
It's an all-in-one easy to use MCP server that will help you secure your Linux OS and harden it to external attackers. It's not perfect by any stretch but if you need something that'll take the pain out of hardening a fresh OS install then give it a try. It's as simple as saying "give me a full security audit using the Defense MCP Server" to your favourite LLM agent.
I started experimenting with Kali and I had a weird thought that if someone ever gained control of that system they could do some damage in my network. I found it came with all sorts of interesting defensive tools besides the obvious offensive ones and so I started messing around with automating the hardening process. Eventually I left Kali to the hackers and just switched to a Debian 13 vanilla type setup on my daily driver. All those hacker tools just made me nervous! However I have spent an incredible amount of time learning about system security on Linux building this thing and I think its ready to see the light of day for others to use.
Please don't hesitate to leave feedback or if you think there's a good tool I should include.
So my stack for this that I've tested is VS Codium on Kali and Debian 13 using Roo Code and Claude Code using Anthropic Models. I gotta say I'm pretty happy with how well it does. I've really tried to get it to be a simple all-in-one hardening tool that'll at least plug the major gaps in anyones system. If you're using API's then its really gonna chug down some tokens so be warned. It did go through a few rounds of token efficiency optimisation but it'll eat em up like their Girl Guides Thin Mint cookies.
npm install -g defense-mcp-server
Or via Smithery:
npx -y @smithery/cli install @bottobot/defense-mcp-server --client claude
This server exposes Linux security tools as MCP tools that an AI assistant can invoke on your behalf. Instead of memorizing command syntax for dozens of security utilities, you describe what you want in plain English and the assistant calls the right tool with the right parameters. Sounds pretty good right?
Here are the tools:
| Module | What It Does |
|---|---|
| Firewall | Manage iptables, nftables, and UFW rules |
| Hardening | Apply sysctl settings, file permissions, kernel security, USB device control |
| Compliance | Run CIS benchmarks, HIPAA/SOC2/ISO27001 checks |
| Patch Management | Check for updates, apply patches, track CVEs |
| Access Control | Configure SSH, PAM, user account policies |
| Malware | Scan with ClamAV, manage quarantine, deploy YARA rules |
| File Integrity | AIDE, rootkit detection, file hashing, drift baselines |
| Logging | Set up auditd rules, log rotation, fail2ban |
| Encryption | Manage TLS certificates, LUKS volumes, GPG keys |
| Certificate Lifecycle | Inventory certs, check renewal, audit CA trust store, OCSP, CT logs |
| Backup | Create and restore system state snapshots |
| Container Security | AppArmor profiles, seccomp policies, image scanning |
| Network Defense | Packet capture, connection monitoring, port scanning |
| Network Segmentation | Map zones, verify isolation, test paths, audit VLANs |
| Secrets | Scan for leaked credentials, audit SSH keys |
| Incident Response | Collect volatile evidence, IOC scan, filesystem timeline |
| Forensics | Memory dumps, disk imaging, evidence chain of custody |
| eBPF Security | Deploy Falco rules, list eBPF programs |
| Supply Chain | SBOM generation, package integrity verification |
| Zero Trust Network | WireGuard tunnels, mTLS, microsegmentation |
| App Hardening | Harden Apache, Nginx, MySQL, PostgreSQL, Docker |
| Sudo Management | Manage sudo elevation, session tracking |
| Meta/Workflow | Security posture assessment, defense workflows, auto-remediation |
| DNS Security | DNSSEC validation, tunneling detection, domain blocklists, query log analysis |
| Vulnerability Management | nmap/nikto scanning, vulnerability lifecycle tracking, risk prioritization |
| Process Security | Capability auditing, namespace isolation, anomaly detection |
| WAF Management | ModSecurity audit/rules, OWASP CRS deployment, rate limiting |
| Threat Intelligence | IP/hash/domain checks against feeds, blocklist application |
| Cloud Security | AWS/GCP/Azure detection, IMDS security, IAM credential scanning |
| API Security | Local API discovery, auth auditing, rate-limit testing, CORS checking |
| Deception/Honeypots | Canary token deployment, honeyport listeners, trigger monitoring |
| Wireless Security | Bluetooth/WiFi auditing, rogue AP detection, interface disabling |
Every tool runs with safety guardrails — you won't blow up your box:
You don't need to pre-install every security tool. The server automatically detects missing dependencies and installs them when needed.
How it works:
firewall_iptables needs iptables or ufw)apt on Kali/Debian, dnf on RHEL, pacman on Arch)Example: If you ask the assistant to scan for malware but ClamAV isn't installed, the server will run apt install clamav automatically, then proceed with the scan.
Security controls on auto-installation:
yara-python, cdxgen) — arbitrary packages cannot be installedTo disable auto-installation entirely, run with:
DEFENSE_MCP_AUTO_INSTALL=false node build/index.js
Most tools will be auto-installed on first use, but you can pre-install everything for faster startup:
sudo apt-get install -y \
aide rkhunter chkrootkit clamav clamav-daemon lynis auditd \
nmap tcpdump nftables fail2ban apparmor apparmor-utils \
libpam-pwquality suricata bpftool gitleaks cosign checksec \
wireguard-tools debsums acct uidmap inotify-tools sysstat \
htop strace logrotate openssl gnupg cryptsetup curl lsof
These are not available in standard Debian/Ubuntu repos. The instructions below avoid piping remote scripts into a shell (curl | sh) — each binary is downloaded, verified, and installed as a discrete step.
Note: The MCP server can auto-install these tools for you when
DEFENSE_MCP_AUTO_INSTALL=true(the default). It uses GPG fingerprint and SHA256 verification internally. The manual steps below are for pre-installation or air-gapped environments.
# Import GPG key and verify fingerprint
curl -fsSL https://falco.org/repo/falcosecurity-packages.asc -o /tmp/falco.asc
gpg --show-keys /tmp/falco.asc # Verify: 478B 2FBB C75F 4237 B731 DA43 6510 6822 B35B 1B1F
sudo gpg --dearmor -o /usr/share/keyrings/falco-archive-keyring.gpg /tmp/falco.asc
rm /tmp/falco.asc
# Add signed repo and install
echo "deb [signed-by=/usr/share/keyrings/falco-archive-keyring.gpg] https://download.falco.org/packages/deb stable main" \
| sudo tee /etc/apt/sources.list.d/falcosecurity.list
sudo apt-get update && sudo apt-get install -y falco
# Import GPG key and verify fingerprint
curl -fsSL https://aquasecurity.github.io/trivy-repo/deb/public.key -o /tmp/trivy.asc
gpg --show-keys /tmp/trivy.asc # Verify: 2E2D 3567 4616 32C8 4BB6 CD6F E9D0 A361 6276 FA6C
sudo gpg --dearmor -o /usr/share/keyrings/trivy-archive-keyring.gpg /tmp/trivy.asc
rm /tmp/trivy.asc
# Add signed repo and install
echo "deb [signed-by=/usr/share/keyrings/trivy-archive-keyring.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" \
| sudo tee /etc/apt/sources.list.d/trivy.list
sudo apt-get update && sudo apt-get install -y trivy
VERSION=v0.110.0
curl -fsSL -o /tmp/grype.tar.gz \
"https://github.com/anchore/grype/releases/download/${VERSION}/grype_${VERSION#v}_linux_amd64.tar.gz"
curl -fsSL -o /tmp/grype.tar.gz.sha256 \
"https://github.com/anchore/grype/releases/download/${VERSION}/grype_${VERSION#v}_checksums.txt"
# Verify checksum
cd /tmp && grep "linux_amd64.tar.gz" grype.tar.gz.sha256 | sha256sum -c -
tar xzf grype.tar.gz grype && sudo install grype /usr/local/bin/grype
rm -f /tmp/grype /tmp/grype.tar.gz /tmp/grype.tar.gz.sha256
VERSION=v1.42.3
curl -fsSL -o /tmp/syft.tar.gz \
"https://github.com/anchore/syft/releases/download/${VERSION}/syft_${VERSION#v}_linux_amd64.tar.gz"
curl -fsSL -o /tmp/syft_checksums.txt \
"https://github.com/anchore/syft/releases/download/${VERSION}/syft_${VERSION#v}_checksums.txt"
# Verify checksum
cd /tmp && grep "linux_amd64.tar.gz" syft_checksums.txt | sha256sum -c -
tar xzf syft.tar.gz syft && sudo install syft /usr/local/bin/syft
rm -f /tmp/syft /tmp/syft.tar.gz /tmp/syft_checksums.txt
VERSION=v3.94.1
curl -fsSL -o /tmp/trufflehog.tar.gz \
"https://github.com/trufflesecurity/trufflehog/releases/download/${VERSION}/trufflehog_${VERSION#v}_linux_amd64.tar.gz"
curl -fsSL -o /tmp/trufflehog_checksums.txt \
"https://github.com/trufflesecurity/trufflehog/releases/download/${VERSION}/trufflehog_${VERSION#v}_checksums.txt"
# Verify checksum
cd /tmp && grep "linux_amd64.tar.gz" trufflehog_checksums.txt | sha256sum -c -
tar xzf trufflehog.tar.gz trufflehog && sudo install trufflehog /usr/local/bin/trufflehog
rm -f /tmp/trufflehog /tmp/trufflehog.tar.gz /tmp/trufflehog_checksums.txt
VERSION=v2.7.1
curl -fsSL -o /tmp/slsa-verifier \
"https://github.com/slsa-framework/slsa-verifier/releases/download/${VERSION}/slsa-verifier-linux-amd64"
curl -fsSL -o /tmp/slsa-verifier.sha256 \
"https://github.com/slsa-framework/slsa-verifier/releases/download/${VERSION}/slsa-verifier-linux-amd64.sha256"
# Verify checksum
cd /tmp && echo "$(cat slsa-verifier.sha256) slsa-verifier" | sha256sum -c -
sudo install slsa-verifier /usr/local/bin/slsa-verifier
rm -f /tmp/slsa-verifier /tmp/slsa-verifier.sha256
npm install -g @cyclonedx/cdxgen
snort → suricata: Snort has been removed from Debian Trixie (13+) repositories. Suricata is the recommended IDS replacement and is available in standard repos.ufw vs nftables: UFW conflicts with iptables-persistent — they cannot coexist on the same system. For modern Debian systems, prefer nftables (the nft command) for firewall management.bpftool: On Debian Trixie, install the bpftool package directly (NOT linux-tools-generic which is Ubuntu-specific).pam_pwquality: This is a PAM module (libpam-pwquality), not a standalone binary. Install via apt-get install libpam-pwquality.Pick one method:
npm (recommended):
npm install -g defense-mcp-server
Or clone and build from source:
git clone https://github.com/bottobot/defense-mcp-server.git
cd defense-mcp-server
npm install && npm run build
The server supports any MCP client. Pick your client below and add the configuration:
Claude Code (CLI / VS Code / JetBrains):
Create a .mcp.json file in your project root (or ~/.claude/ for global):
{
"mcpServers": {
"defense-mcp-server": {
"command": "defense-mcp-server",
"env": {
"DEFENSE_MCP_DRY_RUN": "true",
"DEFENSE_MCP_ALLOWED_DIRS": "/tmp,/home,/var/log"
}
}
}
}
Claude Desktop:
Edit ~/.config/claude/claude_desktop_config.json (Linux) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"defense-mcp-server": {
"command": "defense-mcp-server"
}
}
}
Restart Claude Desktop. The server will appear in the MCP tools panel.
Cursor / Other MCP clients:
{
"mcpServers": {
"defense-mcp-server": {
"command": "defense-mcp-server"
}
}
}
If you cloned and built from source, replace "defense-mcp-server" in the command field with:
"command": "node",
"args": ["/path/to/defense-mcp-server/build/index.js"]
Open your AI client and ask:
"Check my firewall status"
The assistant should call the firewall tool and return your iptables/UFW rules. If it does, you're all set.
Most audit tools (listing firewall rules, checking patches, reading logs) work without sudo. When a tool needs elevated privileges, the server will tell you. Elevate securely:
"Elevate sudo with GUI dialog"
This opens a native password dialog (zenity/kdialog) — your password never passes through the AI conversation. The session auto-expires after 15 minutes, or you can drop it anytime:
"Drop sudo privileges"
/tmp, /home, and /var/log are accessible by defaultTo enable live changes (not just previews), set DEFENSE_MCP_DRY_RUN=false in the env config above.
Once connected, talk to your AI assistant naturally:
firewall_iptables with action: listaccess_ssh with harden action and appropriate settingscompliance_check with CIS frameworkmalware_clamav on the specified pathpatch_update_auditbackup with state actionlog_fail2ban to configure jailcloud_security with check_iam_credswireless_security with rogue_ap_detectreport_export with generate actionThe assistant handles parameter construction, error interpretation, and follow-up actions automatically.
Many tools require elevated privileges. The server provides a secure sudo management system:
sudo_elevate — provide your password once; it's stored in a zeroable Buffer (never logged)sudo_elevate_gui — use a native GUI dialog (zenity/kdialog) so the password is never visible to the AIsudo_status — check if the session is currently elevatedsudo_drop — immediately zero the cached password and drop elevationsudo_extend — extend the session timeout without re-entering the passwordpreflight_batch_check — check multiple tools' sudo requirements before running themConfiguration is via environment variables. All have secure defaults:
| Variable | Default | Description |
|---|---|---|
DEFENSE_MCP_DRY_RUN |
true |
Preview changes without applying |
DEFENSE_MCP_REQUIRE_CONFIRMATION |
true |
Require confirmation for destructive actions |
DEFENSE_MCP_ALLOWED_DIRS |
/tmp,/home,/var/log |
Directories the server can access |
DEFENSE_MCP_LOG_LEVEL |
info |
Log verbosity (debug/info/warn/error) |
DEFENSE_MCP_BACKUP_ENABLED |
true |
Auto-backup before system changes |
DEFENSE_MCP_AUTO_INSTALL |
true |
Auto-install missing tool dependencies |
DEFENSE_MCP_PREFLIGHT |
true |
Enable pre-flight dependency checks |
DEFENSE_MCP_PREFLIGHT_BANNERS |
true |
Show pre-flight status in tool output |
MCP_TRANSPORT |
stdio |
Transport mode: stdio or http |
MCP_PORT |
3100 |
HTTP server port (when MCP_TRANSPORT=http) |
To apply changes for real (not just preview), set:
DEFENSE_MCP_DRY_RUN=false node build/index.js
A security tool that isn't secure itself is worse than useless. This server implements defense-in-depth across 10 layers, from configuration defaults down to cryptographic verification.
The MCP spec defines security requirements for servers. Here's how this project meets them:
| MCP Requirement | Implementation |
|---|---|
| Validate all tool inputs | Zod schemas on every parameter + 15 specialized validators (paths, IPs, ports, service names, etc.) |
| Implement access controls | 200+ entry command allowlist, shell: false enforced, sudo session management |
| Rate limit tool invocations | 30/tool/min, 100 global/min, auth failure throttling (5 attempts per 5 minutes) |
| Sanitize tool outputs | Error sanitization strips paths, stack traces, and truncates to 500 chars |
Everything is locked down out of the box. You have to explicitly opt in to making changes:
/, /etc, /usr, /bin, /sbin are blocked by defaultNo tool can run arbitrary commands. Every command goes through multiple gates:
fs.existsSync(), never through which or PATHshell: false enforced — hardcoded, cannot be overridden. Shell metacharacters (;, |, &, `, $, etc.) have no effectEvery parameter is validated before it reaches any tool handler:
../ sequences rejected, null bytes blocked, symlinks resolved and re-validated[;|&$\(){}<>!\\n\r]` stripped from all inputs[\x00-\x08\x0e-\x1f\x7f] blockedThe server never asks for your password in a way an AI can see:
sudo_elevate_gui opens a native zenity/kdialog dialog. The password goes directly to sudo, never through the AI conversationsudo -S -k -v before being acceptedNOPASSWD: ALL rulessudo -S stdin piping — passwords are piped via stdin, never passed as command-line arguments (which would be visible in ps)Every file write is atomic and permission-hardened:
0o600, directories with 0o700~/.defense-mcp/backups/Sensitive runtime data is encrypted at rest:
DEFENSE_MCP_STATE_KEY)Auto-installed tools are verified, not blindly trusted:
curl | sh — all downloads verified before executionDEFENSE_MCP_THIRD_PARTY_INSTALL=true to enableProtection against runaway or abusive tool invocations:
Every change is recorded and reversible:
Hardening policies are enforced safely:
0o700 directory permissionsFor the full security architecture, see ARCHITECTURE.md.
# Run tests
npm test
# Run with coverage
npm run test:coverage
# Type check
npm run build:verify
# Security lint
npm run lint:security
# Security audit
npm run audit:security
MIT — see LICENSE
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"defense-mcp": {
"command": "npx",
"args": []
}
}
}