Skip to main content
A protocol: mcp lane terminates MCP streamable HTTP on /mcp and forwards to one remote MCP server over streamable-http or sse. It hides the tools a rule denies, judges each tools/call with the lane’s guardrails, OPA and AI analyzer, masks tool and resource results, and records one Sidecar session per MCP session. The lane embeds mcpproxy and ships in Sidecar 1.289.0 and later. A Sidecar build without the MCP engine refuses the lane at -validate. Feature coverage shows which part of MCP each feature reads. Limits lists what the lane does not do.

Configure a lane

config.yaml
The MCP client points at http://127.0.0.1:18901/mcp.

Listener keys


Tool allow and deny

A guardrail rule of type mcp_tool decides which tools a lane offers. tools lists the tools it denies; allow lists the only tools it lets through. A rule sets one of the two.
config.yaml
The lane leaves out of tools/list every tool an mcp_tool rule denies, so the model never sees it. The catalog statement names the hidden tools in mcp.tools_hidden. A call to a hidden tool is denied like any rule denial: a tool result with isError: true and the text denied by the hoop sidecar (rule <name>): <message>. MCP reports a failed tool call this way, as a result rather than a JSON-RPC error, so the model sees the denial and its message. A tools/list result the lane cannot read ends the session and records mcp_catalog_unreadable: the lane could neither hide tools from it nor judge it. With action: defer, an mcp_tool rule hides nothing, and OPA decides each call: without OPA, a deferring rule denies the call. Two allow rules let through only the tools both list. A tools/call is judged by its exact name key. Params that name no tool, or carry keys that differ only in case, are refused as invalid params (-32602) and recorded as mcp_invalid_params. Other rule types and OPA judge calls too, and hide nothing. A glob has one metacharacter: * matches any run of characters, including none. Every other character matches literally, and case counts: *delete* matches bulk_delete_rows, and get_* does not match Get_file. The rule reads the real tool name, not the name overrides gives it. An mcp_tool rule in the top-level guardrails reaches every mcp lane, and other lanes ignore it. A lane’s own rules run first and the top-level ones after them; rules: [] on the lane drops the top-level ones. A rule edit applies without a restart and ends the open MCP sessions; the next session gets the new catalog. On a managed sidecar, the Guardrails page of the control plane offers it as the rule type MCP tool on an MCP listener, from version 1.300.0.

mcp_gateway keys

tool_rate_limits globs work as in mcp_tool. Once the session has listed tools, a call to a tool the server did not list is refused too: -32010, tool "x" was not advertised by the server. A call these keys refuse, a truncated result and a rug pull reach the Sidecar session as activities: mcp.tool_denied, mcp.budget_exceeded, mcp.tools_changed. A key the block does not map, such as allowed_tools (an mcp_tool rule instead), approval_tools, command or headers, fails as unknown field.

What the rules read

Each tools/call is one statement: operation: call, tables: [<tool>] in lower case, the text <tool> with its arguments JSON on the next line, and the metadata mcp.method, mcp.tool and mcp.session. A call to a SQL tool adds one statement per SQL statement in its argument.
config.yaml
The metadata names the tool in the audit trail and in OPA’s input. Each tools/list is one catalog statement: direction: server, operation: show, no tables, one <name>: <description> line per tool. Rules and OPA judge the catalog too, and a hit ends the session. A deny_words_list word in a tool description ends it. They read the catalog after overrides: a replaced description is what they see. A table rule never matches the catalog, require_table_match included. Policy Rules describes each rule type.

SQL tools

