zn-gate MCP server
Commit Nov 16, 2026Provides a local security layer for coding agents by redacting secrets, checking for prompt injections, and wrapping MCP servers.
Also known as usezn/zn
- Stars
- 5
- Tools
- 4
- Downloads, 30 days
- —
- Latest version
- 1.15.0
- Last commit
- Nov 16, 2026
- License
- MIT
What is zn-gate MCP?
zn-gate provides a local security layer for coding agents by redacting secrets, checking for prompt injections, and wrapping MCP servers. It exposes 4 tools, such as analyze_prompt, check_tool_call, check_tool_result.
Summary generated from the project's README
About zn-gate MCP server
zn-gate acts as a local security layer designed to protect developers using coding agents like Claude Code, Cursor, Codex CLI, and ZCode. It functions as a middle layer between your AI agent and the tools or content it interacts with, running entirely on your machine without requiring an account or API keys. The system works by auditing prompts, checking for prompt injections, and redacting sensitive information from tool outputs before the model can see it.
Developers can deploy this protection using the init command to automatically configure supported agents or by installing it as a standalone MCP server for editors like VS Code or Zed. It includes a local encrypted vault to manage secrets, allowing you to move sensitive values from .env files into a secure storage area using the env shadow command. This ensures that while your local applications can still access necessary credentials, the AI agent only sees safe markers instead of real secrets.
What you can do with it
- 1Redact sensitive tool outputsPrevent an AI agent from seeing private credentials by replacing them with markers in tool results.
- 2Secure environment variablesMove real secret values from .env files into an encrypted local vault to hide them from coding agents.
- 3Audit agent reachCheck which secrets, credential files, and MCP servers are accessible to your coding agents on your machine.
- 4Protect existing MCP serversWrap your current local MCP servers to add a layer of security to their communications.
Written from the project's README. Every use case is checked against a quote from it.
How to install zn-gate MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall zn-gate MCP in Claude Code
$ claude mcp add --env 'ZN_API_KEY=<YOUR_ZN_API_KEY>' zn-gate -- npx -y zn-gate mcpInstall zn-gate MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"zn-gate": {
"command": "npx",
"args": [
"-y",
"zn-gate",
"mcp"
],
"env": {
"ZN_API_KEY": "<YOUR_ZN_API_KEY>"
}
}
}
}Install zn-gate MCP in VS Code
.vscode/mcp.json
{
"servers": {
"zn-gate": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"zn-gate",
"mcp"
],
"env": {
"ZN_API_KEY": "<YOUR_ZN_API_KEY>"
}
}
}
}Install zn-gate MCP in VS Code CLI
$ code --add-mcp '{"name":"zn-gate","type":"stdio","command":"npx","args":["-y","zn-gate","mcp"],"env":{"ZN_API_KEY":"<YOUR_ZN_API_KEY>"}}'Install zn-gate MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"zn-gate": {
"command": "npx",
"args": [
"-y",
"zn-gate",
"mcp"
],
"env": {
"ZN_API_KEY": "<YOUR_ZN_API_KEY>"
}
}
}
}Install zn-gate MCP in Codex
$ codex mcp add zn-gate --env 'ZN_API_KEY=<YOUR_ZN_API_KEY>' -- npx -y zn-gate mcpInstall zn-gate MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.zn-gate] command = "npx" args = ["-y", "zn-gate", "mcp"] [mcp_servers.zn-gate.env] ZN_API_KEY = "<YOUR_ZN_API_KEY>"
Install zn-gate MCP in Gemini CLI
$ gemini mcp add -s user -e 'ZN_API_KEY=<YOUR_ZN_API_KEY>' zn-gate npx -- -y zn-gate mcpInstall zn-gate MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"zn-gate": {
"command": "npx",
"args": [
"-y",
"zn-gate",
"mcp"
],
"env": {
"ZN_API_KEY": "<YOUR_ZN_API_KEY>"
}
}
}
}Started by HostedMCP on 16 Nov 2026
We ran this command for zn-gate 1.15.0 in an isolated container with no network and no keys. It answered and listed 4 tools.
zn-gate MCP tools 4
Read from the server with tools/listanalyze_promptRead-onlyCheck a piece of text for prompt injection, jailbreak attempts, role hijacking and attempts to steal credentials. Use it on a user message, system prompt or message from another agent that should be checked before you act on it. The check runs on this computer. Only if the user has turned on the optional cloud check (ZN_CLOUD=1 with ZN_API_KEY, or zn-gate connect) is the text, with secrets removed, also sent to the zn cloud. Returns a verdict (allow or block), a confidence score and the rule that matched. Example input: {"text": "Summarize the meeting notes below."}
check_tool_callRead-onlyCheck a tool call before it runs. Call it with the tool name and its arguments right before the agent executes the tool, for example a shell command, a file write, a database query or a message to send. It runs the local rules on the arguments and looks for injected instructions, sensitive file paths and links that would send data out. It does not judge whether a command is destructive. Nothing leaves the computer. Returns safe_to_execute, the verdict (allow or block) and the arguments with sensitive values hidden. Example input: {"tool_name": "write_file", "arguments": {"path": "notes.txt", "content": "hello"}}
check_tool_resultRead-onlyCheck the output of a tool before the model reads it. Call it on content that came from outside: web pages, search results, file contents, git commits, database query results and API responses. It looks for hidden instructions aimed at the model (indirect prompt injection) and for secrets such as API keys. Nothing leaves the computer. Returns the content with secrets redacted, or neutralized if an injection is found, plus the verdict. Example input: {"tool_name": "web_search", "content": "Search results here"}
zn_statusRead-onlyReport the current zn-gate status: the detection engine, the rules version, and whether anything leaves this computer (and if so, what). Call it when the user asks what zn-gate is doing or whether their data is shared. It takes no arguments and changes nothing. Example: call it with no arguments.
Configuration
ZN_API_KEYSecretAPI key for the optional cloud check. Has no effect without ZN_CLOUD=1.
ZN_CLOUDSet to 1 to let prompt analysis also query the optional cloud classifier. Off by default.
ZN_LOCAL_ONLYSet to true to force local-only mode, even if ZN_CLOUD=1.
Automated checks
Ran Nov 16, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachableusezn/zn is public and reachablegithub.com/usezn/zn ↗Pass
- Package names this repository as its sourcezn-gate names usezn/zn as sourcenpmjs.com/package/zn-gate ↗Pass
- Build provenance (Sigstore attestation)Sigstore attestation for zn-gatenpmjs.com/package/zn-gate/v/1.15.0#provenance ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-16github.com/usezn/zn ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNo popular package one edit away from zn-gatePass
- No critical advisory in the package or its dependencies9 resolved dependencies checked; no critical advisoryosv.dev ↗Pass
- No hidden instructions to the modelInstruction aimed at the model found in the README or listing descriptionFinding
- Destructive tools are labelledNo tool named like delete, drop or execPass
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubzn-gate
The local security layer for coding agents. zn-gate guards your secrets, your data and your systems while you use Claude Code, Codex CLI, Cursor, OpenCode, Antigravity or ZCode desktop app.
zn-gate is an open-source security layer that runs on your machine, between your agent and the tools and content it touches. It checks what the agent reads and calls for prompt injection, redacts secrets from tool output before the model sees it, and audits prompts, skills and configs. No account, no network by default, and no runtime dependencies except age-encryption (and its @noble/@scure dependencies) for the secret vault, bundled in the package at the versions pinned in package-lock.json.
For: developers using Claude Code, Codex CLI, Cursor, OpenCode, Antigravity, ZCode desktop app or any MCP client. Python SDK: zn-gate on PyPI.
Install
Everything runs on your machine; no account or API key is needed. Node.js 22 LTS is recommended (from nodejs.org). Node.js 18 or later works for the hooks and the CLI; the Claude Code plugin needs 20.19 or later. For security, use the latest patch of a supported Node.js line (22.23.4, 24.22.1, 26.12.1 or later): Node.js 18 and 20 are end-of-life and get no security fixes, even though zn-gate still runs on them. With a Node.js older than 18, the zn-gate and zn commands stop and say how to install it.
Getting started: four steps, one command each. Run them in your own terminal.
npx -y zn-gate reachshows what your coding agents can reach on this machine: secrets in your.envfiles (by name only), credential files and MCP servers. It is read only and sends nothing. Details in docs/reach.md.npx -y zn-gate initsets up protection for the coding agents it finds, one step at a time, and asks before each change.npx -y zn-gate checktests that protection with a fake secret in a temporary folder.initruns it at the end too.npx -y zn-gate env shadow .envmoves the real values of your.envinto the local vault and leaves markers in the file. The first time, runnpx -y zn-gate unlockto create the vault.
One command for the coding agents on your machine:
npx -y zn-gate init
init does this:
- It finds Claude Code, Codex CLI, Cursor, OpenCode, Antigravity and ZCode desktop app on your machine.
- For each one that is not protected yet, it shows the setup: the zn-gate plugin for Claude Code (or zn's hooks when your Node.js is older than 20.19), and zn's hooks for the others.
- It runs each step only after you confirm it.
- It ends with
zn-gate check.
Run it yourself, in your own terminal. When an AI agent or a script runs it, it only prints the steps.
Windows PowerShell:
npmandnpxcan fail with "running scripts is disabled on this system", because the default execution policy blocksnpm.ps1. Usenpm.cmd,npx.cmdandzn.cmdinstead (for examplenpm.cmd install -g zn-gate), run the commands from Command Prompt, or allow local scripts for your account withSet-ExecutionPolicy -Scope CurrentUser RemoteSigned.
If something fails:
npx: command not found, or a message about the Node.js version: install the LTS version of Node.js, open a new terminal and run the command again.- "running scripts is disabled on this system" on Windows: see the PowerShell note above.
initonly prints steps and changes nothing: an AI agent or a script ran it. Run it yourself in your own terminal.checkshows NOT protected: that line says why and what to run. What the output means.- You want to remove zn-gate:
npx -y zn-gate uninstallshows what it will remove (the Claude Code plugin, zn's hooks, wrapped MCP servers) and asks first.init --revertonly puts back MCP configs saved before wrapping.
Then keep your .env values in the vault. With the plugin or the hooks, the agent cannot read .env files with real values; move them into zn-gate's encrypted vault, and the file keeps markers such as __ZN_STRIPE_KEY__:
npx -y zn-gate unlock # creates the vault the first time
npx -y zn-gate env shadow .env
After this, your own app also reads the markers in .env: start it with zn-gate's run command once you allow it (docs/secrets.md). env shadow tells you how to undo it.
Five-minute walkthrough: docs/secrets.md. Limits: docs/threat-model.md. Words you do not know: glossary. Every command and exit code: command line reference.
One agent at a time (the same steps init runs):
Claude Code: the plugin. You also need Git and Claude Code 2.1.295 or later. The plugin needs Node.js 20.19 or later. With an older Node.js, npx -y zn-gate init skips the plugin and sets up zn's hooks for Claude Code instead (zn-gate check says so if the plugin is installed); update Node.js to use the plugin.
claude plugin marketplace add usezn/zn
claude plugin install zn-gate@usezn
Already ran zn hooks install claude-code before? Run zn hooks uninstall claude-code first, otherwise both sets of hooks run.
Start a new Claude Code session. Claude Code is then blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced with markers or redacted before the model sees them, a secret pasted into a prompt is blocked. The plugin adds no MCP server since version 1.14.0: for the secrets server, run zn hooks install claude-code instead of the plugin. Not covered: Claude Code sessions in the cloud, Cowork and chat. Details: plugins/zn-gate.
Codex CLI, Cursor or OpenCode: the hooks.
npm install -g zn-gate
zn hooks install codex # or: cursor, opencode
In Codex, approve the new hooks with /hooks. In Cursor, shell output and file contents are not scrubbed. What each agent supports: docs/compat.md.
Other editors (VS Code, Windsurf, Cline, Zed, JetBrains, Continue): zn-gate works there as an MCP server only. Setup for each one: usezn.com/docs/integrations/editors.
Antigravity. zn hooks install antigravity (or npx -y zn-gate init) adds a hook that runs before each tool call. It blocks reads and writes of secret files and shell commands that handle secrets, and the agent cannot edit the hook files. It cannot remove secrets from what a tool returns, Antigravity's MCP configuration files are not protected, and Antigravity does not document what happens when a hook fails (in our tests the call is blocked), so treat it as a first layer. The MCP server works there too. Details: Antigravity page.
ZCode desktop app. zn hooks install zcode (or npx -y zn-gate init) adds hooks that run before each tool call and before each prompt. It blocks reads and writes of secret files, shell commands that handle secrets, MCP calls that would send a secret, and a prompt that contains a secret, and the agent cannot edit ZCode's own config file. It cannot remove secrets from what a tool returns (zn adds a notice when an output holds one), ZCode ignores the hooks of a project, and zn's launcher blocks the call when its Node.js is gone, so treat it as a first layer. ZCode's documentation does not say what happens when a hook fails; in our tests with the ZCode desktop app 3.16.3 on Linux, a hook that failed (an exit code other than 2, a crash or a timeout) let the call run, and only exit code 2 or a deny answer blocked it. Tested end to end on the ZCode desktop app 3.16.3 on Linux x64 and Windows x64 (Windows Server 2022, through the agent the app ships; the Windows app window was not driven); macOS is not tested. Details: ZCode page.
Copilot CLI (experimental). zn hooks install copilot adds hooks that run before and after each tool call. They block reads and writes of secret files and shell commands that handle secrets, and replace secret values in the results of read-type and shell tools. They cannot block a typed prompt, Copilot lets a call through when a hook times out, so zn, which sets a 15-second timeout on its hooks, blocks the call itself at 11 seconds, it has not been tested on Windows, and Copilot's own session log keeps the original output, so treat it as a first layer. Details: Copilot CLI notes.
Gemini CLI (experimental). zn hooks install gemini adds a hook that runs before each tool call. It blocks reads and writes of secret files and shell commands that handle secrets, and the agent cannot edit Gemini CLI's settings files. It does not change what a tool returns, Gemini CLI hooks cannot ask you for confirmation, and Gemini CLI lets a call run when a hook crashes or times out, so zn blocks it instead (a hook that fails is answered with a block, and zn sets a 15-second timeout on its hook and answers a check still running after 11 seconds with a block), so treat it as a first layer. Google replaced Gemini CLI with Antigravity CLI for free and Google One accounts on 18 June 2026; Gemini CLI keeps working with zn-gate. Details: Gemini CLI notes.
Python: for agents you build yourself (rules engine and secret redaction for LangChain, CrewAI, LlamaIndex or plain tool calling). It does not protect Claude Code, Codex, Cursor or other coding agents. Install it in a virtual environment; many recent Linux systems, and Homebrew's Python on macOS, refuse pip install outside one ("externally-managed-environment"):
python3 -m venv .venv
.venv/bin/pip install zn-gate # Windows: .venv\Scripts\pip install zn-gate
zn-gate as an MCP server only (the agent calls it when it decides to; not automatic protection):
claude mcp add zn-gate -- npx -y zn-gate mcp # Claude Code
codex mcp add zn-gate -- npx -y zn-gate mcp # Codex CLI
Cursor (~/.cursor/mcp.json) and other editors: { "mcpServers": { "zn-gate": { "command": "npx", "args": ["-y", "zn-gate", "mcp"] } } }. OpenCode (~/.config/opencode/opencode.json): { "mcp": { "zn-gate": { "type": "local", "command": ["npx", "-y", "zn-gate", "mcp"], "enabled": true } } }.
Wrap the MCP servers you already use
init finds MCP servers in your agent config files, writes a backup, and wraps each local (stdio) server with zn-gate shield:
npx -y zn-gate init --dry-run # preview, changes nothing
npx -y zn-gate init --wrap-mcp # wrap (a .bak.<timestamp> copy is written first)
npx -y zn-gate init --shadow # log detections without blocking
npx -y zn-gate init --revert # put back the MCP configs saved before wrapping (not hooks or the plugin)
| Agent | File | Format |
|---|---|---|
| Claude Desktop | claude_desktop_config.json (macOS ~/Library/Application Support/Claude/, Windows %APPDATA%\Claude\, Linux ~/.config/Claude/) |
mcpServers JSON |
| Claude Code | ~/.claude.json (user scope) |
mcpServers JSON |
| Cursor | ~/.cursor/mcp.json |
mcpServers JSON |
| Codex CLI | ~/.codex/config.toml (or $CODEX_HOME/config.toml) |
[mcp_servers.<name>] TOML |
| OpenCode | ~/.config/opencode/opencode.json |
mcp JSON, command array |
| Antigravity | ~/.gemini/antigravity/mcp_config.json (Google's MCP guides) and ~/.gemini/config/mcp_config.json (shared settings, used by some setups); each one only if it exists |
mcpServers JSON |
| Hermes / PiAgent | ~/.hermes/mcp.json |
mcpServers JSON (path not verified against official docs) |
Remote (URL) servers are left as they are. init never rewrites a file it cannot round-trip safely: OpenCode JSONC files with comments and Codex entries with multi-line args are reported as "wrap manually".
To wrap a single server by hand:
npx -y zn-gate shield -- uvx mcp-server-fetch
See what zn-gate did
npx -y zn-gate report
A short summary of the last 7 days on this computer: blocked actions, secrets hidden, new protected MCP servers and tool changes waiting for your approval. It reads only local files, needs no account and sends nothing. --since 30d changes the period, --json prints it for scripts. What it shows.
Turn on the optional cloud check
npx -y zn-gate connect
Optional, and you do it yourself in your own terminal (an agent cannot). It opens usezn.com so you can create an analysis-only API key (it cannot read your usage or manage keys), then asks you to paste it at a hidden prompt. A full-access key is refused. The key is kept in your system keychain (or the zn vault when there is no keychain), never written to a file, and zn's hooks refuse the direct ways for your agent to read it. After that, the text you or your agent send through analyze_prompt, with detected secrets removed first, is also checked by the Galvanize 3 classifier at usezn.com. Until you run it, nothing is sent. zn-gate disconnect removes the key from this computer and asks whether to revoke it on usezn.com too (default no). How it works.
Check that it works
npx -y zn-gate check
For each agent set up for your user, zn-gate asks its hook to let the agent read a .env file with a fake key and an ordinary file, in a temporary folder. It shows what your agent would be told, and a line that says NOT protected says how to fix it. Nothing is sent over the network and no setting changes. What the output means.
npx -y zn-gate test
This runs the local self-test (51 curated vectors: 26 attacks, 25 benign) and shows per-decision latency on your machine. It is a smoke test, not a detection rate. Nothing is sent over the network.
For developers: see the redaction by hand. 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, and look for sanitized_content in the output; that field is what the model would see. In the full output, verdict: allow only means that no prompt injection was found; the secrets are hidden in sanitized_content (here [REDACTED_AWS_KEY] and [REDACTED_DB_PASSWORD]), and secrets_redacted counts them:
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
Example: protect the tools of a Vercel AI SDK agent.
What each piece does
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 (
check_tool_result,check_tool_call, and output of servers wrapped byshield/init). - Today, agent hooks and vault: 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 rungives a value (as an environment variable) only to commands you approved; personal data (cards, IBAN, national IDs, e-mail, phone) is detected too. What each agent allows differs: see compat.md.
Galvanize: prompt-injection detection
- Today, local: a deterministic rules engine with normalization against homoglyphs, zero-width characters, BiDi overrides (CVE-2021-42574), comment splicing and Base64. It checks prompts, tool arguments, tool output and MCP tool descriptions.
- Today, optional cloud: the Galvanize 3 classifier (open weights on Hugging Face; announcement; the previous model, Galvanize 2, also has open weights under Apache-2.0) can also check prompts sent to
analyze_prompt, only withZN_CLOUD=1andZN_API_KEY. The secrets zn-gate detects are removed before sending; personal data and a secret it does not recognize are sent as written. - Roadmap: running Galvanize locally inside zn-gate.
Scan: audit what your agent is about to trust
- Today:
npx -y zn-gate scan <path>audits prompt templates,AGENTS.md/SKILL.mdfiles and configs for injection traps and leaked secrets. It exits with code 1 on findings, for CI. A link given as the folder to scan is followed. When no file is scanned, the report says "No files were scanned in " and the exit code is 3. A file or folder that could not be read (for example a file of 2 MiB or larger) is listed and also makes the exit code 3, unless you pass--allow-partial. It also checks the MCP server configs (.mcp.json,.cursor/mcp.json,.vscode/mcp.json,.codex/config.toml,claude_desktop_config.jsonand others) for keys and passwords written in plain text inenv,headers, arguments or URLs; it never prints the value, and--include-homechecks your own MCP configs too. MCP servers can be checked on the web at usezn.com/scan. - Roadmap: auditing MCP servers and skills from the CLI before you add them.
MCP tools
| Tool | Phase | What it does | Network |
|---|---|---|---|
analyze_prompt |
Before the LLM | Checks a prompt for injection, jailbreak and exfiltration patterns. | Only with ZN_CLOUD=1 + key, redacted |
check_tool_call |
Before execution | Checks tool name and arguments; returns sanitized_arguments with secrets masked. |
Never |
check_tool_result |
Before ingestion | Checks tool output for indirect injection; returns it with secrets redacted, or neutralized if blocked. | Never |
zn_status |
Any | Engine, rules version, and what (if anything) leaves the machine. | Never |
What leaves your machine
Nothing, by default.
| 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 |
Counts of what zn-gate did (zn-gate stats: checks, blocks, secrets replaced, per secret type) |
Written locally to ~/.zn/stats.json |
Never, unless you turn on zn-gate stats share on: then, each time you run zn-gate stats, one report per complete day (at most the last 3 days) with a random installation id, the day, the zn-gate, OS and Node.js versions, the agent and part of zn-gate used most, and the number of secrets found per built-in type (never values, prompts, variable or secret names, paths, hosts or emails). zn-gate stats share show shows it first. |
Prompts (analyze_prompt, zn-gate analyze) |
Locally | Only if you set both ZN_CLOUD=1 and ZN_API_KEY, run zn-gate connect yourself, or use the API key option of the Claude Code plugin (for analyze_prompt only). Detected secrets are removed locally before sending. Personal data, and any secret zn-gate does not recognize, is sent as written. |
Team audit trail (~/.zn/audit.jsonl) |
Written locally | Only on a machine joined to a Team organization with zn team join: while the vault is unlocked, the vault daemon syncs a few seconds after zn unlock and then every 15 minutes, and uploads audit metadata only (time, secret name, how it was used, agent, tool, command name, host, decision and its reason, written since you joined; earlier records only with zn team join --include-history) to your organization. Never secret values, prompts, file contents or tool output. See zn Team. |
Secret values in the vault (secrets_http_request, zn run) |
Encrypted locally | Never to zn. zn gives a value only to a program you allowed (zn run, in its environment) or puts it into a request the agent asks for, and only to hosts you allowed for that secret (headers only by default). What an allowed program does with it is up to that program (limits). |
zn-gate connect and zn-gate disconnect |
Locally | Only when you run them yourself in your own terminal. They send only the API key, to api.usezn.com: to check it (/prod/usage) and, with disconnect --revoke or when you say yes, to revoke it (/prod/keys/self). |
If the cloud call fails (no connection, a timeout, an error from the service, or a saved key that cannot be read), the prompt is checked by the local rules alone and the result says fallback: true. The check does not fail closed: a prompt the local rules allow goes through. ZN_API_KEY alone enables nothing. zn-gate connect is the other way to opt in: you run it, in your own terminal, and it keeps the key in your system keychain or the zn vault, never in a file (zn-gate disconnect undoes it and can revoke the key on usezn.com when you say yes; details). ZN_LOCAL_ONLY=true (or --local-only) overrides ZN_CLOUD=1 and a connected key. npx -y zn-gate status shows the active detection engine and whether the optional cloud check is on. Sharing of usage statistics is off by default and has its own status: npx -y zn-gate stats share status. Data-flow diagrams: repository README.
1.4.0 and earlier: with
ZN_API_KEYset, tool output and tool-call arguments not blocked locally were sent toapi.usezn.comwithout redaction. 1.4.1 removes that path. See the CHANGELOG.
zn-gate MCP questions
How do I add zn-gate MCP to Claude Code?
Run claude mcp add --env 'ZN_API_KEY=<YOUR_ZN_API_KEY>' zn-gate -- npx -y zn-gate mcp in your terminal. Add --scope user to make it available in every project.
How do I add zn-gate MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
What tools does zn-gate MCP provide?
It exposes 4 tools, including analyze_prompt, check_tool_call, check_tool_result, zn_status.
Does zn-gate require an account or internet connection?
No, it runs locally on your machine with no account or network required by default.
How can I protect my .env files from being read by AI agents?
You can use the 'env shadow' command to move real values into an encrypted local vault and leave markers in the file instead.
Can I use zn-gate with editors like VS Code or Zed?
Yes, for these editors, zn-gate works as an MCP server.
What happens if I want to remove zn-gate?
You can run the uninstall command which will show you what it will remove and ask for confirmation first.