Skip to main content

STOA Gateway

Overview​

STOA Gateway (stoa-gateway/, Rust/Tokio/axum) is the unified AI-native gateway runtime in production since February 2026. It exposes four STOA_GATEWAY_MODE profiles (ADR-024) and an optional Envoy gRPC ExtAuthzService listener.

Data Plane Evolution (ADR-073)

Under ADR-073: Adopt Envoy as Primary Data Plane, stoa-gateway is in Production / Maintenance while L4/L7 proxy duties converge onto upstream Envoy configured via STOA Link (stoa-connect loopback mTLS ADS) and authorized by stoa-gateway's built-in gRPC ExtAuthzService (STOA_EXT_AUTHZ_GRPC_ADDR, STOA_EXT_AUTHZ_AUDIENCE, and non-empty STOA_EXT_AUTHZ_REQUIRED_SCOPES in prod). Full policy parity and default topology migration remain in progress (Data Plane Architecture).

Architecture Vision​

Deployment Modes​

Edge-MCP Mode (Current Default)​

Status: ✅ Production (Maintenance under ADR-073)

The primary mode for AI agent integration via the Model Context Protocol (MCP) and contract-driven REST routes.

Use Cases:

  • Claude.ai and Claude Desktop integration
  • Custom LLM agent access to enterprise APIs
  • Transactional REST + MCP API contracts (POST /admin/contracts)

Features:

  • Streamable HTTP (POST /mcp), SSE (GET/POST/DELETE /mcp/sse), and opt-in WebSocket (GET /mcp/ws when STOA_WEBSOCKET_ENABLED=true)
  • JSON-RPC 2.0 single and batch message handling (2025-11-25, 2025-03-26, 2024-11-05)
  • Dynamic tool registry from Kubernetes CRDs (Tool, ToolSet, Skill) and Control Plane sync
  • OAuth2/OIDC authentication via Keycloak (stoa realm, verified tenant_id claim, ADR-074)
  • Fail-closed signed Ed25519 per-tenant policy enforcement (ADR-070) and OPA evaluation
  • Optional gRPC envoy.service.auth.v3.Authorization server (STOA_EXT_AUTHZ_GRPC_ADDR + STOA_EXT_AUTHZ_AUDIENCE + non-empty STOA_EXT_AUTHZ_REQUIRED_SCOPES in prod)

Example:

STOA_GATEWAY_MODE=edge-mcp \
STOA_PORT=8080 \
STOA_KEYCLOAK_URL=https://auth.example.com \
STOA_KEYCLOAK_REALM=stoa \
STOA_MCP_AUDIENCE=stoa-mcp \
stoa-gateway

Primary Endpoints:

  • POST /mcp — Streamable HTTP JSON-RPC 2.0 entrypoint
  • GET /mcp/sse & POST /mcp/sse — SSE transport
  • GET /mcp/v1/tools & POST /mcp/v1/tools/invoke — Companion JWT-gated REST tool endpoints

Sidecar Mode (Companion Runtime)​

Status: Runtime present. Same-pod packaging exists in charts/stoa-platform (stoaSidecar.enabled=false by default).

The same binary starts with STOA_GATEWAY_MODE=sidecar and answers HTTP POST /authz. The host gateway keeps authentication, routing, and verdict enforcement. The HTTP companion decision engine does not evaluate OPA and does not emit Kafka metering events.

Envoy gRPC ext_authz vs HTTP Companion

stoa-gateway is configured exclusively via STOA_* environment variables or config.yaml (not --mode CLI flags). For Envoy's native envoy.filters.http.ext_authz gRPC filter (ADR-073), set STOA_EXT_AUTHZ_GRPC_ADDR, STOA_EXT_AUTHZ_AUDIENCE, and STOA_EXT_AUTHZ_REQUIRED_SCOPES (required non-empty when STOA_ENVIRONMENT=prod) rather than POST /authz. See Companion usage for HTTP /authz limits and stoa-connect for control-plane sync and loopback mTLS ADS.

Client → host gateway → POST /authz → stoa-gateway (sidecar)
└── on 200 → backend

