Skip to main content

Gateway Modes

The Rust gateway has four mode values, selected with STOA_GATEWAY_MODE. The table distinguishes the available Edge-MCP and Sidecar runtimes from the partial Rust implementations of Proxy and Shadow.

Mode Overview​

ModeDefault HTTP PortMCP SupportUse CaseStatus
edge-mcp8080YesStandalone MCP gateway with full protocol support (+ optional Envoy ext_authz gRPC listener)Production (Maintenance, ADR-073)
sidecar8080 (companion Helm chart sets 8081)NoAllow or deny on HTTP POST /authz for a host that calls itRuntime present
proxy8080NoHTTP forwarding componentsPartial Rust implementation. Envoy xDS target (ADR-073 §8)
shadow8080NoStatus and UAC generation endpointsPartial Rust implementation. Envoy mirroring target (ADR-073 §8)

Mode Capabilities​

Capabilityedge-mcpsidecarproxyshadow
MCP protocol (SSE)YesNoNoNo
Tool discovery/invocationYesNoNoNo
JWT authenticationYesNo. /authz trusts the JSON userNot wiredNo
Rate limitingYesOptional, in-memory, per processNot wiredNo
Circuit breakerYesNoNot wiredNo
Request transformationNoNoComponent onlyNo
Traffic captureNoNoNoNo capture source wired
UAC generationNoNoNoManual endpoint requires data
Requires upstreamNoNoForwarding requires a registered upstream routeGitLab only for UAC submission
Passive (read-only)NoNoNoStatus and analysis only. UAC submission writes to GitLab

Edge-MCP Mode (Production)​

The default and primary production mode. Implements the full MCP protocol with SSE transport, OAuth 2.1 discovery, tool management, and session handling.

Configuration​

# Environment variables
STOA_GATEWAY_MODE=edge-mcp

# Edge-MCP specific settings
STOA_SSE_KEEPALIVE=true
STOA_SSE_KEEPALIVE_INTERVAL_SECS=30
STOA_MAX_SESSIONS=10000
STOA_SESSION_TIMEOUT_SECS=3600

Helm Values​

stoaGateway:
mode: edge-mcp
edgeMcp:
sseKeepalive: true
sseKeepaliveIntervalSecs: 30
maxSessions: 10000
sessionTimeoutSecs: 3600

Exposed Routes​

PathMethodPurpose
/.well-known/oauth-authorization-serverGETOAuth 2.1 discovery
/.well-known/oauth-protected-resourceGETProtected resource metadata
/mcpGET, POSTDiscovery (GET) & Streamable HTTP JSON-RPC 2.0 (POST)
/mcp/sseGET, POST, DELETESSE transport & JSON-RPC session endpoint
/mcp/wsGETOpt-in WebSocket JSON-RPC (STOA_WEBSOCKET_ENABLED=true)
/oauth/tokenPOSTToken proxy (to Keycloak stoa realm)
/oauth/parPOSTPushed Authorization Request proxy (to Keycloak stoa realm)
/oauth/registerPOSTDynamic client registration
/admin/*VariousGateway Admin API (Bearer STOA_ADMIN_API_TOKEN)
/health, /readyGETLiveness and fail-closed readiness checks
/metricsGETPrometheus metrics

(Note: GET /oauth/authorize returns 404 on stoa-gateway; /.well-known/oauth-authorization-server directs clients directly to Keycloak's /realms/stoa/protocol/openid-connect/auth. When STOA_EXT_AUTHZ_GRPC_ADDR, STOA_EXT_AUTHZ_AUDIENCE, and non-empty STOA_EXT_AUTHZ_REQUIRED_SCOPES in prod are set, stoa-gateway also supervises a gRPC envoy.service.auth.v3.Authorization listener for upstream Envoy per ADR-073.)

When to Use​

  • Standalone MCP gateway deployment
  • AI agent integration (Claude, GPT, custom agents)
  • Full API management with rate limiting, quotas, and circuit breaking
  • Production workloads requiring SSE transport

Sidecar Mode​

Starts the same binary with STOA_GATEWAY_MODE=sidecar. The process exposes POST /authz and does not mount MCP routes. The host keeps authentication, routing, and enforcement. A same-pod Helm template exists and is off by default. Live calls from Kong, webMethods, or Envoy are not demonstrated in the repository.

Read Companion usage for the three integration shapes (same-pod gateway, application callout, mesh) and the current limits. Mesh adapters are design notes only.

Configuration​

STOA_GATEWAY_MODE=sidecar
STOA_PORT=8081

STOA_UPSTREAM_TYPE, STOA_USER_INFO_HEADER, and STOA_TENANT_ID_HEADER are read into sidecar settings and are not used by /authz. STOA_DECISION_FORMAT is not read. The response format is status code only: 200, 401, 403, or 429, with an empty body. JSON, Envoy, and Kong formatters exist in the binary and cannot be selected.

The HTTP listener binds 0.0.0.0 and STOA_PORT. STOA_HOST does not change that bind. The chart's STOA_HOST=127.0.0.1 does not make /authz loopback-only.

Exposed Routes​

PathMethodPurpose
/authzPOSTAllow or deny from the shared decision engine
/health, /readyGETHealth and readiness
/metricsGETGeneric Prometheus metrics for the process

There is no stoa_sidecar_* metric in the gateway source.

When to Use​

  • A host in the same pod can build the JSON body and call POST /authz before it forwards.
  • An application can make the same callout. That is not a same-pod companion deployment.
  • GitOps synchronization of Kong, Gravitee, webMethods, or Envoy is stoa-connect, which stays off the request path.

Proxy Mode​

The Rust binary starts this mode with an empty route registry and no request or response transformers attached. The repository tests routing and transformation components in isolation. Those tests do not cover a working proxy running from the binary.

ADR-073 §8 defines the Envoy target. UAC contracts provide the routes through xDS, with STOA processing in external services.

Shadow Mode​

The Rust binary exposes the endpoints below and starts without a traffic capture source attached. UAC generation needs captured samples. The repository tests analysis and generation with data passed directly to the service.

Submitting a UAC is a separate operation that requires a configured GitLab client. ADR-073 §8 defines the Envoy target, where request mirroring and access logs supply the data for UAC generation.

Exposed Routes​

PathMethodPurpose
/shadow/statusGETReport capture and analysis statistics
/shadow/generatePOSTTrigger UAC generation. Reports insufficient_data when there are too few samples
/shadow/submit-uacPOSTSubmit a UAC to GitLab when the GitLab client is configured
/healthGETHealth check
/metricsGETPrometheus metrics

Mode Selection Guide​

ScenarioRecommended Mode
Greenfield MCP deploymentedge-mcp
Allow or deny beside a host that calls POST /authzCompanion (sidecar runtime). See Companion usage
API transformation layerEnvoy routing profile defined in ADR-073 §8
Legacy API discoveryEnvoy traffic mirroring defined in ADR-073 §8
Keep a third-party gateway and sync desired statestoa-connect. A same-pod companion is a separate callout and is not a recorded webMethods integration

Runtime Configuration​

Set the mode via environment variable or Helm values:

# Environment variable (highest priority)
export STOA_GATEWAY_MODE=edge-mcp

# Helm values
stoaGateway:
mode: edge-mcp

The mode is logged at startup:

INFO Starting STOA Gateway version=2.0.0 mode=edge-mcp

The Rust binary uses HTTP port 8080 by default in all four modes. Set STOA_PORT to change the listen port. If you also set the legacy PORT variable, it takes precedence.

  • Helm sets port 8080 in the main gateway container and 8081 in the companion container.
  • Docker Compose maps host port 8081 by default to container port 8080 in the main stack. PORT_GATEWAY changes the host port.

Troubleshooting​

ProblemCauseFix
"Unknown mode" on startupInvalid STOA_GATEWAY_MODE valueUse: edge-mcp, sidecar, proxy, or shadow
MCP endpoints return 404Wrong mode selectedOnly edge-mcp serves MCP routes
Sidecar answers with a status and an empty body/authz format is fixed to status codeSend the JSON body in Companion usage. STOA_DECISION_FORMAT is not read
Shadow not capturing trafficThe Rust mode has no input wired to its capture serviceSee Shadow Mode for the current runtime and the Envoy target
Proxy dropping WebSocketThe Rust mode does not wire WebSocket passthroughSee Proxy Mode for the current runtime and the Envoy target

Cookies and privacy

With your permission, we use cookies to measure visits and understand navigation to improve the site.

Learn more

Google Analytics measures visits and useful clicks. Microsoft Clarity provides masked interaction replays. No advertising use. Your choice is saved for six months. You can change or withdraw it at any time using the “Cookies” button.

Read the audience measurement details