Repository navigation
envoy, node, docs: support GCP Agent Gateway FULL_DUPLEX_STREAMED ext_proc and host-first MCP resolution - #965
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces integration support for Google Cloud Agent Gateway with Agent Mesh, adding comprehensive deployment examples, scripts, and documentation for both managed and edge topologies. It updates the Envoy ext_proc server and node ext_authz logic to support host-resolved MCP services (eliminating the need for custom target headers), selective body buffering, and FULL_DUPLEX_STREAMED body modes, while ensuring HTTP/2 header keys are emitted in lowercase. Robust unit and integration tests have been added to verify these changes. There are no review comments, and I have no feedback to provide.
…_proc and host-first MCP resolution
Add full compatibility with Google Cloud Agent Gateway (AuthzExtension
EXT_PROC_GRPC + AuthzPolicy CONTENT_AUTHZ) and Envoy BUFFERED /
FULL_DUPLEX_STREAMED ext_proc proxies for unmodified HTTP, Git Smart HTTP,
and MCP traffic:
- internal/envoy:
- Read ProcessingRequest.ProtocolConfig and FlowControlInit to detect
FULL_DUPLEX_STREAMED request/response body modes and
SendBodyWithoutWaitingForHeaderResponse.
- In FULL_DUPLEX_STREAMED mode, buffer MCP POST request body chunks silently
until EndOfStream (or RequestTrailers) before authorizing tools/call against
TaskAuthorizationRule allowed_tools, echoing allowed bodies via
BodyMutation.StreamedResponse and failing closed with 403 ImmediateResponse
(or 413 on overflow > MaxHTTPBodyBytes) before any disallowed bytes leave
Envoy.
- Reject partial half-duplex STREAMED MCP RequestBody chunks (EndOfStream=false
when not in FULL_DUPLEX_STREAMED mode) fail-closed with 403 ImmediateResponse
on the first chunk so zero unverified body bytes can be released upstream.
- Add CheckInput.HeadersOnly and CheckResult.NeedsRequestBody so host-resolved
MCP services mounted on arbitrary paths (such as "/" or "/mcp/v1") trigger
body inspection without relying on a /mcp path prefix or custom headers,
while non-MCP POST traffic (such as Git Smart HTTP git-upload-pack) is
decided at RequestHeaders without body buffering.
- Emit RFC 9113 lowercase, deterministically sorted HTTP/2 header names in
both gRPC ext_authz Check and ext_proc HeaderMutation responses.
- internal/node:
- Add ResolveMCPByHostPath (longest segment-boundary path prefix with
fail-closed ambiguity rejection) and strip explicit :port from :authority.
- Resolve ext_authz / ext_proc targets host-first for unmodified gateway
traffic (X-Mesh-Target-Service -> /mesh/... -> MCP host+path -> Egress host
-> bare /<scheme>/<name>).
- Return verified X-Mesh-* provenance headers (never backend secrets) on
HeadersOnly MCP pre-checks for FULL_DUPLEX_STREAMED gateways, and enforce
TrustedTransport (--socket-path or --tls-ca) before injecting MCP
target_auth_path Authorization headers alongside egress credential brokering.
- Add structured audit logging for ExtAuthz denials and ExtProc protocol mode.
- site & development/examples/gcp-agent-gateway:
- Add the Google Cloud Agent Gateway integration guide and runnable deployment
and verification bundle (Managed Agent Gateway + Vertex AI Agent Runtime
AGENT_IDENTITY, plus Edge ALB Service Extensions topology).
aojea
force-pushed
the
gcp-agent-gateway-ext-proc
branch
from
November 27, 2026 17:13
fac976d to
2190365
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables
agentmesh-nodeto act as a drop-in Envoyext_proc/ext_authzPolicy Enforcement Point (PEP) for Google Cloud Agent Gateway (AuthzExtensionEXT_PROC_GRPC+AuthzPolicyCONTENT_AUTHZ) and unmodified HTTP, Git Smart HTTP, and MCP traffic.Changes
Envoy
ext_procBUFFERED&FULL_DUPLEX_STREAMEDsupport (internal/envoy)ProcessingRequest.ProtocolConfig(RequestBodyMode,ResponseBodyMode,SendBodyWithoutWaitingForHeaderResponse) andFlowControlInit.FULL_DUPLEX_STREAMEDmode, buffers MCP POST request chunks silently untilEndOfStream(orRequestTrailers) so zero bytes of a disallowed tool call leave Envoy, and echoes allowed request and response body chunks viaBodyMutation.StreamedResponseso Envoy does not strip bodies to 0 bytes.SendBodyWithoutWaitingForHeaderResponse=false(stamps verifiedX-Mesh-*provenance headers onRequestHeaderswithout backend secrets, while still blocking disallowed tools viaImmediateResponseinRequestBody) andSendBodyWithoutWaitingForHeaderResponse=true(defersHeadersResponseuntil Phase 2 authorizes the tool).STREAMEDMCPRequestBodychunks (EndOfStream=falseoutsideFULL_DUPLEX_STREAMED) fail-closed with403 ImmediateResponseon chunk 1 so unverified bytes cannot be released upstream, and fails closed with413 PayloadTooLargeaboveMaxHTTPBodyBytes.CheckInput.HeadersOnlyandCheckResult.NeedsRequestBodyso host-resolved MCP services on arbitrary paths trigger body buffering while streaming non-MCP POSTs (e.g., Git Smart HTTPgit-upload-pack) avoid buffering.ext_authz(Check) andext_proc(HeaderMutation).Host-first target resolution, transport trust & auditability (
internal/node)ResolveMCPByHostPathwith longest segment-boundary prefix matching and fail-closed ambiguity detection, and strips:portfrom:authority/Host.ext_authz/ext_proctargets host-first when unmodified gateway traffic omitsX-Mesh-Target-Service.TrustedTransport(--socket-pathor--tls-ca) gate to MCPtarget_auth_pathAuthorizationinjection as egress credential brokering.ExtAuthz deniedandExtProc protocol configlogging without emitting secret values.Docs & runnable GCP qualification bundle
site/content/docs/guides/gcp-agent-gateway.mdand links it fromsite/content/docs/guides/_index.md.development/examples/gcp-agent-gateway/with end-to-end deployment and verification scripts for Managed Google Cloud Agent Gateway (with Vertex AI Agent RuntimeAGENT_IDENTITYSPIFFE OIDC exchange) and Edge ALB Service Extensions.Testing
make(all binaries build cleanly; zero newgo.moddependencies)go vet ./...go test -race -count=1 ./internal/envoy/... ./internal/node/...go test -p 1 -race -count=1 ./tests/integration/...AgentGateway(CONTENT_AUTHZ+EXT_PROC_GRPC+ Vertex AI Agent RuntimeAGENT_IDENTITY+ livegithub.comGit Smart HTTP + live GitHub MCP backend): 5/5 probes passed (allowed read-only clone, denied git push, denied out-of-scope repo, allowed read-only MCPlist_issueswith verifiedX-Mesh-*headers and spoofed header stripping, and 4/4 mutating MCP tools blocked atREQUEST_BODYbefore reaching the backend).