mcp_gateway.sql names the tools whose calls carry SQL. The lane’s rules then read that SQL as on a SQL lane. Sidecar 1.302.0 and later; older builds refuse the key at -validate.
config.yaml
-validate refuses an entry without a glob, an argument or a known dialect. The lane never guesses the dialect. A call to a SQL tool is 1 + N statements, judged in order: the call statement, then one statement per SQL statement in the argument. The first deny stops the call, and the client gets it as for any rule denial. Each SQL statement carries the SQL as its text, and the operation, effects and tables the lexer reads. What the audit records lists its metadata. mcp_tool rules read only the call statement. A table rule reads the tables of the SQL, and require_table_match denies a SQL statement that names none. Observe mode records all 1 + N. To scope a rule to one tool, use OPA or a metadata rule on mcp.tool. SQL the lexer cannot read is operation: unknown, as on a SQL lane: EXECUTE IMMEDIATE, a script loop or block, EXPORT DATA. A rule must name unknown to refuse it. With googlesql, a script part that starts with LOOP, WHILE, REPEAT, FOR or a BEGIN block, also after a label, is unknown with its writes as effects: a rule naming delete refuses a DELETE in a loop. A bare BEGIN and BEGIN TRANSACTION are not scripts. The lane refuses a call before any rule, also in observe mode, when it cannot read the argument:
  • arguments is absent or not an object.
  • The argument, by its exact name, is absent, not a string, blank or holds no statement.
  • The argument appears two times, also after JSON unescape or in another case.
  • The argument holds invalid UTF-8 or a lone surrogate escape.
  • Two globs of the same length match the tool and disagree.
The client gets denied by the hoop sidecar (rule mcp_gateway.sql): <reason>, and the session records mcp_sql_unreadable. A Sidecar managed by a Control Plane gets sql only when it reports the mcp_sql capability.

OPA

With an opa block, the lane consults OPA on every call and on the catalog. The input for a call, beside the context every lane sends:
responses: false keeps the catalog from OPA:
config.yaml

Masking

The lane masks tool and resource results with its mask rules. It masks these strings of a tools/call, resources/read and tasks/result result:
  • content[].text
  • content[].resource.text, an embedded resource
  • contents[].text
  • every string of structuredContent, up to 128 levels deep
Object keys, numbers and other fields are not masked: the client reads them as protocol. Prompts and upstream error messages are not masked. Sidecar 1.304.0 and later. Older builds refuse a mask block on the lane and do not mask inherited rules.
config.yaml
  • Rules find values by entity. The lane gets each string without its key, so a columns rule never matches. -validate refuses one in the lane’s mask block. An inherited one does not apply on the lane, and -validate says so; inherited entity rules apply.
  • Each masked result is one masked audit row with the count and the entities, never the values.
  • The client gets JSON-RPC error -32010 instead of the result, and the MCP session stays open, when the masker fails, its audit row cannot be written under fail_on_audit_error, a key repeats or differs only in case, structuredContent nests deeper than 128 levels, or the result or a field above has an unexpected type (an object where an array belongs). A null passes.
  • Turning masking on or off needs a restart. A rule change applies without one.
  • A Sidecar managed by a Control Plane gets mask rules on an mcp lane only when it reports the mcp_mask capability. The Data masking page offers MCP listeners and binds entity rules only.

AI analyzer

An analyzer block, or an ai_analysis rule, classifies each tools/call. See Risk Analysis for the block. The model reads the tool name and the arguments JSON, cut to max_input_bytes (default 8 KiB). It never reads tools/list or a result. Sidecar 1.305.0 and later; older builds refuse an analyzer block on the lane at -validate.
config.yaml
  • block refuses the one call as a tool error. The MCP session stays open.
  • A hold files the call as on the other lanes: the tool name and the arguments, byte for byte. Approved, the call runs once. Rejected or expired, it is a tool error with the reason, and the MCP session stays open.
  • With review_mode: hold (the default), the call waits 4 minutes at most. The lane ends a request after 5 minutes, and an approved call keeps the last minute to run. A call still pending then gets a tool error that starts held for approval by the hoop sidecar and names the approval. After the approval, the same call runs.
  • The 4 minutes count from the start of the call and cover all its holds. A SQL tool call with two held statements spends the first approval when its statement is released. If the second is still pending at the limit, the call does not run, and the retry files the first statement again.
  • With review_mode: return, a pending call gets that tool error at once. When the Sidecar has the approval MCP server, the error names approval_wait. Use return when a review takes longer than the client waits for a tool call. Check that limit in the client’s own settings.
  • A hold that a person approves needs a reviewer to start, as on the other lanes: a Control Plane with an approval rule, or a terminal reviewer.
  • A provider failure follows fail_open, as on the other lanes.
  • On a SQL tool, the model reads the call and each SQL statement of its argument: one model call for the call and one per statement. A trigger selects the SQL by its own operation and tables, and also by call or by the tool name in tables.
  • The statement row carries risk_level, risk_action, ai_rule and ai_status.
  • A Sidecar managed by a Control Plane gets an analyzer on an mcp lane only when it reports the mcp_analyzer capability. The AI Analyzer page offers MCP listeners.

