Metadata-Version: 2.5
Name: agent-gatehouse
Version: 0.5.0
Summary: One-install security suite for AI agents: vet MCP servers, firewall tool traffic, guard sensitive reads, audit everything.
Project-URL: Repository, https://github.com/Realgagenichols/gatehouse
Project-URL: Issues, https://github.com/Realgagenichols/gatehouse/issues
Project-URL: Security, https://github.com/Realgagenichols/gatehouse/security/policy
Author-email: Gage Nichols <gage@hiregage.com>
License-Expression: MIT
License-File: LICENSE
Keywords: ai-agents,audit,claude-code,dlp,firewall,mcp,scanner,security
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Requires-Python: >=3.12
Requires-Dist: mcp<1.28,>=1.27.2
Requires-Dist: pydantic>=2.13.4
Requires-Dist: pyyaml>=6.0.3
Provides-Extra: full
Requires-Dist: chardet>=5.0.0; extra == 'full'
Requires-Dist: openpyxl>=3.1.0; extra == 'full'
Requires-Dist: pdfplumber>=0.10.0; extra == 'full'
Requires-Dist: python-docx>=1.0.0; extra == 'full'
Requires-Dist: python-magic>=0.4.27; extra == 'full'
Description-Content-Type: text/markdown

# gatehouse

**One install that puts a security perimeter around your AI agent.**

```sh
uv tool install agent-gatehouse      # or: pipx install agent-gatehouse
gatehouse setup                      # shows a plan, asks, then protects every agent it finds
gatehouse status                     # am I protected?
```

`setup` finds Claude Code, Claude Desktop and Cursor and shows you exactly which files it will
change and which MCP servers it will start to vet them. Only after you agree does it vet the
servers, back up your configs and wire everything in **observe mode**: firewall rules log what
they would block until you say so, while the read guard (it asks before an agent reads sensitive
files) and self-protection work from the start. `--dry-run` shows the plan and starts nothing. `gatehouse uninstall` puts it all back.

## What you get

| | | |
|---|---|---|
| 🔎 **Vet** | before a server runs | Every MCP server is started in a sandbox with decoy credentials, and the tool definitions the model would read are checked for prompt injection, hidden text, credential-fishing parameters and impersonated tool names. What it saw is locked, so a server that changes after you approved it — a *rug-pull* — shows up in `gatehouse verify --all`. |
| 🧱 **Firewall** | on every tool call | Policy and data-loss prevention on every call and result: block `curl … \| sh`, stop an AWS key from leaving in a GitHub issue, redact credentials out of tool output before the model sees them. Claude Code is covered through its hooks (built-in and MCP tools); Claude Desktop and Cursor through an MCP gateway. |
| 🛡️ **Read guard** | before a file is read | When Claude Code is about to read a file full of Social Security numbers, card numbers, private keys or patient data, you are asked first — with a summary of *what kinds* of data it holds, never the values. |
| 📜 **Audit** | always | A hash-chained log of every decision, which `gatehouse audit verify` can prove was not edited. Secret values never appear in it. |
| 🔒 **Self-protection** | always | The agent cannot edit gatehouse's config, its hooks or its audit log, and cannot run `gatehouse setup`, `uninstall` or `mode` itself — in observe mode too. |

Everything is deterministic and local: no AI judges another AI, nothing is sent anywhere.

## Day to day

```sh
gatehouse status                 # wiring, mode, last vet results, audit health — one screen
gatehouse report                 # what the firewall saw, and what it would have stopped
gatehouse mode enforce           # start blocking (and `gatehouse mode observe` to go back)
gatehouse scan --all             # vet every server, e.g. after installing a new one
gatehouse verify --all           # has any server changed since it was vetted?
gatehouse scan --all --accept-changes cursor/notes   # after reviewing a change: new baseline
gatehouse uninstall              # remove everything setup added, restore your configs
```

A sensible rollout: run a few days in observe mode, read `gatehouse report`, then
`gatehouse mode enforce`.

