MCP tool allowlists at the gate
An MCP server can advertise any tool it likes, and an agent will call what it is told to. Constle puts each declared server behind a gate outside the sandbox, where an allowlist of tool names decides which calls go through.
On this page
- What you'll get
- How the gate sits
- 011. Declare the server and its tools
- 022. Point the agent's MCP client at the gate
- 033. Validate
- 044. Run, and see what was refused
- What the gate refuses
- What this does not cover
- FAQ
- Can I allow some tools on a server and require approval for others?
- What does the agent see when a tool is refused?
- Can the agent find the real server URL?
- Does this work with MCP servers that use standard input and output?
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
- Each MCP server you declare reached through a per-run gate. Constle never passes the real server URL into the sandbox.
- A tool allowlist per server: a
tools/callfor anything else is refused at the gate and recorded asmcp_tool_blocked. - Reading resources or prompts refused unless you list it, and any other method the agent sends refused.
- Requests the gate cannot read unambiguously refused before they reach the server, and each forwarded tool call recorded with a start event, and an end event when it finishes before the run ends.
How the gate sitsLink to this section
Constle never passes an MCP server's address into the sandbox. For each server declared under mcp.servers, the agent receives one variable, CONSTLE_MCP_<ID>_URL, pointing at the gate, and the server's host can't be added to allowed_hosts. The tool allowlist, human approval and spend metering apply to calls that pass through the gate: the calls sent to that variable's address. Step by step through one call: Architecture.
Streamable HTTP is the only transport the gate supports: a server's url must be http or https.
1. Declare the server and its toolsLink to this section
mcp:
servers:
- id: issues
url: https://mcp.issues.internal/mcp # host-side only; never passed into the sandbox
tools: [list_issues, create_issue] # every other tool is refused at the gateid: lowercase letters, digits,-and_. It names the variable the agent reads:issuesbecomesCONSTLE_MCP_ISSUES_URL(hyphens become underscores, and the name is uppercased).url: the real endpoint. Its host must not appear inallowed_hosts. An Agentfile that lists it there is rejected, because that entry would let the agent skip the gate.tools: exact tool names. Omit it and every tool passes the gate (a gated tool's calls that pass through the gate still wait for approval). An empty list,tools: [], allows none. List them and a server that grows a new tool cannot have it called through the gate until you add it here.methods: the resource, prompt, completion and logging requests this server may receive, from a fixed list:resources/list,resources/templates/list,resources/read,resources/subscribe,resources/unsubscribe,prompts/list,prompts/get,completion/complete,logging/setLevel. Any other entry fails validation. Tool calls go through the tool checks. The handshake,ping,tools/list, notifications and responses pass. Resource, prompt, completion and logging requests pass only if the server'smethodslist names them, and any other request the agent sends is refused. What the server sends, its own requests and notifications on itsGETstream included, is relayed without method checks. A listed method is forwarded and logged, but not tool-checked, gated or metered.
2. Point the agent's MCP client at the gateLink to this section
Configure the agent's MCP client to use the URL in CONSTLE_MCP_ISSUES_URL as the server's Streamable HTTP endpoint. How you do that depends on the agent or framework: a config file that reads an environment variable, or one line of code. The gate is per run, so read the URL from the environment at run time rather than writing it into the image. Its HTTP client must use the proxy it's given, and it reaches MCP servers at the CONSTLE_MCP_<ID>_URL it's given.
3. ValidateLink to this section
constle validate agent.yamlValidation refuses a duplicate id, two ids that would name the same variable (foo-bar and foo_bar), a tool name with characters outside ASCII letters, digits, _, - and ., a methods entry outside the fixed list, and a server host that also appears in allowed_hosts. The server URL's path is checked when the gate is built, at constle run, before any sandbox starts.
4. Run, and see what was refusedLink to this section
constle run agent.yaml
grep -E 'mcp_|tool_call' ~/.constle/logs/<agent>-$(date -u +%F).jsonl| Event | Written when |
|---|---|
tool_call_start, tool_call_end |
around each tool call forwarded to the server, with the server id, the tool name and the size of the arguments (never the arguments themselves) |
mcp_tool_blocked |
a tools/call names a tool that is not in tools, or differs from a gated tool's name only in case |
mcp_request_blocked |
a request the gate will not forward (below) |
mcp_method_forwarded |
the agent sends a method listed under methods, or a notification MCP doesn't define for a client, and the gate forwards it |
What the gate refusesLink to this section
The gate inspects a copy of each request and forwards the original bytes, so it refuses anything two parsers could read differently:
| Request | Result |
|---|---|
A method other than POST, GET or DELETE |
405 · mcp_request_blocked |
A GET or DELETE with a body |
400 · mcp_request_blocked |
A POST that is not a JSON-RPC 2.0 message |
refused |
| A body with a repeated member, or two members that differ only in case, at any depth | 400 · mcp_request_blocked |
A method that differs from tools/call only in case, or a tool name that differs from a gated or listed one only by case, whitespace or a control character |
refused |
| A path below the declared endpoint, or a query string | refused |
A protocol upgrade (Upgrade header), or a 101 from the server |
400, or 502 for the response |
A JSON-RPC request from the agent other than a tool call, the handshake, ping or tools/list, unless it is a resource, prompt, completion or logging request the server's methods lists |
refused before it reaches the server · mcp_request_blocked |
What this does not coverLink to this section
- The agent still sees every tool's name.
tools/listis forwarded as it is, so the agent can see tools it is not allowed to call, but it can't call them through the gate. Methods you list undermethodsare forwarded and logged, but not gated or metered, so list only what the agent needs. - Contents are not judged. The gate matches tool names. It does not inspect arguments for meaning, and it passes the content of the server's responses, tool descriptions included, back to the agent as it is. A poisoned tool result still reaches the model. What it cannot do is widen the policy.
- Local MCP servers. An MCP server you run inside the agent's own image isn't gated. What it sends out meets the same proxy and allowlist.
- Servers you did not declare. If an MCP server's host is in
allowed_hostsinstead of undermcp.servers, the agent can reach it directly as ordinary HTTPS, past the gate. Declare every remote server you want governed. - Co-hosted names. 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). Keep MCP servers off hosts you allow.
- The server itself. The gate decides which of the calls that pass through it reach a server. What the server then does is up to the server.
More in Known limitations.
FAQLink to this section
Can I allow some tools on a server and require approval for others?Link to this section
Yes. List every tool the agent may call under tools, and name the consequential ones under human_gates.require_approval_for. A listed tool that is not gated is forwarded straight away, while a gated tool's calls that pass through the gate wait for a person. See Require human approval at the MCP gate.
What does the agent see when a tool is refused?Link to this section
The gate answers the call itself, as a JSON-RPC error, and the server never receives it. The refusal is written to the audit log as mcp_tool_blocked with the server id and the tool name.
Can the agent find the real server URL?Link to this section
Not from Constle: it is never passed into the sandbox, and the agent only has the gate's per-run address. A server's own replies can still name it: the gate filters the response headers it relays, not the bodies. Its host is also rejected in allowed_hosts, so it can't be listed as a direct route. Traffic to hosts you allow isn't gated, though. If an allowed host shares a server with an MCP server, a request can reach that MCP server past the gate (limitation 2).
Does this work with MCP servers that use standard input and output?Link to this section
The gate supports Streamable HTTP only. A server that runs as a subprocess inside the image isn't gated. What it sends out meets the same proxy and allowlist.