Sessions and audit

One Sidecar session per MCP session. It opens on the first message and closes on the client’s DELETE or the idle timeout. The session records initialize as an activity (client name, version, protocol version), one statement per tools/call, allowed or denied with its rule, and one statement per tools/list. A resources/read or a prompts/get leaves no statement. mcpproxy refusals, such as a budget or a rug pull, reach the session as activities. A rule reload ends the open MCP sessions. The next message on one is refused, and the client initializes again under the new rules. A change to the lane itself (upstream, listen, the mcp_gateway block) needs a restart, as for every listener.

What the audit records

Each statement carries this metadata: The session also records these activities: A call a guardrail rule or OPA denies is a statement with its rule, not an activity. A masked result adds a masked row; see Masking. The analyzer’s verdict is on the call’s statement; see AI analyzer.

Metrics

Sidecar 1.302.0 and later. GET /stats lists the lane. active and total count MCP sessions. denied counts the messages the lane refused, in both directions: by a rule or OPA, as invalid params, and by mcp_gateway (a budget, a rate limit, a tool the server did not list, a rug pull). A request that the caller token check refuses does not count.
With a telemetry block, the lane exports hoop.sidecar.mcp.messages, a counter of every message: The method and tool labels are bounded, so a client cannot add series. Each tool call also counts in hoop.sidecar.statements. With traces on, each tool call is a trace of its own: a hoop.statement span with its stages.

Auth

The lane can check a caller token. To the upstream it sends a mutual TLS certificate, or each caller’s own token, and no credential of its own.

Caller to lane

identity_header names a caller and verifies nothing: any process that reaches the port can set it. Use it only behind a proxy on the same host or pod that authenticates the caller and sets the header. Callers the lane cannot tell apart share the anonymous identity, so any of them that holds a session id can use that session. Not supported yet: a verified identity per user, and OAuth login of MCP clients.

Caller token

caller_token admits a caller by a shared token, so the lane can listen on an address other than loopback. Sidecar 1.290.0 and later; older builds refuse the key at -validate.
config.yaml
The MCP client sends the token on every request:
  • What is refused. No header, an empty value, a value not in the file, or the header sent twice. The request gets a 403 request refused: <reason> before the lane reads its body, and the connection closes. Claude Code shows the server as needs-auth.
  • 403, not 401. A 401 sends MCP clients into OAuth discovery, which the lane does not serve.
  • Refusals are logged, not audited. No MCP session exists yet. The Sidecar logs mcp request refused with the peer address and the reason.
  • What is admitted. The session and every statement name name as the principal.
  • A session belongs to its token. An Mcp-Session-Id works only with the token that opened it. A request with another token gets a 404, and the session records mcp.session_refused.
  • The token stays in the Sidecar. The lane removes the header first. The token never reaches the upstream, an audit row, policy input or a log.
  • Refused at startup. A header that MCP uses (Mcp-*, Last-Event-ID), or one the upstream, HTTP framing or the Sidecar already uses, such as authorization or host. caller_token together with identity_header.
  • No TLS of its own. The token travels as written. Set downstream_tls, or put TLS in front of the listener.
The file, rotation and revocation work as on the http lane. See Caller token.

Lane to upstream

Without passthrough_header, the lane sends no Authorization header to the upstream, the caller’s included. It refuses headers, because the config holds no inline secret. For a server that needs a token the caller does not hold, or OAuth: run the MCP server yourself with its credential, or run a proxy on loopback that adds the credential, and point upstream at that proxy (http://127.0.0.1:<port>/mcp is accepted on loopback). Not supported yet: a token from a file or a secret source, OAuth to the upstream, and AWS SigV4.

The caller’s own token

With mcp_gateway.passthrough_header, each caller sends its own token for the upstream, such as a GitHub personal access token or a Stripe restricted key. The lane forwards it as Authorization: Bearer <token>. Older Sidecar builds refuse the key at -validate, and the control plane does not serve it to them.
config.yaml
The MCP client sends the token on every request:
The Cursor CLI (2026.11.22) sends a header value in mcp.json as written: ${env:GITHUB_PAT} reaches the lane as that text, not the token.
  • What is forwarded. The lane removes the header and sends its value as Authorization: Bearer <value>. A Bearer prefix on the value is accepted.
  • What is refused. No header, an empty value, or the header sent twice. The request gets a 403 request refused: <reason> that names the header, and the connection closes.
  • The token stays out of the record. It never reaches an audit row, policy input, the AI analyzer or a log. An upstream error that quotes it is logged with [REDACTED] in its place.
  • Each request uses its own token. The session keeps the latest token in memory, for the replies the lane sends to the server on its own, and drops it when the session ends.
  • One upstream session. The upstream session stays the one the first request opened. A server that binds its session to a user refuses a later request with another user’s token. To change users, open a new session.
  • With caller auth. It works with caller_token, with identity_header or with neither. With caller_token, the lane checks the caller token first, and the upstream gets only the passthrough token.
  • Refused at startup. transport: sse, because the sse stream keeps the token of the request that opened it. A header that is the caller_token header or the identity_header, one an MCP client sends for itself (Mcp-*, Last-Event-ID, Accept, Content-Type, Origin, User-Agent), or one HTTP framing or a proxy uses, such as host, proxy-authorization or x-forwarded-for. authorization is accepted.

Feature coverage

Which part of MCP each feature reads. A part marked No passes through unread.
  • Args are the arguments of a tools/call. SQL rules read the SQL in an mcp_gateway.sql argument.
  • Descriptions are the tools/list result, after overrides. A guardrail hit or an OPA deny there ends the session. opa: {responses: false} keeps them from OPA.
  • Text is a result’s content[].text; Structured is its structuredContent.
  • Resources are resources/read results: the text is masked, a blob is not.
  • Recorded: one statement per call and one per list. Counted: a masked row with the count of masked values, never the text. A resources/read leaves no statement.
The tests behind each cell:

Limits

  • listen takes an address other than loopback only with caller_token. See Caller token.
  • Remote servers only: upstream is an https URL, or http on loopback, over streamable-http or sse. A server that runs as a local command (stdio) needs a wrapper that serves it over HTTP.
  • To the upstream the lane sends at most the caller’s own token, as Authorization: Bearer. Not supported: a key in another header (such as X-Goog-Api-Key), a token the caller does not hold, OAuth, and AWS SigV4. See Lane to upstream.
  • An sse upstream gets no token: passthrough_header is refused on it.
  • A held call waits 4 minutes at most. See AI analyzer.
  • max_conns and network: unix are refused.
  • Sessions live in memory: run one replica, or pin Mcp-Session-Id to one.
  • Sessions reach the Control Plane only with the feature flag experimental.sidecar_session_events on. The Sidecar’s own audit file records them either way.
  • A client that never sends DELETE leaves its session open until idle_timeout_sec, 30 minutes by default.
  • resources/read and prompts/get are not judged and leave no statement. See Feature coverage.

Try it

The envoy-stack/mcp demo runs one session through a lane in front of a test MCP server: a request without the caller token, refused with 403, then initialize, tools/list without the tools an mcp_tool rule hides, an allowed call, a call to a hidden tool and a call over the mcp_gateway budget, then the audit rows under the token’s name, /stats, the hoop.sidecar.mcp.messages points and the trace of each call.

Next

Policy Rules

Every rule type, and how a lane inherits rules.

Config File

The whole configuration, including the OPA block.