Proxy Mode​

Status: Rust scaffolding present; full L7 API proxy targeted on upstream Envoy via xDS (ADR-073 §8)

Classic API gateway profile for greenfield REST/gRPC traffic with full policy enforcement.

Use Cases:

  • New API deployments needing centralized governance
  • Replacing legacy gateways without MCP tool exposure
  • Multi-tenant API platforms

Capabilities & Trajectory:

  • stoa-gateway already serves dynamic contract routes (POST /admin/contracts) and API proxy backends in edge-mcp mode
  • Under ADR-073 §8, standalone proxy mode maps to an Envoy listener/cluster profile reconciled over xDS with ExtAuthzService gRPC enforcement

Shadow Mode​

Status: ⏸️ Rust capture scaffolding present; production traffic mirroring targeted on Envoy (ADR-073 §8) pending security review

Passive traffic observation for legacy API discovery and UAC contract generation without modifying live responses.

Use Cases:

  • Legacy APIs with missing or stale OpenAPI specs
  • Black-box enterprise applications (SAP, Oracle, ERP)
  • API inventory discovery

Security Requirements (before production enablement):

  • PII detection and masking before storage
  • Explicit opt-in per API and tenant
  • Retention < 30 days with automatic purge
  • GDPR Article 25 data-protection-by-design compliance

Configuration​

Environment Variables​

stoa-gateway reads STOA_* environment variables (and optional config.yaml):

VariableDescriptionDefault
STOA_GATEWAY_MODEDeployment mode (edge-mcp, sidecar, proxy, shadow)edge-mcp
STOA_PORTHTTP listener port8080
STOA_KEYCLOAK_URLCanonical Keycloak base URLOptional (required for OIDC)
STOA_KEYCLOAK_REALMShared Keycloak realm (ADR-074)stoa (in Helm/Compose)
STOA_MCP_AUDIENCERequired JWT aud for MCP endpoints (mandatory when STOA_ENVIRONMENT=prod)Unset (fail-closed)
STOA_POLICY_ENABLEDEnforce signed Ed25519 per-tenant tool policies (ADR-070)true
STOA_POLICY_BOOT_TENANTSComma-separated tenant IDs whose signed policy must exist at startupEmpty
STOA_EXT_AUTHZ_GRPC_ADDROptional gRPC ExtAuthzService socket address for Envoy (host:port)Unset
STOA_EXT_AUTHZ_AUDIENCERequired JWT aud for Envoy gRPC ext_authz checks (mandatory in prod)Unset (fail-closed)
STOA_EXT_AUTHZ_REQUIRED_SCOPESComma-separated required JWT scopes for Envoy gRPC ext_authz (mandatory non-empty in prod)Empty
STOA_K8S_ENABLEDEnable Kubernetes Tool/ToolSet/Skill CRD watcher (requires Cargo k8s feature)false
STOA_KAFKA_ENABLEDEnable internal Kafka/Redpanda metering producerfalse

Kubernetes CRDs​

When compiled with the k8s Cargo feature and started with STOA_K8S_ENABLED=true, stoa-gateway watches Tool, ToolSet, and Skill resources (gostoa.dev/v1alpha1):

apiVersion: gostoa.dev/v1alpha1
kind: Tool
metadata:
name: my-api-tool
namespace: stoa-system
spec:
displayName: My API Tool
description: A sample tool
endpoint: https://api.example.com/v1/action
method: POST
inputSchema:
type: object
properties:
query:
type: string

See Kubernetes CRDs Reference for all five CRDs (Tool, ToolSet, Skill, GatewayInstance, GatewayBinding).

Implementation Summary​

AspectDetails
Directorystoa-gateway/
Language & RuntimeRust (stable), Tokio + axum + tonic
Lifecycle StatusProduction / Maintenance (ADR-073)
Primary Active Modeedge-mcp (plus optional ExtAuthzService gRPC listener)
Companion Modesidecar HTTP POST /authz (Companion usage)
Target Proxy & ShadowUpstream Envoy via stoa-connect xDS ADS (ADR-073)

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