Docs menuMCP gateway

Docs Integrations

MCP gateway

Check every MCP tool call against your Runback policies before the server runs it. One change to your MCP client's config, no change to the agent or the server. About ten minutes.

The MCP gateway sits between your agent and an MCP server. Your MCP client starts the gateway, and the gateway starts the real server. Before any tool call reaches the server, the gateway asks Runback whether it may run.

  • Allowed: the call goes to the server unchanged.
  • Blocked: the server never sees it. The agent gets an error result that names the rule.
  • Needs approval: Runback asks a reviewer, by email, Slack or Teams as for any held call. The call waits, then runs or is blocked.

Every decision is recorded and signed in your workspace's ledger as decided by Runback (MCP proxy).

tools/call resultJSON
{
  "content": [
    {
      "type": "text",
      "text": "Blocked by Runback (rule: no-large-refunds): refunds over 1000 are blocked"
    }
  ],
  "isError": true,
  "_meta": {
    "runback.dev/decision": {
      "decision": "deny",
      "rule": "no-large-refunds",
      "decision_id": "7f1c2a9e-3b4d-4e5f-8a6b-0c1d2e3f4a5b"
    }
  }
}

The agent reads this like any failed tool call: it sees the rule and can change course. Nothing else in the conversation changes.

Before you begin

  • Node.js 22 or later, with npm. Check with node --version.
  • A Runback API key, the same kind an SDK uses, and a policy assigned to the agent name you will use. See Control.
  • An MCP client that starts servers over stdio, such as Claude Desktop, Claude Code or Cursor.

Steps

  1. Check the gateway runs

    There is nothing to install: npx fetches the gateway from npm the first time it runs.

    terminalShell
    npx -y @runback/gateway mcp --help
    Expected output
    usage: runback-gateway mcp [options] -- <MCP server command> [args…], then the options below.
  2. Wrap the server in your client's config

    Find the server in your MCP client's config. Move its command to the end of args, after --, and make npx the command, with -y @runback/gateway mcp first in args. Keep the -y: your client starts the gateway without a terminal, so npx must not stop to ask before installing it.

    --agent is the agent name your policy assignments use. The key goes in env. The gateway does not pass it on to the server.

    MCP client configJSON
    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": [
            "-y", "@runback/gateway", "mcp",
            "--agent", "files-agent",
            "--",
            "npx", "-y", "@modelcontextprotocol/server-filesystem", "/Users/you/Documents"
          ],
          "env": {
            "RUNBACK_API_KEY": "<RUNBACK_API_KEY>"
          }
        }
      }
    }
    Expected output
    Restart your client. The server's tools are listed as before.
  3. Make a call your policy blocks

    Ask the agent to do something one of your rules forbids.

    Expected output
    The tool call fails with Blocked by Runback (rule: …). The server never received it.

Options

Put options before --. Everything after -- is the server's command, passed on as written.

OptionWhat it doesDefault
--agent NAMEThe agent name your policy assignments are keyed by.mcp-gateway
--base-url URLWhere Runback is.RUNBACK_INGEST_URL; otherwise runback.dev for an rb_cloud_ key, or http://localhost:3000
--fail-openRun calls when Runback cannot be reached.Off: they are blocked
--hold-seconds NHow long a call waits for a reviewer before the agent is told it is held.50
--timeout-ms NHow long to wait for each decision.5000
--run-id IDThe run decisions and approvals are tied to.A new one each time the gateway starts
--redact strictRemove more from arguments before they are sent.standard

When a call needs approval

The gateway waits up to --hold-seconds for a reviewer. If they approve, the call runs. If they reject it, or the approval expires, it is blocked.

If nobody has decided in time, the agent gets a result that starts Held by Runback and names the approval. MCP clients stop waiting for a call after a time limit, so the gateway answers first. When the agent makes the same call again, with the same arguments, the gateway presents the same approval rather than asking again. Once approved, that call runs once.

An approval belongs to the call it was asked for. If another call differs only in arguments that redaction removed, such as a different email address, it is blocked while the first one waits, never approved along with it.

When Runback cannot be reached

By default the gateway fails closed: if Runback does not answer, the call is blocked with runback_unreachable. With --fail-open the call runs instead, and the gateway prints a warning. A call that runs this way is not checked and not recorded.

When the gateway starts, it asks Runback for the agent's fail mode. If the policy assignment fails closed, --fail-open is ignored. The flag only applies on its own if Runback has not answered once since the gateway started.

--fail-open never lets a call through when Runback answers and refuses the request, for example with a wrong key.

What Runback sees

Arguments are redacted on your machine before they are sent, with the same redaction library the SDKs use. Your policies, and your reviewers, see the redacted arguments. The server still gets the arguments exactly as the agent sent them.

Only tool calls are checked. Everything else, such as listing tools or reading resources, passes straight through and is not sent to Runback.

Troubleshooting

You seeWhat it meansFix
Every call fails with decide_rejectedRunback refused the request, usually because the key is missing or wrong.Check RUNBACK_API_KEY in the server's env in your client config.
Every call fails with runback_unreachableThe gateway could not reach Runback.Check --base-url. A self-hosted Runback needs it set.
Calls are allowed that your policy should blockThe policy is assigned to a different agent name.Make --agent match the assignment, or assign the policy to *.
missing the server commandNothing after --.Put the server's command and its arguments after --.

What it does not do

  • It works with servers your client starts over stdio. Servers reached over HTTP (Streamable HTTP) are not supported yet.
  • A tool call sent inside a JSON-RPC batch is refused, not split up. MCP clients send calls one at a time.
  • It does not record the run itself, only the decisions. To record runs, use an SDK or OpenTelemetry.

Next steps

  • Write and assign the rules the gateway enforces: Control.
  • Check a decision's seal yourself: Evidence.
Last updated 19 Nov 2026.