A server that changed since it was vetted is reported as **CHANGED** by both `scan --all` and
`verify --all` — with what its descriptions said before and say now — and its old baseline is
kept until you accept the change: re-scanning never quietly forgets a rug-pull. A server you add
to Claude Desktop or Cursor after setup shows as **PARTLY protected** in `status`; run
`gatehouse setup` again to move it behind the firewall. Servers from a repository's `.mcp.json` are vetted only once you
have approved them in Claude Code, so running gatehouse inside a cloned repo starts nothing new.

### When gatehouse asks or blocks

- **The read guard asks before an agent reads a file that holds sensitive values** (SSNs, card
  numbers, keys — not files that merely *mention* them). Answer in Claude Code's prompt; a yes
  covers that file for the rest of the session unless it changes. Folders you never want asked
  about (test fixtures, say) go in `~/.config/gatehouse/dlp-policy.toml`:
  ```toml
  [read_guard]
  allow = ["~/code/myapp/tests/fixtures/**", "*.sample"]
  ```
- **A firewall rule blocks or asks** (enforce mode) — the message says which rule and why.
  Rules live in `~/.config/gatehouse/claude-code.yaml`; edit it yourself, then
  `gatehouse gateway validate -c ~/.config/gatehouse/claude-code.yaml`. If you edit it into a
  state that does not load, gatehouse keeps using the last version that did and `status` says so.
