
SafeNode MCP Gateway
io.github.sp3ak由 GitHub 帳號 sp3ak 發布v0.1.2更新於 Oct 24, 2026
Policy proxy for MCP tool calls. A denied call never reaches the downstream server.
概覽
一個本機 MCP 代理,在把每次工具呼叫轉送給下游 MCP 伺服器之前,先向 SafeNode 政策 API 請求判定。
- 可以做什麼
- SafeNode MCP Gateway 位於 MCP 用戶端與你原本使用的伺服器之間。tools/list 原樣透傳,但每次 tools/call 都會先交給 SafeNode API 評估,回傳 allow、warn、review 或 deny。被拒絕或標記為待審核的呼叫不會到達下游伺服器;拒絕會以工具錯誤形式回傳,並附上原因與 trace id。它也能在送出前對工具參數做去識別化或只送中繼資料,並寫出本機 JSONL 決策日誌。
- 適用情境
- 當你希望在能寫檔案、執行 shell 指令或涉及付款的 MCP 工具前加一層政策,而且要求模型無法藉由選擇不呼叫某個工具來繞過時,適合使用。它不是沙箱,也不是提示注入偵測器,且無法離線運作。
- 執行需求
- 需要 Node.js 18 或更新版本,透過 npx 或 Docker 在本機執行(Docker 需掛載 stdin)。需要在 SAFENODE_API_KEY 環境變數中提供 SafeNode API 金鑰(有免費額度),需要一份列出下游 MCP 伺服器的 JSON 設定,而且每次受管控的呼叫都需要連線到 SafeNode API。可用 SAFENODE_BASE_URL 覆寫 API 基礎位址。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 SafeNode MCP Gateway,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
SafeNode MCP Gateway
An MCP proxy that enforces policy on every tool call. The agent cannot route around it.
Why a proxy
An MCP server that exposes an evaluate_action tool is theatre. The model can choose not to call
it, which means it enforces nothing.
This is a proxy. It sits between your MCP client (Claude Desktop, Claude Code, Cursor, any MCP
host) and the MCP servers you already use. tools/list passes straight through, so the model sees
exactly the tools it saw before. Every tools/call is evaluated against SafeNode first. A denial
means the call never reaches the downstream server at all.
Your agent needs no code changes. It does not know the gateway is there.
Get an API key — free tier, no card · Docs · Python SDK
Setup
1. Get an API key
Free at safenode.tech. Keys look like sn_....
2. Write a config
safenode-gateway.json — take the servers straight out of your existing MCP client config:
Do not put your API key in this file. Set SAFENODE_API_KEY in the environment — it takes
precedence over the config, so the file stays safe to commit.
3. See what would be sent, before sending anything
Prints the exact JSON body that an evaluation would POST. No network call. This is the fastest way to satisfy yourself about what leaves your machine.
4. Point your MCP client at the gateway
Claude Desktop — claude_desktop_config.json:
Claude Code — .mcp.json in your project:
Cursor — ~/.cursor/mcp.json, same shape as Claude Desktop.
Replace your existing server entries with this one. The gateway spawns them itself, so listing them in both places would run each server twice.
What each decision does
Denials come back as MCP tool errors, not transport failures, so the model sees why and can try something else instead of the host surfacing an opaque crash.
Fail behaviour
failMode decides what happens when SafeNode itself is unreachable.
The gateway defaults to fail_closed, unlike the SafeNode SDKs, which default to fail_open.
That difference is deliberate. An SDK wraps a developer's own code, where taking production down
during a SafeNode outage loses the user forever. The gateway fronts arbitrary MCP tools it knows
nothing about — filesystem writes, shell commands, payments — and silently letting all of that
through the moment SafeNode is unreachable defeats the point of installing it.
Loosen it per tool for the read-only ones:
Degraded decisions are logged to stderr and marked "degraded": true with a null traceId in the
decision log, so they can never be counted as real policy decisions.
What data leaves your machine
For every tool call, the gateway sends: the tool name, the downstream server name, a session id, any static context from your config, and the tool arguments as the payload.
payloadMode controls the arguments:
Redaction covers emails, Luhn-validated credit cards, US SSNs, provider API key prefixes (sk-,
ghp_, xoxb-, AKIA, AIza), bearer tokens, and PEM private key blocks. Values become
[REDACTED:<type>].
Why redaction counts are always sent
Alongside the redacted payload, the gateway sends counts of what it removed:
This is load-bearing. SafeNode's server-side sensitive_data rule matches patterns against payload
values. If the gateway scrubbed those values and said nothing, a policy of "deny any action
containing a card number" would silently start passing — the client-side privacy feature would have
disabled the server-side security control. Reporting counts closes that: policy can act on the
presence of a card number without ever receiving one.
If you use sensitive_data with patterns, pair it with a redaction_metadata rule.
These counts are self-reported. They raise the floor for an honest client; they are not a defence against a hostile one.
No telemetry
The gateway talks to exactly two things: the downstream MCP servers you configured, and the SafeNode API. No analytics, no phone-home, no postinstall scripts.
Local decision log
Set logFile to get a JSONL record of every decision, independent of the server-side audit trail —
so you still have evidence of what your agent tried to do when the network was down:
Configuration reference
failMode, payloadMode and context can be set globally, per server, or per tool. Most specific
wins.
tools.<name>.bypass: true skips evaluation entirely for one tool. It does what it says — the call
is forwarded with no policy check at all.
Tool name collisions
If two downstream servers export the same tool name, the gateway prefixes every tool with
<server>__ and logs a warning. Silently picking a winner would apply one server's policy to
another server's tool, which is a security bug rather than a cosmetic one.
What this is not
- Not a sandbox. It decides whether a call is forwarded. It does not contain the downstream server, restrict syscalls, or limit what that server can do once the call reaches it.
- Not a prompt-injection detector. It evaluates the action, not the reasoning that produced it. If your agent has been talked into deleting a table, this can stop the delete — it will not tell you the agent was manipulated.
- Not offline. Every tool call costs a round trip to the SafeNode API. There is no local policy evaluation.
- Not a substitute for scoping the underlying servers. Still pass a filesystem server the narrowest root directory that works.
- Not free of side effects. Every evaluation is recorded server-side and counts against your monthly quota.
Latency
Each gated tool call adds one round trip to the SafeNode API, with a 5000ms budget by default. Bypassed tools add nothing.
A measured p99 for the evaluate endpoint is not published yet, because it has not been measured under realistic load. When it has been, it will go here and in the docs rather than being estimated.
Docker
Running it with no arguments starts against a bundled demo config that proxies an included echo server, so you can see the proxy work without any setup:
The demo key is a placeholder, so tools/list passes through while any real tool call is denied by
the fail_closed policy. For real use, mount your own config and supply a key:
-i is required. MCP speaks JSON-RPC over stdio, so without stdin attached the gateway has nothing
to talk to.
Agent skill
SKILL.md teaches an agent to set
the gateway up for you, moving your existing servers behind it, and how to behave when a call is
blocked or held for review. Copy it into a folder in your agent's skills directory (for Claude Code,
~/.claude/skills/safenode-mcp-gateway/). The policy-authoring companion is in skill/safenode-policies/.
Requirements
Node 18+. One runtime dependency: @modelcontextprotocol/sdk.
Contributing
See CONTRIBUTING.md. Bug reports about enforcement gaps — anything that reaches a downstream server when it should have been blocked — are the most valuable thing you can file.
Security
See SECURITY.md. Please do not open public issues for vulnerabilities.
License
MIT. See LICENSE.
來源:README.md,提交 3497b6d
工具
0版本歷史
1- v0.1.2最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
