The local security layer for coding agents. Use Claude Code, Codex, Cursor, OpenCode or Hermes without exposing your secrets, your data or your systems. Open source, MIT, nothing leaves your machine.
- ✓Open-source license (MIT)
- ✓Actively maintained (<30d)
- ✓Clear description
- ✓Topics declared
- ✓Documented (README)
claude mcp add zn -- npx -y zn-gate{
"mcpServers": {
"zn": {
"command": "npx",
"args": ["-y", "zn-gate"]
}
}
}MCP Servers overview
<p align="center">
<a href="https://usezn.com">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/brand/zn-banner-dark.png">
<source media="(prefers-color-scheme: light)" srcset="assets/brand/zn-banner-light.png">
<img src="assets/brand/zn-banner-light.png" alt="zn" width="100%">
</picture>
</a>
</p>
<h1 align="center">zn-gate</h1>
<p align="center">
<strong>Use AI coding agents without exposing your secrets, your data or your systems.</strong><br/>
An open-source security layer that runs on your machine, between your agent and the tools and content it touches.
</p>
<p align="center">
<a href="https://github.com/usezn/zn/actions/workflows/ci.yml"><img src="https://github.com/usezn/zn/actions/workflows/ci.yml/badge.svg" alt="CI"/></a>
<a href="https://www.npmjs.com/package/zn-gate"><img src="https://img.shields.io/npm/v/zn-gate?color=cb3837&logo=npm&logoColor=white" alt="npm version"/></a>
<a href="https://pypi.org/project/zn-gate/"><img src="https://img.shields.io/pypi/v/zn-gate?color=3775a9&logo=pypi&logoColor=white" alt="PyPI version"/></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License: MIT"/></a>
</p>
<p align="center">
<a href="https://usezn.com/docs">Docs</a> ·
<a href="packages/zn-gate/README.md">npm package</a> ·
<a href="packages/zn-gate-py/README.md">Python package</a> ·
<a href="SECURITY.md">Security</a> ·
<a href="https://discord.gg/WngUHPsA9D">Discord</a>
</p>
---
**For:** developers using Claude Code, Codex CLI, Cursor, OpenCode or any MCP client, and teams building agents with MCP, LangChain, CrewAI or LlamaIndex.
**What it does:** keeps secret values out of what your agent sends to its model, checks what your agent reads and calls for prompt injection, and audits prompts, skills and configs. Everything runs on your machine, is MIT-licensed and needs no account. The Python package has no runtime dependencies; the npm package's only one is `age-encryption` (with its `@noble`/`@scure` dependencies) for the secret vault, bundled in the package.
## Install
**Keep secrets out of your agent's context.** The secrets scrubber and broker for coding agents keeps real values in an encrypted vault on your machine, and your agent works with markers such as `__ZN_STRIPE_KEY__`.
```bash
npm install -g zn-gate # Node.js 18+
zn unlock # create or unlock the local vault
zn env shadow .env # move .env values into the vault, leave markers
zn hooks install claude-code # or: codex, cursor, opencode
```
Cursor support is partial: zn-gate can only rewrite the output of MCP tools there, not of shell commands or file reads.
Five-minute walkthrough: [docs/secrets.md](docs/secrets.md). What each agent supports: [docs/compat.md](docs/compat.md). Limits: [docs/threat-model.md](docs/threat-model.md).
**Add zn-gate as an MCP server.** Pick your agent. Each command adds zn-gate as an MCP server (Node.js 18+).
**Claude Code**
```bash
claude mcp add zn-gate -- npx -y zn-gate mcp
```
**Codex CLI**
```bash
codex mcp add zn-gate -- npx -y zn-gate mcp
```
**Cursor**: add to `~/.cursor/mcp.json`
```json
{ "mcpServers": { "zn-gate": { "command": "npx", "args": ["-y", "zn-gate", "mcp"] } } }
```
**OpenCode**: add to `~/.config/opencode/opencode.json`
```json
{ "mcp": { "zn-gate": { "type": "local", "command": ["npx", "-y", "zn-gate", "mcp"], "enabled": true } } }
```
**Protect the MCP servers you already use.** `init` finds them in your agent configs, writes a backup, and wraps each local server with the zn-gate proxy:
```bash
npx -y zn-gate init --dry-run # preview
npx -y zn-gate init # wrap (backup first)
npx -y zn-gate init --revert # undo
```
It reads Claude Desktop, Claude Code (`~/.claude.json`), Cursor (`~/.cursor/mcp.json`), Codex CLI (`~/.codex/config.toml`) and OpenCode (`~/.config/opencode/opencode.json`). [Full list and rules](packages/zn-gate/README.md#wrap-the-mcp-servers-you-already-use).
**Python** (rules engine and secret redaction; the vault, hooks and `zn run` are in the npm package)
```bash
pip install zn-gate
```
## Check that it works
Send a tool output with a fake AWS key (AWS's documentation example) and a database password through zn-gate, exactly as your agent would. Requires zn-gate 1.4.1 or later.
```bash
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"check_tool_result","arguments":{"tool_name":"read_file","content":"AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\nDATABASE_URL=postgres://app:hunter2@db:5432/main"}}}' \
| npx -y zn-gate@latest mcp | jq -r '.result.content[0].text'
```
`jq` only pretty-prints; without it, look for `sanitized_content` in the raw JSON. That field is what the model would see:
```text
"secrets_redacted": 2,
"sanitized_content": "AWS_ACCESS_KEY_ID=[REDACTED_AWS_KEY]\nDATABASE_URL=postgres://app:[REDACTED_DB_PASSWORD]@db:5432/main"
```
Nothing was sent over the network. Python equivalent:
```bash
python -c "from zn_gate import sanitize_tool_result as s; print(s('read_file', 'AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE')['sanitized_content'])"
```
Then run the local self-test (51 curated vectors: 26 attacks, 25 benign):
```bash
npx -y zn-gate test
```
## What each piece does
Where zn-gate sits in a tool call, as an MCP server or as the `shield` proxy around other servers:
```mermaid
sequenceDiagram
participant A as Agent
participant Z as zn-gate (on your machine)
participant T as Tool or MCP server
A->>Z: analyze_prompt
Z-->>A: allow, or block with the rule that fired
A->>Z: check_tool_call (name, arguments)
Z-->>A: allow with secrets masked, or block
A->>T: run the tool
T-->>Z: output (check_tool_result, or through shield)
Z-->>A: output with secrets redacted, or neutralized if it carries an injection
```
### Scrubber: secrets stay out of the model's context
- **Today, through zn-gate:** redacts AWS keys, OpenAI and Anthropic keys, GitHub tokens, JWTs, private keys and database URL passwords in everything that passes through zn-gate: tool output checked with `check_tool_result`, tool arguments checked with `check_tool_call`, and output of MCP servers wrapped by `zn-gate shield` / `init`. Python: `sanitize_tool_result`, `@guard(mask_secrets=True)` and the framework integrations.
- **Today, agent hooks and vault (npm package):** hooks for Claude Code, Codex CLI and OpenCode scrub the output of the agents' built-in tools and block pasted secrets (in Cursor only MCP tool output is scrubbed); a local encrypted vault with stable markers (`__ZN_AWS_KEY_1__`); `zn run` fills values only into commands you approved; personal data (cards, IBAN, national IDs, e-mail, phone) is detected too. What each agent allows differs: see [docs/compat.md](docs/compat.md).
### Galvanize: prompt-injection detection
- **Today, local:** a deterministic rules engine (signatures plus normalization against homoglyphs, zero-width characters, BiDi overrides, comment splicing and Base64) checks prompts, tool arguments, tool output and MCP tool descriptions.
- **Today, optional cloud check:** the Galvanize 2 classifier ([open weights on Hugging Face](https://huggingface.co/usezn/Galvanize-2), Apache-2.0) can also check prompts sent to `analyze_prompt`, only if you set `ZN_CLOUD=1` and `ZN_API_KEY`. The secrets zn-gate detects are removed from the prompt on your machine before it is sent; personal data is not removed on this path.
- **Roadmap:** running Galvanize locally inside zn-gate.
### Scan: audit what your agent is about to trust
- **Today:** `zn-gate scan <path>` audits prompt templates, `AGENTS.md` / `SKILL.md` files and configs for injection traps and leaked secrets (exit code 1 on findings, for CI). The same check runs as a [GitHub Action](#github-action). MCP servers can be checked on the web at [usezn.com/scan](https://usezn.com/scan).
- **Roadmap:** auditing MCP servers and skills from the CLI before you add them.
## What the cloud adds for teams
Everything above runs locally, for free, with no account. The optional cloud at [usezn.com](https://usezn.com) is for teams that need a shared record of what their agents did:
- **Audit and traceability:** an evidence dashboard with the metadata of each cloud decision (verdict, rule, score, latency), 90-day retention and CSV/JSONL export.
- **A larger detection model** for prompts, when you opt in (`ZN_CLOUD=1`).
- **Team controls** (shared policies, organization-level audit): in progress.
By default nothing is sent. If you set `ZN_CLOUD=1` and an API key, `analyze` sends the prompt text after removing the secrets zn-gate detects locally: personal data is not removed on this path, and a secret it does not detect would be sent with the text. The dashboard keeps the metadata of each cloud decision. Tool output and tool-call arguments are never sent.
## What leaves your machine
**Nothing, by default.**
```mermaid
flowchart LR
subgraph local["Your machine"]
A["Agent"]
Z["zn-gate<br/>rules engine + secret redaction"]
T["Tools and MCP servers<br/>files, shell, web, databases"]
end
C["api.usezn.com<br/>Galvanize 2 classifier"]
A -- "tool calls and prompts" --> Z
Z -- "allowed calls, secrets masked" --> T
T -- "tool output" --> Z
Z -- "redacted output, verdicts" --> A
Z -. "prompts only, detected secrets removed,<br/>only with ZN_CLOUD=1 and ZN_API_KEY" .-> C
```
| Data | Evaluated | Sent anywhere? |
|---|---|---|
| Tool output (`check_tool_result`, `shield`) | Locally | **Never**, in any configuration |
| Tool-call arguments (`check_tool_call`, `shield`) | Locally | **Never**, in any configuration |
| MCP tool and parameter descriptions (`shield`) | Locally | **Never**, in any configuration |
| Prompts (`analyze_prompt`, `zn-gate analyze`, Python `analyze()`) | Locally | Only if you set **both** `ZN_CLOUD=1` and `ZN_API_KEY`. DeteWhat people ask about zn
What is usezn/zn?
+
usezn/zn is mcp servers for the Claude AI ecosystem. The local security layer for coding agents. Use Claude Code, Codex, Cursor, OpenCode or Hermes without exposing your secrets, your data or your systems. Open source, MIT, nothing leaves your machine. It has 2 GitHub stars and its last recorded update is dated 2026-10-12.
How do I install zn?
+
You can install zn by cloning the repository (https://github.com/usezn/zn) or following the README instructions on GitHub. ClaudeWave also provides quick install blocks on this page.
Is usezn/zn safe to use?
+
Our security agent has analyzed usezn/zn and assigned a Trust Score of 95/100 (tier: Verified). See the full breakdown of passed checks and flags on this page.
Who maintains usezn/zn?
+
usezn/zn is maintained by usezn. The last recorded GitHub activity is dated 2026-10-12, with 10 open issues.
Are there alternatives to zn?
+
Yes. On ClaudeWave you can browse similar mcp servers at /categories/mcp, sorted by popularity or recent activity.
Deploy zn to your cloud
Ship this repo to production in minutes. Each platform spins up its own environment with editable env vars.
Maintain this repo? Add a badge to your README
Drop the badge into your GitHub README to show it's tracked on ClaudeWave. Each badge links back to this page and reflects the live Trust Score.
More MCP Servers
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
Reverse engineer anything with agents, from app behavior down to native binaries.
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
An open-source AI agent that brings the power of Gemini directly into your terminal.
Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface
🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev