Skip to main content
Glama
Kavach MCP Server

Kavach MCP Server

by VAMFI
README.md
# Kavach

[![CI](https://github.com/VAMFI/kavach/actions/workflows/ci.yml/badge.svg)](https://github.com/VAMFI/kavach/actions/workflows/ci.yml)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
[![SARIF 2.1.0](https://img.shields.io/badge/SARIF-2.1.0-orange.svg)](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html)

**Agent-first, harness-agnostic defensive server security auditor, SARIF 2.1.0 correlator, Policy-as-Code gate, and read-only MCP server — built with zero external runtime dependencies.**

---

## What is Kavach? (In Plain English)

**Kavach** (Sanskrit for *armor / shield*) is a free, open-source safety layer for protecting backend servers and AI coding agents.

Most security scanners are noisy and hard for AI assistants to use safely: every tool prints a different format, secrets can accidentally leak into chat context, and blind automated fixes can lock you out of SSH or your firewall. **Kavach solves this in four simple steps:**

1. **Scan everything read-only:** Runs built-in zero-dependency checks on your Linux/Proxmox server, websites/TLS endpoints, and AI agent MCP/skill configs — and automatically plugs into top OSS scanners (`Trivy`, `Opengrep`, `Gitleaks`, `Checkov`, `Lynis`, `testssl.sh`) when installed.
2. **Prioritize by real exposure:** Checks live sockets (`ss -tulnp`) and firewalls (`nftables`, `pve-firewall`, `ufw`) so public internet risks jump to the top while scrubbing any leaked secrets before an AI sees them.
3. **Enforce Policy-as-Code:** Checks findings against declarative budgets and expiring waivers (`kavach policy-check`) plus baseline drift (`kavach diff --fail-on high`).
4. **Stage lockout-safe fixes:** Emits non-destructive drop-in config patches (`00-kavach-sshd.conf`, `99-kavach-sysctl.conf`, `kavach-edge-headers.conf`) and human-approved runbooks with syntax checks and `120s` rollback timers — never mutating your server behind your back.

---

## 30-Second Quick Start

**Prerequisites:** Python `>= 3.11` (standard library only — zero `pip` packages required).

```bash
git clone https://github.com/VAMFI/kavach.git
cd kavach

# One-command unified check (repo agent audit + external tools + policy + staged patches)
./bin/kavach protect --repo . --policy ./examples/policy.strict.json --emit-patches --out-dir /tmp/kavach-out

# Audit a Linux / Proxmox server + authorized HTTPS edge + repo together
./bin/kavach protect --host --repo . --url https://example.com --policy ./examples/policy.strict.json --emit-patches --out-dir /tmp/kavach-out
```

### Example Output (Sanitized)

```markdown
# Kavach Defensive Action Packet — `api.example.com`

- **Posture Score:** `76/100` (Grade `C`)
- **Tools Ingested:** `kavach-web`
- **Effective Counts:** critical `0` | high `2` | medium `1` | low `0` | info `0`

1. **[HIGH]** `kavach-web/HTTP-MISSING-CSP` (raw `medium`, exposure `public-internet`)
   - **Skill / Gate:** `tls-http-surface-audit` (`human-approval-lockout-safe`)
   - **Action:** Stage a conservative `Content-Security-Policy-Report-Only` policy before enforcing.
```

---

## How Kavach Works

```text
  Built-in Zero-Dep Auditors                    External OSS Scanners
  ──────────────────────────                    ──────────────────────
  • audit-host (sshd -T, nft -j, apt, auditctl, • Trivy / Checkov (SARIF)
    sysctl, perms, Proxmox pveproxy/pct)        • Opengrep / Gitleaks (SARIF)
  • audit-web (passive TLS + HTTP headers/CORS) • Lynis (.dat) / testssl.sh (.json)
  • audit-agent (MCP configs + SKILL.md safety)
                        │                                    │
                        └───────────────┬────────────────────┘
                                        ▼
                       kavach protect / correlate
                   (redact + exposure-aware risk + skill route)
                                        │
        ┌───────────────────┬───────────┴──────────┬──────────────────┐
        ▼                   ▼                      ▼                  ▼
  posture.sarif       policy-verdict         patches/           kavach diff
  & agent-brief.md    (budgets + waivers)    (00-sshd, sysctl,  (regression gate)
                                              edge headers)
```

---

## CLI Reference

| Command | Purpose | Mutates Host? |
| :--- | :--- | :--- |
| `kavach protect` | Unified orchestrator: host + repo/agent + web + external SARIF + policy + staged patches | No (read-only) |
| `kavach audit-host` | Zero-dep Linux & Proxmox VE security audit (`sshd -T`, `nft -j`, `apt-get -s`, `auditctl`, `sysctl`) | No (read-only) |
| `kavach audit-web --url <URL>` | Strictly passive TLS version/expiry + OWASP security header/CORS/cookie check | No (passive) |
| `kavach audit-agent --target <DIR>` | Audit MCP JSON configs & `SKILL.md`/`AGENTS.md` for secrets, unpinned runners, injection | No (read-only) |
| `kavach policy-check` | Enforce Policy-as-Code severity budgets, allowed ports, IPv6 parity, and expiring waivers | No (offline) |
| `kavach remediate-plan` | Generate phased runbook + optional `--emit-patches <DIR>` drop-in hardening snippets | No (read-only) |
| `kavach correlate` | Normalize, redact, exposure-weight, and export OASIS SARIF 2.1.0 + Action Packet | No (offline) |
| `kavach diff` | Compare baseline vs current `posture.json`; `--fail-on` exits `2` on regressions | No (offline) |
| `kavach capture-exposure` | Capture `ss -tulnp` TCP `LISTEN` sockets + `nftables`/`pve-firewall` summary | No (read-only) |
| `kavach doctor` | Detect installed defensive OSS scanners (`trivy`, `opengrep`, `gitleaks`, `lynis`, `testssl.sh`, etc.) | No (read-only) |
| `kavach scan --target <DIR>` | Run installed local read-only OSS scanners (`--dry-run` supported) and correlate | No (read-only) |
| `kavach skill-map` | Group findings by paired `/skill-foundry` `SKILL.md` and safety gate | No (offline) |
| `kavach mcp` | Start stdio MCP server (`7` default tools, `--print-manifest` SHA-256 pinning, `--allow-live-host-audit`) | No (read-only) |

---

## Paired `/skill-foundry` Defensive Skills (`7` Total)

| Skill | Focus | Primary OSS Stack |
| :--- | :--- | :--- |
| `linux-server-security-audit` | Host hardening, `sshd -T`, `nftables`, Proxmox VE | `sshd`, `nft`, `lynis`, `oscap` |
| `backend-vuln-sbom-scan` | Dependencies, containers, SBOMs, IaC | `trivy`, `syft`, `grype`, `vuls`, `checkov` |
| `backend-sast-secrets-audit` | SAST & redacted secret hygiene | `opengrep` (LGPL-2.1), `gitleaks --redact` |
| `tls-http-surface-audit` | Passive TLS, headers, cookies, CORS, edge diff | `testssl.sh`, `openssl`, `curl -sSI`, `kavach audit-web` |
| `linux-runtime-defense-audit` | Runtime defense & FIM posture | `crowdsec`, `falco`, `wazuh-agent`, `aide`, `auditd` |
| `agent-mcp-security-audit` | MCP config safety, SHA-256 tool pinning, prompt safety | `kavach audit-agent`, `kavach mcp --print-manifest` |
| `policy-as-code-sarif-gates` | Policy budgets, expiring waivers, SARIF drift loops | `kavach policy-check`, `kavach diff`, OPA/Rego, DefectDojo |

---

## Documentation for Humans & AI Agents

- **For AI Agents & Harnesses:** Read [`AGENTS.md`](./AGENTS.md) and [`llms.txt`](./llms.txt) for exact CLI/MCP contracts, SHA-256 tool pinning, and mandatory lockout-safe human gates.
- **Cross-Harness MCP & CI Integration:** See [`docs/harnesses.md`](./docs/harnesses.md) for Antigravity, Claude Code, Codex CLI, Cursor, Gemini CLI, GitHub Code Scanning, and DefectDojo setup.
- **Starter Strict Policy:** See [`examples/policy.strict.json`](./examples/policy.strict.json).
- **Security Policy:** See [`SECURITY.md`](./SECURITY.md) — strictly defensive, authorized targets only, zero offensive modules.

---

## Verification & Contributing

```bash
PYTHONPATH=src python3 -m unittest discover -s tests -v
```

Contributions are welcome — see [`CONTRIBUTING.md`](./CONTRIBUTING.md).

## License

MIT License — Copyright (c) 2026 **VAMFI Inc.** ([`vamfi.org`](https://vamfi.org)). See [`LICENSE`](./LICENSE).

TDQS

B3.2/5.0

Scored across 7 tools

Disambiguation4/5

Most tools are cleanly separated by stage of the posture workflow: detect scanners, correlate outputs, diff baselines, map to skills, plan remediation, audit AI configs, and check policy. The closest overlap is between kavach_skill_map, kavach_remediate_plan, and kavach_policy_check, which all consume posture.json and emit guidance, but their descriptions (skill grouping vs. runbook vs. policy/waiver evaluation) give enough signal to choose correctly.

Naming Consistency4/5

All seven tools share a consistent kavach_ prefix and snake_case convention, making the set instantly recognizable as one family. The suffix style varies (noun like _doctor, bare verb like _correlate, noun_verb like _skill_map, _diff_baseline, _remediate_plan), which is a minor deviation from a strict verb_noun pattern but never ambiguous.

Tool Count5/5

Seven tools is well within the sweet spot and each maps to a distinct stage of a security posture pipeline rather than duplicating functionality. No tool feels like filler, and none are obviously missing from the count perspective.

Completeness3/5

The surface covers detection, correlation, baseline diffing, prioritization, remediation planning, and policy evaluation, but there is no tool to actually execute the detected scanners or emit/write the Action Packet, so kavach_correlate depends on artifacts produced outside the server. It is also unclear how waivers for kavach_policy_check are managed, and there is no post-remediation verification step, leaving notable gaps in the loop.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues