agent-preflight
# agent-preflight
Zero-dependency local security guardrail **CLI & MCP server** for AI coding agents. Run three fast pre-flight checks locally with zero API keys before trusting a repo, pasting logs into an LLM, or installing AI-suggested packages:
1. **Secrets & PII Redaction** — detects and masks GitHub/AWS/OpenAI/Anthropic/Stripe keys, private keys, and emails (`[REDACTED:...]`).
2. **Prompt Injection & Trojan-Source Unicode** — flags hidden bidi/zero-width control characters, system-prompt exfiltration instructions, and raw-IP fetches in untrusted READMEs, issues, and diffs.
3. **Slopsquatting Dependency Check** — verifies `requirements.txt`, `pyproject.toml`, and `package.json` entries against PyPI and npm to catch hallucinated or newly registered typosquat packages.
## Quickstart
Requires Python 3.11+ (zero external runtime dependencies).
```bash
# Scan current repository (exits 1 on high-severity findings)
uvx --from git+https://github.com/dev-shiki/agent-preflight agent-preflight scan .
# Check Python/Node manifests for slopsquatted or <14-day-old packages
uvx --from git+https://github.com/dev-shiki/agent-preflight agent-preflight check-deps .
# Redact PII/secrets from a log file before sharing
uvx --from git+https://github.com/dev-shiki/agent-preflight agent-preflight redact debug.log
```
## MCP Server Configuration
Add to Claude Code, Cursor, Windsurf, or Antigravity `mcp_config.json`:
```json
{
"mcpServers": {
"agent-preflight": {
"command": "uvx",
"args": ["--from", "git+https://github.com/dev-shiki/agent-preflight", "agent-preflight-mcp"]
}
}
}
```
### Exposed MCP Tools
- `preflight_scan_text` — inspect untrusted text for secrets, bidi Unicode, and prompt injection.
- `preflight_scan_path` — recursively scan a file or workspace directory.
- `preflight_redact` — scrub secrets and emails from text.
- `preflight_check_deps` — verify PyPI/npm packages in a project directory.
## Development
```bash
uv run --with pytest pytest -v
```
TDQS
Scored across 4 tools
Each tool targets a distinct operation: scanning text, scanning a filesystem path, redacting sensitive data, and checking dependencies. The only mild overlap is between preflight_scan_text and preflight_scan_path, but the descriptions clearly differentiate string input from filesystem input.
All four tools use a consistent preflight_ prefix followed by a verb_noun or verb form (scan_text, scan_path, redact, check_deps). The pattern is predictable and immediately readable.
Four focused tools map cleanly to the server's stated preflight-safety purpose, with no filler or redundant entries. Each tool earns its place.
The surface covers the core safety workflows: text scanning, path scanning, redaction, and dependency verification. Minor gaps exist, such as scanning remote URLs/repos or configuring rules, but the main use cases are handled.