Skip to content

envoy, node, docs: support GCP Agent Gateway FULL_DUPLEX_STREAMED ext_proc and host-first MCP resolution - #965

Merged
aojea merged 1 commit into
google:mainfrom
aojea:gcp-agent-gateway-ext-proc
Nov 27, 2026
Merged

aojea merged 1 commit into
google:mainfrom
aojea:gcp-agent-gateway-ext-proc

Conversation

@aojea

@aojea aojea commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Enables agentmesh-node to act as a drop-in Envoy ext_proc / ext_authz Policy Enforcement Point (PEP) for Google Cloud Agent Gateway (AuthzExtension EXT_PROC_GRPC + AuthzPolicy CONTENT_AUTHZ) and unmodified HTTP, Git Smart HTTP, and MCP traffic.

Changes

  1. Envoy ext_proc BUFFERED & FULL_DUPLEX_STREAMED support (internal/envoy)

    • Inspects ProcessingRequest.ProtocolConfig (RequestBodyMode, ResponseBodyMode, SendBodyWithoutWaitingForHeaderResponse) and FlowControlInit.
    • In FULL_DUPLEX_STREAMED mode, buffers MCP POST request chunks silently until EndOfStream (or RequestTrailers) so zero bytes of a disallowed tool call leave Envoy, and echoes allowed request and response body chunks via BodyMutation.StreamedResponse so Envoy does not strip bodies to 0 bytes.
    • Handles both SendBodyWithoutWaitingForHeaderResponse=false (stamps verified X-Mesh-* provenance headers on RequestHeaders without backend secrets, while still blocking disallowed tools via ImmediateResponse in RequestBody) and SendBodyWithoutWaitingForHeaderResponse=true (defers HeadersResponse until Phase 2 authorizes the tool).
    • Rejects partial half-duplex STREAMED MCP RequestBody chunks (EndOfStream=false outside FULL_DUPLEX_STREAMED) fail-closed with 403 ImmediateResponse on chunk 1 so unverified bytes cannot be released upstream, and fails closed with 413 PayloadTooLarge above MaxHTTPBodyBytes.
    • Adds CheckInput.HeadersOnly and CheckResult.NeedsRequestBody so host-resolved MCP services on arbitrary paths trigger body buffering while streaming non-MCP POSTs (e.g., Git Smart HTTP git-upload-pack) avoid buffering.
    • Emits RFC 9113 lowercase, deterministically sorted HTTP/2 header names in gRPC ext_authz (Check) and ext_proc (HeaderMutation).
  2. Host-first target resolution, transport trust & auditability (internal/node)

    • Adds ResolveMCPByHostPath with longest segment-boundary prefix matching and fail-closed ambiguity detection, and strips :port from :authority / Host.
    • Resolves ext_authz / ext_proc targets host-first when unmodified gateway traffic omits X-Mesh-Target-Service.
    • Applies the same TrustedTransport (--socket-path or --tls-ca) gate to MCP target_auth_path Authorization injection as egress credential brokering.
    • Adds structured ExtAuthz denied and ExtProc protocol config logging without emitting secret values.
  3. Docs & runnable GCP qualification bundle

Testing

  • make (all binaries build cleanly; zero new go.mod dependencies)
  • go vet ./...
  • go test -race -count=1 ./internal/envoy/... ./internal/node/...
  • go test -p 1 -race -count=1 ./tests/integration/...
  • End-to-end live verification on Google Cloud Managed AgentGateway (CONTENT_AUTHZ + EXT_PROC_GRPC + Vertex AI Agent Runtime AGENT_IDENTITY + live github.com Git 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 MCP list_issues with verified X-Mesh-* headers and spoofed header stripping, and 4/4 mutating MCP tools blocked at REQUEST_BODY before reaching the backend).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
aojea force-pushed the gcp-agent-gateway-ext-proc branch from fac976d to 2190365 Compare November 27, 2026 17:13
@aojea
aojea merged commit 08c2381 into google:main Nov 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant