Skip to main content

Gateway Modes

STOA Gateway supports 4 deployment modes (defined in ADR-024), each optimized for a different integration pattern. Select the mode via the STOA_GATEWAY_MODE environment variable.

Mode Overview​

ModePortMCP SupportUse CaseStatus
edge-mcp8080YesStandalone MCP gateway with full protocol supportProduction
sidecar8081NoPolicy enforcement alongside existing gatewaysQ2 2026
proxy8082NoInline request/response transformationQ3 2026
shadow8083NoPassive traffic capture and UAC generationQ4 2026

Mode Capabilities​

Capabilityedge-mcpsidecarproxyshadow
MCP protocol (SSE)YesNoNoNo
Tool discovery/invocationYesNoNoNo
JWT authenticationYesYesYesNo
Rate limitingYesYesYesNo
Circuit breakerYesNoYesNo
Request transformationNoNoYesNo
Traffic captureNoNoNoYes
UAC generationNoNoNoYes
Requires upstreamNoNoYesYes
Passive (read-only)NoNoNoYes

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
/mcp/sseGETSSE transport endpoint
/mcp/messagesPOSTJSON-RPC message endpoint
/oauth/authorizeGETOIDC proxy (to Keycloak)
/oauth/tokenPOSTToken proxy (to Keycloak)
/oauth/registerPOSTDynamic client registration
/admin/*VariousAdmin API (22 endpoints)
/healthGETHealth check
/metricsGETPrometheus metrics

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​

Deploys alongside an existing API gateway (Kong, webMethods, Envoy) to add STOA policy enforcement without replacing the primary gateway.

Configuration​

STOA_GATEWAY_MODE=sidecar

# Sidecar specific settings
STOA_UPSTREAM_TYPE=generic # Options: generic, webmethods, kong, envoy, apigee
STOA_USER_INFO_HEADER=X-User-Info
STOA_TENANT_ID_HEADER=X-Tenant-ID
STOA_DECISION_FORMAT=StatusCode # Options: StatusCode, JsonBody, EnvoyExtAuthz, KongPlugin

Decision Format​

The sidecar responds to auth/policy checks in a format compatible with the host gateway:

FormatCompatible WithResponse
StatusCodeAny gateway200 (allow) or 403 (deny)
JsonBodyCustom integrationsJSON with allowed: true/false and reason
EnvoyExtAuthzEnvoy, Istioext_authz gRPC/HTTP response
KongPluginKongKong plugin-compatible response

Exposed Routes​

PathMethodPurpose
/authzPOSTAuthorization decision endpoint
/healthGETHealth check
/metricsGETPrometheus metrics

When to Use​

  • Adding STOA RBAC/rate-limiting to an existing Kong or Envoy deployment
  • Gradual migration from a legacy gateway
  • Environments where replacing the gateway is not feasible

Proxy Mode​

Sits inline in the request path, transforming requests and responses between clients and backends. Supports header injection, body transformation, and WebSocket passthrough.

Configuration​

STOA_GATEWAY_MODE=proxy

# Proxy specific settings
STOA_TRANSFORM_REQUEST=false
STOA_TRANSFORM_RESPONSE=false
STOA_INJECT_HEADERS=true
STOA_WEBSOCKET_PASSTHROUGH=false
STOA_CONNECTION_POOL_SIZE=100

Capabilities​

FeatureDefaultDescription
Request transformationOffModify request headers/body before forwarding
Response transformationOffModify response headers/body before returning
Header injectionOnAdd tenant, trace, and correlation headers
WebSocket passthroughOffForward WebSocket connections
Connection pooling100Upstream connection pool size

When to Use​

  • Request/response transformation between clients and backends
  • Adding observability headers to existing API traffic
  • WebSocket proxying with policy enforcement
  • Environments requiring inline traffic manipulation

Shadow Mode​

Passively captures traffic for analysis and automatic UAC (Universal API Contract) generation. Does not modify or block any requests.

Configuration​

STOA_GATEWAY_MODE=shadow

# Shadow specific settings
STOA_CAPTURE_METHOD=Inline # Options: EnvoyTap, PortMirror, Inline, KafkaReplay
STOA_UAC_OUTPUT_DIR=/var/stoa/uac
STOA_AUTO_CREATE_MR=false
STOA_MIN_REQUESTS_FOR_UAC=100
STOA_ANALYSIS_WINDOW_HOURS=168 # 7 days

Capture Methods​

MethodDescriptionInfrastructure
InlineSTOA captures traffic directlyNo extra infra
EnvoyTapEnvoy tap filter forwards copiesEnvoy sidecar
PortMirrorNetwork-level traffic mirroringSwitch/router config
KafkaReplayReplay from Kafka topicRedpanda/Kafka

UAC Generation​

After collecting min_requests_for_uac requests over analysis_window_hours, shadow mode generates a Universal API Contract:

1. Capture traffic (requests + responses)
2. Analyze patterns (endpoints, schemas, error codes)
3. Generate OpenAPI spec + STOA UAC annotations
4. Output to UAC_OUTPUT_DIR (or auto-create MR if configured)

Exposed Routes​

PathMethodPurpose
/shadow/statusGETCapture statistics
/shadow/generatePOSTTrigger UAC generation
/healthGETHealth check
/metricsGETPrometheus metrics

When to Use​

  • Discovering undocumented APIs in legacy environments
  • Automatically generating API contracts from live traffic
  • Pre-migration analysis before moving to STOA
  • Compliance auditing of API traffic patterns

Mode Selection Guide​

ScenarioRecommended Mode
Greenfield MCP deploymentedge-mcp
Adding policies to existing Kongsidecar
API transformation layerproxy
Legacy API discoveryshadow β†’ then edge-mcp
Gradual migration from webMethodsshadow β†’ sidecar β†’ edge-mcp

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 gateway listens on the mode's default port (8080-8083) unless overridden.

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 not enforcing policiesDecision format mismatchMatch STOA_DECISION_FORMAT to host gateway
Shadow not capturing trafficCapture method requires infraUse Inline if no Envoy/Kafka available
Proxy dropping WebSocketPassthrough disabledSet STOA_WEBSOCKET_PASSTHROUGH=true