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).
{
"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
Check the gateway runs
There is nothing to install:
npxfetches the gateway from npm the first time it runs.terminalShell npx -y @runback/gateway mcp --helpExpected outputusage: runback-gateway mcp [options] -- <MCP server command> [args…], then the options below.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 makenpxthe command, with-y @runback/gateway mcpfirst inargs. Keep the-y: your client starts the gateway without a terminal, sonpxmust not stop to ask before installing it.--agentis the agent name your policy assignments use. The key goes inenv. 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 outputRestart your client. The server's tools are listed as before.Make a call your policy blocks
Ask the agent to do something one of your rules forbids.
Expected outputThe tool call fails withBlocked by Runback (rule: …). The server never received it.
Options
Put options before --. Everything after -- is the server's command, passed on as written.
| Option | What it does | Default |
|---|---|---|
--agent NAME | The agent name your policy assignments are keyed by. | mcp-gateway |
--base-url URL | Where Runback is. | RUNBACK_INGEST_URL; otherwise runback.dev for an rb_cloud_ key, or http://localhost:3000 |
--fail-open | Run calls when Runback cannot be reached. | Off: they are blocked |
--hold-seconds N | How long a call waits for a reviewer before the agent is told it is held. | 50 |
--timeout-ms N | How long to wait for each decision. | 5000 |
--run-id ID | The run decisions and approvals are tied to. | A new one each time the gateway starts |
--redact strict | Remove 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 see | What it means | Fix |
|---|---|---|
Every call fails with decide_rejected | Runback 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_unreachable | The gateway could not reach Runback. | Check --base-url. A self-hosted Runback needs it set. |
| Calls are allowed that your policy should block | The policy is assigned to a different agent name. | Make --agent match the assignment, or assign the policy to *. |
missing the server command | Nothing 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.