SuperAPIAI Directory

safenode-mcp-gateway

github.com · AI developer platforms

Fail-closed policy proxy for MCP tool calls that denies, warns on or holds each call for human approval before forwarding, with client-side redaction.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

SafeNode MCP Gateway is an MCP proxy used to enforce policy on every tool call. Compared with the approach of exposing an evaluate_action tool as an MCP server (the model can choose not to call it, so it does not actually constitute enforcement), this proxy sits between the MCP client and existing MCP servers. tools/list is passed through directly, so the set of tools the model sees remains unchanged; every tools/call is first evaluated by SafeNode, and rejected calls never reach the downstream server at all. Agents using it require no code changes and are not aware of the gateway's existence.

Main capabilities and behavior

  • Policy enforcement: every tool call is evaluated first, and rejections are returned as MCP tool errors rather than transport-layer failures, so the model can see the reason and try other approaches, instead of the host presenting an opaque crash.
  • failMode: determines behavior when SafeNode is unreachable. The gateway defaults to fail_closed, while the SafeNode SDK defaults to fail_open. This difference is intentional: the SDK wraps the developer's own code, whereas in front of the gateway are arbitrary MCP tools it knows nothing about (filesystem writes, shell commands, payments, etc.). Allowing everything when SafeNode is unreachable would defeat the purpose of installing it. It can be relaxed per tool for read-only tools. Degradation decisions are logged to stderr and marked in the decision log as "degraded": true with traceId as null, so they are never counted as real policy decisions.
  • Client-side redaction: payloadMode controls the parameters sent. Redaction covers emails, credit cards that pass the Luhn check, US SSNs, vendor API key prefixes (sk-, ghp_, xoxb-, AKIA, AIza), bearer tokens, and PEM private key blocks, with values becoming [REDACTED:<type>].
  • Redaction counts: while sending the redacted payload, the gateway always sends the counts of what was removed. This point is critical: SafeNode server-side sensitive_data rules match patterns against payload values. If the client erases these values without reporting it, policies such as "reject any operation containing a card number" would quietly start allowing them through—a client privacy feature would instead disable server-side security controls. Reporting the counts compensates for thisOne point: the policy can act on the existence of a card number without receiving the card number. If using sensitive_data with patterns, pair it with redaction_metadata rules. These counts are self-reported and only raise the baseline against honest clients, not a defense against malicious clients.
  • Data egress scope: for each tool call, the gateway sends the tool name, downstream server name, session id, static context from configuration, and the tool arguments as payload. The gateway communicates only with two kinds of parties: the downstream MCP servers you configure and the SafeNode API. No analytics, no callbacks, no postinstall scripts.
  • Local decision log: setting logFile gives a JSONL record of every decision, independent of the server-side audit trail, so that evidence of the agent's attempted behavior is retained even during network outages.
  • Tool name collisions: if two downstream servers export tools with the same name, the gateway prefixes each tool with <server>__ and logs a warning. Silently picking one winner would apply one server's policy to another server's tool, which is a security flaw rather than a cosmetic issue.

Usage

  1. Get an API key: get one for free at safenode.tech; the key looks like sn_....
  2. Write the configuration: safenode-gateway.json, taking the servers directly from your existing MCP client configuration. Do not write the API key into this file; set SAFENODE_API_KEY in the environment, which takes precedence over the configuration, so the file can be safely committed.
  3. Before sending, review what will be sent: print the exact JSON body that the evaluation will POST, without making a network request; this is the fastest way to confirm what is leaving your machine.
  4. Point the MCP client at the gateway: Claude Desktop's claude_desktop_config.json, Claude Code's .mcp.json, Cursor's ~/.cursor/mcp.json (same shape as Claude Desktop). Replace the original server entries with this one; the gateway will launch them itself, and if they are listed in both places, each server will run twice.

Configuration reference: failMode, payloadMode, and context can be set globally, per server, or per tool, with the most specific taking effect. tools.<name>.bypass: true completely skips evaluation for a single tool, and the call will be forwarded directly without any policy check.

Use cases

  • Need to apply a unified security policy to any MCP tool call without modifying the agent code.
  • Need client-side sensitive data redaction while preserving the server-side ability to make policy judgments about the presence of sensitive data.
  • Need to still have local decision records when the network is interrupted.

Limitations and boundaries

  • Not a sandbox: it only decides whether a call is forwarded; it does not isolate the downstream server, does not restrict system calls, and does not restrict what that server can do after receiving the call.
  • Not a prompt injection detector: it evaluates actions, not the reasoning that produces them. If the agent is induced to delete a table, it can block the deletion, but it will not tell you that the agent was manipulated.
  • Not offline: every tool call requires a round trip to the SafeNode API, with no local policy evaluation.
  • Cannot replace scoping limits on the underlying server: you should still pass the smallest usable root directory to the filesystem server.
  • Not side-effect free: every evaluation is recorded by the server and counts toward the monthly quota.
  • Each managed tool call adds one SafeNode API round trip, with a default budget of 5000ms; bypassed tools do not add one. The measured p99 of the evaluate endpoint has not yet been published because it has not yet been measured under real load.

Running and dependencies Running without arguments uses the built-in demo configuration, proxying a bundled echo server, making it easy to observe the proxy working with zero configuration. The demo key is a placeholder, so tools/list is allowed while any real tool call will be rejected by the fail_closed policy. Real use requires mounting your own configuration and providing a key, and -i is required because MCP uses JSON-RPC over stdio, and without stdin the gateway has no way to communicate. Node 18+ is required, and the only runtime dependency is @modelcontextprotocol/sdk. The license is MIT.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools