Require human approval at the MCP gate
Human in the loop, enforced outside the agent. Name a tool, and its calls that pass through the gate wait there until a person decides. The agent holds neither the terminal nor the approver's key.
On this page
- What you'll get
- Why the gate is outside the agent
- 011. Route the MCP server through the gate
- 022. Create the approver key
- 033. Name the calls that wait
- 044. Decide what silence means
- 055. Add a signed decision endpoint (optional)
- 066. Run, and answer the prompt
- 077. Check the decisions afterwards
- What this enforces, and what it doesn't
- FAQ
- Can the agent approve its own call?
- Can I approve from my phone or a chat app?
- Can I gate only some arguments, such as payments over a threshold?
- What happens when the approver is away?
Note
Release status
The current source and its signed releases aren't public yet. More in Project status.
What you'll getLink to this section
- Name a tool, and its calls that pass through the gate wait until a person approves or denies them, at the terminal where
constle runis running or with a signed decision from your own endpoint. - By default, no answer means no: gated calls that pass through the gate and get no answer are refused, and the run stops.
- Gate openings and decisions go into the audit log, and signed decisions can be re-verified later against the approver's key.
Why the gate is outside the agentLink to this section
An approval prompt the agent controls is an approval the agent can be talked out of asking for. Constle never passes your MCP servers' real addresses into the sandbox: the agent reaches them through the gate, and approvals apply to calls that pass through the gate. Traffic to hosts you allow isn't gated. If an allowed host shares a server with an MCP server, a request can reach that MCP server past the gate (limitation 2). The policy that names the gated tools is read once, before the sandbox starts. Constle passes neither the approver's private key nor the address of your decision endpoint into the sandbox. The mechanics: Human gates.
1. Route the MCP server through the gateLink to this section
mcp:
servers:
- id: accounting
url: https://mcp.accounting.internal # host side only; never passed into the sandbox
tools: [list_invoices, pay_invoice]A gate can only hold calls that pass through the gate, and those are calls to the servers declared here. With no mcp.servers declared, nothing is gated. The agent reaches this server through CONSTLE_MCP_ACCOUNTING_URL. Setting that up is covered in MCP tool allowlists.
2. Create the approver keyLink to this section
constle webhook-keygen approverThis keypair is not an agent identity: it authenticates the person deciding, not the agent asking. Constle never passes its private key into the sandbox. You give it to whoever operates your decision endpoint. The command prints a did:key to paste into the Agentfile. human_gates.approver_pubkey is required whenever require_approval_for lists a tool, even if you will only ever approve at the terminal.
3. Name the calls that waitLink to this section
human_gates:
enabled: true # the master switch; required whenever you list gated tools
require_approval_for:
- pay_invoice # the exact MCP tool name
approver_pubkey: did:key:z6Mk… # from `constle webhook-keygen`Entries are exact, case-sensitive tool names: the params.name of a tools/call. There are no patterns and no semantic matching, so the entry pay_invoice holds only pay_invoice calls that pass through the gate. A call whose name differs from a gated one only in case is refused rather than forwarded ungated. validate and run warn about any entry that provably matches no declared tool, and about every entry when enabled: false is written. An Agentfile whose entries have no enabled key is refused.
4. Decide what silence meansLink to this section
human_gates:
approval_timeout_seconds: 300 # the default
on_timeout: abort # the default: refuse the call and stop the runon_timeout decides every gate that reaches its deadline without a decision, which includes an unreachable or broken decision endpoint. Keep abort. Under proceed, gated calls that pass through the gate and get no decision in time are forwarded without approval, so the gate becomes a delay.
When the input of constle run is not a terminal (CI, a pipe, a background job), nobody can answer the prompt: each gate shows the call, says it cannot prompt, and waits for its deadline. Nobody watching is never read as a yes. on_timeout decides.
5. Add a signed decision endpoint (optional)Link to this section
human_gates:
notify:
- channel: webhook
url_secret_ref: HUMAN_GATE_WEBHOOK_URL # the host variable holding the URLWith approver_pubkey set and this URL resolving, gated calls that pass through the gate also go to your endpoint: Constle POSTs each request there and polls it for a decision, racing the terminal prompt, and the first decision wins. A decision must be Ed25519-signed by the approver key over the request id, the decision and the digest of the exact tool call. One that fails any check counts as a denial. Your endpoint can put the request in front of a person however you like, as long as it signs their answer with the approver key.
Without a resolving URL, constle run warns that gated calls will only be decided at the terminal.
6. Run, and answer the promptLink to this section
export HUMAN_GATE_WEBHOOK_URL=https://approvals.example.internal/gates # if you set up step 5
constle run agent.yamlWhen the agent calls pay_invoice, the call waits at the gate, and the terminal shows the prompt (abridged: the subject digest is shortened):
⏸ human gate: agent "invoice-processor" wants to call MCP tool "pay_invoice" on server "accounting"
subject: sha256:4b3f…e91a
arguments (25 bytes, 3 lines) — shown in full:
{
"invoice_id": "INV-0042"
}
approve? [a]pprove / [d]eny (timeout 300s → abort):Over the prompt's display limits (4 KiB of arguments, 200 lines, or 16 KiB of rendered text), the terminal shows the reason instead of the arguments, and the call can only be denied there. A webhook approver can still approve it. A terminal approval is an unsigned local action, recorded with decided_by: terminal. A line typed at the terminal before a prompt appears can answer it, so answer a prompt only after reading it (limitation 9).
7. Check the decisions afterwardsLink to this section
grep gate_ ~/.constle/logs/<agent>-$(date -u +%F).jsonl
constle audit verify --agentfile=agent.yaml ~/.constle/logs/<agent>-$(date -u +%F).jsonlEach gate writes gate_triggered, then gate_approved, gate_denied or gate_timeout. A webhook decision that fails a check is written as gate_signature_invalid, gate_digest_mismatch or gate_request_id_mismatch, and the call is denied. A decision received over the webhook is recorded with its signed fields, and audit verify --agentfile re-verifies it against the Agentfile's approver_pubkey, so a webhook approval the approver never signed fails verification. More in Verify an AI agent's audit log.
What this enforces, and what it doesn'tLink to this section
| Enforced | Not covered |
|---|---|
A gated tools/call waits for a decision, and with the default on_timeout: abort, gated calls that pass through the gate reach their server only after an approval. |
Traffic to hosts you allow isn't gated. If an allowed host shares a server with an MCP server, a request can reach that MCP server past the gate. Nor does the gate see an MCP server run inside the image, or file writes. |
| Exact tool-name matching, with case variants of a gated name refused. | Rules on arguments: a gate holds a gated tool's calls that pass through the gate, whatever their arguments. |
| A decision that arrives is verified, and one that fails any check is a denial. | Key rotation or revocation: a compromised approver key stays valid until the Agentfile changes. |
With the default on_timeout: abort, gated calls that pass through the gate and get no answer are refused. |
One approver per agent, with no M-of-N. |
| Signed decisions are recorded and can be re-verified. | A terminal approval signs nothing, and a line typed ahead can answer a later prompt. The subject digest is unsalted SHA-256, so guessable arguments can be recovered from the log. |
Gates match tool names only: limitation 1. The full list of limits of the signed channel is on Human gates.
FAQLink to this section
Can the agent approve its own call?Link to this section
Not for calls that pass through the gate. The terminal prompt is on the host where constle run runs, and a webhook decision has to be signed with the approver's private key, which Constle never passes into the sandbox. The webhook URL is read from a host variable and is not passed to the agent either. A request that reaches an MCP server past the gate, through an allowed host, needs no approval at all (limitation 2).
Can I approve from my phone or a chat app?Link to this section
Yes, if your decision endpoint does it. For gated calls that pass through the gate, Constle POSTs each request to your endpoint and polls for a decision. What happens in between is up to you, provided the answer comes back signed with the approver key. Constle does not ship such an endpoint.
Can I gate only some arguments, such as payments over a threshold?Link to this section
No. The gate matches the tool name only, so a gated tool's calls that pass through the gate all wait, whatever their arguments. If you need a threshold, have the MCP server expose two tools, enforce the limit itself on the one for small amounts, and gate the other.
What happens when the approver is away?Link to this section
With the defaults, the call waits 300 seconds, is then refused, and the run stops with a gate_timeout event. No gated calls that pass through the gate are forwarded without a decision unless you chose on_timeout: proceed.