- **Test data blocked from being written** — values like `AKIAIOSFODNN7EXAMPLE`, test card
  numbers and un-issuable SSNs are never blocked. For your own fixtures, list their folders under
  `dlp.exempt_paths` in the firewall config. (Exempt paths cover what the agent *writes*; what it
  *reads* is still masked, so an exempt folder can't become a way to read a copied secret.)
- **Masked output** — when the firewall masks values in what a tool returns, the agent is told
  how many, and that the file on disk is unchanged.
- **"… is not allowed from the agent"** — self-protection. Changes to Claude Code's settings
  that keep gatehouse's hooks just ask you; ones that would remove them, and any change to
  gatehouse itself, are yours to make in a terminal.

## Other commands

| Command | |
|---|---|
| `gatehouse scan <command or URL>` | vet one server before you install it (`--format json\|sarif` for CI) |
| `gatehouse classify <file…>` | what the read guard thinks of a file |
| `gatehouse audit verify\|query\|replay` | inspect the audit log |
| `gatehouse gateway run\|validate\|import\|auth\|emit-config` | run or hand-configure the MCP gateway |

`gatehouse <command> --help` has every option. Deeper documentation for each component —
detectors, policy language, DLP patterns, rule packs — is in [`docs/components/`](https://github.com/Realgagenichols/gatehouse/tree/main/docs/components/).

To vet a remote MCP server that needs a token, set `GATEHOUSE_AUTH_TOKEN` and run
`gatehouse scan <url>`.

## Where things live

`~/.config/gatehouse/` holds the firewall config per client (`claude-code.yaml`,
`claude-desktop.yaml`, `cursor.yaml`), the read-guard policy (`dlp-policy.toml`, optional — see
[`examples/dlp-policy.toml.example`](https://github.com/Realgagenichols/gatehouse/blob/main/examples/dlp-policy.toml.example)), the audit log, vet
results and locks (`vet/`), and backups of every file setup changed (`backups/`). The firewall
configs hold your MCP servers' own environment (tokens included) once setup routes them, so the
directory is private (0700) and the agent is not allowed to read it without asking.

## Limits — read these

- **Field-tested in observe mode, with Claude Code.** gatehouse has run on a working machine in
  `observe` mode. `enforce` mode, the gateway for Claude Desktop and Cursor, and Linux are covered
  by the test suite but not yet by sustained real use. Start in `observe`, read `gatehouse report`,
  then switch.
- **Vet "pass" means no known pattern matched**, not that a server is safe. A paraphrased
  instruction gets past pattern matching; the firewall and audit log are the next line.
- **The vet sandbox is strong on macOS only** (`sandbox-exec`). On Linux a server under scan
  gets a scrubbed environment, a fake home and time limits, but no filesystem or network
  confinement — and a warning saying so.
- **Self-protection is exact for file tools; for shell commands it only catches paths
  spelled out in full.** `rm -rf ~/.config/gatehouse`, `sed -i … ~/.config/gatehouse/…`,
  `gatehouse mode …` and `uv tool uninstall agent-gatehouse` are blocked, including inside
  `bash -c '…'`. Changing directory first (`cd ~/.config && …`), globs (`~/.config/gate*`),
  wrappers (`env`, `sudo`), commands aimed at a parent directory (`rm -rf ~/.config`), pipes
  into `xargs` and paths built at run time all get past it; the audit log records the call.
  Following the shell further was tried and set aside: every step closed some bypasses and
  blocked ordinary work, and self-protection blocks in observe mode too. A command over
  128 KB is asked about.
- **If the `gatehouse` program disappears, every check stops.** Claude Code lets a tool call
  through when a hook's command is missing. Self-protection blocks the agent from deleting or
  replacing it by name, but not by the routes above; `gatehouse status` reports it. Install it
  with `uv tool install`, outside any project the agent works in.
- **The read guard checks `Read` and `Grep` of a single file before they run.** A `Grep` over a
  whole directory, or `cat` in a shell, is not pre-checked — there the firewall's redaction of
  the result (SSNs, card numbers, keys) is the backstop. Text past the first million characters
  is not classified, and a file that takes longer than 5 seconds to classify is let through
  unchecked. PDF, Word and Excel files are only looked inside with the `full` extra
  (`uv tool install 'agent-gatehouse[full]'`).
- **Secret detection matches values as they are written.** A secret that is base64-encoded,
  or split across arguments or calls, is not recognised. Invisible characters inside a value
  are ignored, so they do not hide it.
- **A damaged audit log is never reported as intact**, but when the chain is recovered after
  corrupted lines, `audit verify` cannot tell how many events those lines replaced. Deleting
  events from the end of a log is only detectable against a head you recorded elsewhere. With
  `GATEHOUSE_AUDIT_KEY` set, every event is also signed, so none can be rewritten without the
  key (a keyed log from before 0.5.0 signed events will not verify; archive it). The log is never rotated: move it aside when it gets large, and a new one starts.
- **Where Claude Code cannot ask you, gatehouse blocks instead.** In `auto`, `dontAsk` and
  `bypassPermissions` modes Claude Code approves a hook's question without showing it to you, and
  non-interactive `claude -p` runs deny it; so a read the read guard would ask about is blocked,
  with the exact `gatehouse allow <path>` command to run if you want agents to read it.
- **Cursor** runs through the gateway; its support is not yet verified against Cursor itself.

## For maintainers: the benchmark

`bench/poison-garden/` is a corpus of deliberately malicious MCP servers for measuring MCP
scanners — including gatehouse's own vetter. It is a separate package that is never installed
with gatehouse and never imported by it: its value depends on independence from the scanner it
measures. Read its README (especially *Safety*) before running anything there.

## Development

```sh
uv sync --all-packages
uv run pytest                                   # suite
uv run ruff check .
(cd bench/poison-garden && uv run --package poison-garden pytest)
```

`scripts/ci-local.sh` runs everything CI runs (suite, bench and corpus checks on Python 3.12 and
3.13) on your machine; `--quick` is the fast inner loop, `--linux` adds a Linux run in Docker. CI
runs the same checks on GitHub for every push to `main` and every pull request.

On macOS, keep the virtualenv outside an iCloud-synced folder (iCloud re-hides the `.pth` files an editable install depends on).

gatehouse merges four earlier projects — frisk, tollbooth, claude-dlp-guard and poison-garden —
into one install. MIT licensed.

Found a way past gatehouse? Please report it privately; see [SECURITY.md](https://github.com/Realgagenichols/gatehouse/blob/main/SECURITY.md).
