Export a policy pack to Docker MCP Gateway
Last updated 15 November 2026
For platform teams that run MCP servers behind Docker MCP Gateway. At the end you will have exported a policy pack as a guard for the gateway's interceptors, built a gateway image that runs it, and know what it denies, which transports it works with, what it does with input it cannot read, and why it is pinned to one gateway release.
What the export is
Docker MCP Gateway documents a list of tools to enable and some on and off switches, but no rule that denies a tool by name. The one way it can deny a call by a pattern is an interceptor: a program the gateway runs before each tool call and after each result. The Docker MCP Gateway export is such a program, a Python guard with the pack's checks compiled in, with a Dockerfile, an example service and the flags to run it.
Docker describes what an interceptor receives only in an examples README, not in its documentation. The export is therefore pinned to one release, Docker MCP Gateway v0.44.3, and Spellwarden's release workflow runs that gateway with the guard at every engine release before it publishes. A later gateway release may change what an interceptor receives; an export is checked against it only by a later engine release.
The target is new in scanner 1.15.0, the engine that builds every export, and it is on the same plans as the other export targets. Rules, policy packs and exports compares the five targets.
Download the export
- On the Policy packs page, open the pack and find the version in the Versions list. Only a published version can be exported.
- Choose Export, then Docker MCP Gateway. The dialog says: A guard for the gateway's interceptors, with a Dockerfile. The README in the download says how to run it.
- Choose Download the export. The download is a zip named for the pack, the version and the target, with the guard marked executable.
Owners, managers and members can export. Spellwarden keeps an export for 30 days, and an organisation can build 100 exports an hour. A script can build the same export with a write key, and Claude with the connector's tool export_policy_pack, with the target docker-mcp-gateway:
curl -X POST -H "x-api-key: $SPELLWARDEN_API_KEY" -H "content-type: application/json" \
-d '{"target": "docker-mcp-gateway"}' \
https://dash.spellwarden.ai/api/v1/orgs/<your-organisation>/policy-packs/baseline/versions/1.0/exportsThe files
| File | What it holds |
|---|---|
docker-mcp-gateway/spellwarden_gateway_guard.py | The guard: Python 3.8 or newer, its standard library only, run as python3 -I. |
docker-mcp-gateway/Dockerfile | Adds Python 3 to the pinned docker/mcp-gateway v0.44.3 image and copies the guard read-only. |
docker-mcp-gateway/compose.yaml | An example service built from that Dockerfile, with the two interceptor flags. |
docker-mcp-gateway/gateway-flags.txt | The two flags for docker mcp gateway run on a host that has Python 3. |
SPELLWARDEN-README.md | What the export enforces, what it cannot enforce and why, how to install it and its limits. It ends with: Validate field names against the vendor's current documentation before use, and a link back to this guide. |
SHA256SUMS | The SHA-256 of the other five files. |
The Dockerfile pins the gateway image by its digest:
# Spellwarden policy export for Docker MCP Gateway v0.44.3: the pinned image, Python 3 and the guard.
FROM docker/mcp-gateway:v0.44.3@sha256:bae58d801fd4b73f6ad91e609b8ce5ec8868713825f33a2bb20a98f956d0bd46
RUN apk add --no-cache python3
COPY --chmod=0444 spellwarden_gateway_guard.py /opt/spellwarden/spellwarden_gateway_guard.pyRun the gateway with the guard
- Check the files against SHA256SUMS.
- Build the image from the Dockerfile. To use your own gateway image instead, add python3 to it and copy the guard into it.
- Start the gateway with the two interceptor flags. The example service shows them in place; replace duckduckgo with your servers:
# Spellwarden policy export for Docker MCP Gateway v0.44.3: an example service.
# Replace duckduckgo with your servers.
services:
gateway:
build: .
command:
- --transport=sse
- --port=8811
- --servers=duckduckgo
- --interceptor=before:exec:python3 -I /opt/spellwarden/spellwarden_gateway_guard.py before
- --interceptor=after:exec:python3 -I /opt/spellwarden/spellwarden_gateway_guard.py after
ports:
- "127.0.0.1:8811:8811"
volumes:
- /var/run/docker.sock:/var/run/docker.sockFor docker mcp gateway run on a host that has Python 3, add the two flags of gateway-flags.txt and replace /path/to with the directory of the guard:
--interceptor=before:exec:python3 -I /path/to/spellwarden_gateway_guard.py before
--interceptor=after:exec:python3 -I /path/to/spellwarden_gateway_guard.py after- Keep --block-secrets on, as it is by default.
- Connect your clients over SSE, at http://127.0.0.1:8811/sse for the example, or run the gateway over stdio.
- The example publishes the gateway on the loopback address only, because it mounts the Docker socket. Before you publish it on another address, put authentication or network isolation in front of it.
Transports: SSE and stdio only
Run the gateway with --transport=sse or over stdio. With --transport=streaming, Docker MCP Gateway v0.44.3 cannot hand a tool call to an interceptor that runs before the call, and it fails every tool call. Nothing passes, so a gateway started that way is closed, never open, but of no use. The export's README says the same under Limits.
What it enforces and what it cannot
For each of the eight enforcement rules of a pack that has the rule on, the export's README says one of these:
| Rule | In this export | Why |
|---|---|---|
| SW-HK-001 | Not enforced | Enforced by the Claude Code hooks export. |
| SW-HK-002 | Not enforced | Enforced by the Claude Code hooks export. |
| SW-GW-003 | Not enforced | A remote server's OAuth is set per server in the gateway's catalog, not by this export. |
| SW-GW-004 | Enforced | On tool results: a result that holds an injection pattern is replaced by an error result. |
| SW-EG-005 | Not enforced | A sandbox egress proxy is not in this version. |
| SW-GW-006 | Enforced | Denied: the gateway cannot ask a person, so a destructive tool is refused instead of asked about. |
| SW-RG-007 | Not enforced | Enforced by the private registry, not by an export. |
| SW-OB-008 | Not enforced | The gateway's call log records tool names, not a protected audit trail. |
Organisation rules are not included in this export.
How the guard decides
- Before a call, the guard reads the tool's name. A name that starts with one of the verbs delete, drop, destroy, remove, purge, truncate, terminate, wipe, reset and force, or holds one as a word between underscores or hyphens, in any letter case, is answered with an error result that names the pack and SW-GW-006. Any other call goes on unchanged.
- After a call, the guard reads the text of every content item of the result that a model may read, embedded resources included, and the strings of its structured content. Only the binary data of images, audio and resources is left out, and a content type the guard does not know is read whole. It removes invisible characters, normalises the text to NFKC and checks it against the nine injection patterns of SW-GW-004. A result that matches is replaced by an error result. Prompts are not checked.
- The guard fails closed. A request or a result larger than 1 MiB, one that is not JSON, or a request that names no tool is answered with an error result instead of going on.
- An interceptor that fails, including a gateway image without python3, fails the tool call.
- The guard writes one line on standard error when it blocks, with the rule and the tool name. It never writes an argument or a result.
A blocked call is answered like this, for the baseline pack:
{"content": [{"type": "text", "text": "Spellwarden policy Spellwarden Baseline for Agents 1.0 blocked the tool delete_order: SW-GW-006 asks a person to approve destructive tools, and this gateway cannot ask."}], "isError": true}Limits
- The export is checked against Docker MCP Gateway v0.44.3 only. Before each engine release, the release workflow builds the export's Dockerfile, runs it in front of a test server and checks that a destructive tool is refused, an allowed tool answers and a result carrying an injection phrase is replaced.
- A later gateway release may change what an interceptor receives. Until an engine release has been checked against it, keep the pinned image.
- The gateway image must carry Python 3, and the gateway must run over SSE or stdio.
- SW-GW-006 asks a person to approve destructive tools. The gateway cannot ask, so the guard denies them.