The gateway

stalwart gateway is an MCP gateway that checks every tool call an agent makes on its way to the tool. The agent connects to the gateway; the gateway connects to your MCP servers.

$ pip install stalwart-agents
$ stalwart gateway --config gateway.yaml
catalogue: ./catalogue.json     # the tools this gateway stands in front of
rules: ./compiled               # your rules: a compiled folder or a rule sheet; none where left out
withdrawn: [delete_repo]        # tools taken out of service: refused before anything else, never listed
settings: {taint_policy: refuse}   # the tool check's own: taint_policy, confirmation_ttl_seconds
upstreams:
  "*": http://tools.internal:8080/mcp
agents:
  desk: ${DESK_TOKEN}
  billing: ${BILLING_TOKEN}
admin_token: ${GATEWAY_ADMIN_TOKEN}
audit: /var/log/stalwart/decisions.jsonl
storage: sqlite:///gateway.db   # the receipts spent, shared by every gateway process
elicitation_timeout: 600        # seconds a person has to answer a confirmation
listen: 0.0.0.0:8800

Every call is checked against the catalogue and rules this file names, with its settings, and the gateway says at start which catalogue it read, how many tools it holds and which are withdrawn. Nothing is read from the console: the file is the gateway's whole configuration. A second set of tools is a second gateway with its own file.

Each agent connects with its own bearer token, so the gateway knows which agent is calling and what it may reach. A receipt admits one call: the gateway keeps the receipts it has spent in storage, in memory where it is not set.

A confirmation not answered within elicitation_timeout seconds (600 by default) is declined, and so is one whose client disconnects first. The session's other calls wait while a person is asked, because the check and its confirmation must see the same history.

The gateway is an enforcement point only if the tools are reachable through it alone. network-policy.yaml is a Kubernetes NetworkPolicy that lets only the gateway reach the tool servers. Apply it, or its equivalent in your network. To put the check in front of your tools from Kong AI Gateway instead, see the Kong recipe.