Skip to main content

STOA Gateway

Overview​

STOA Gateway is the unified API gateway component of the STOA Platform. It provides AI-native API management with 4 deployment modes to fit different use cases.

Current Implementation: Python/FastAPI (mcp-gateway/) Target Implementation: Rust/Tokio (stoa-gateway/) β€” Q4 2026

See ADR-024 for the architecture decision.

Architecture Vision​

Deployment Modes​

Edge-MCP Mode (Current)​

Status: βœ… Production

The primary mode for AI agent integration via Model Context Protocol (MCP).

Use Cases:

  • Claude Desktop integration
  • Custom LLM agent access to enterprise APIs
  • AI-powered automation workflows

Features:

  • SSE (Server-Sent Events) transport
  • JSON-RPC 2.0 message handling
  • Dynamic tool registry from Kubernetes CRDs
  • OAuth2/OIDC authentication via Keycloak
  • OPA policy evaluation
  • Kafka metering pipeline

Example:

# Current Python implementation
cd mcp-gateway && uvicorn src.main:app --port 3001

# Future Rust implementation
stoa-gateway --mode=edge-mcp --port=3001

Endpoints:

  • GET /mcp/sse β€” SSE endpoint for Claude Desktop
  • POST /mcp/v1/tools/{name} β€” Tool invocation
  • GET /mcp/v1/tools β€” List available tools

Sidecar Mode (Planned Q2 2026)​

Status: πŸ“‹ Planned

Deploy STOA behind existing API gateways to add observability and governance without replacing infrastructure.

Use Cases:

  • Add STOA capabilities to Kong, Envoy, or Apigee
  • Gradual migration from legacy gateways
  • Enterprise compliance requirements

Features:

  • Observability injection (OpenTelemetry traces)
  • Metering events to Kafka for billing
  • UAC compliance validation
  • Error snapshot capture for debugging

Example:

stoa-gateway --mode=sidecar \
--primary-gateway=kong \
--metering-enabled=true

Architecture:


Proxy Mode (Planned Q3 2026)​

Status: πŸ“‹ Planned

Classic API gateway with full policy enforcement, for greenfield deployments.

Use Cases:

  • New API deployments needing governance
  • Replacing legacy gateways entirely
  • Multi-tenant API platforms

Features:

  • OPA policy evaluation (blocking)
  • Rate limiting per tenant/consumer
  • Request/response transformation
  • Circuit breaker patterns
  • mTLS termination

Example:

stoa-gateway --mode=proxy \
--upstream=http://backend:8080 \
--opa-endpoint=http://opa:8181

Shadow Mode (Deferred)​

Status: ⏸️ Deferred pending security review

Passive traffic observation for legacy API discovery. Deploy for 2 weeks, auto-generate interface contracts.

Use Cases:

  • Legacy APIs with no documentation
  • Black-box progiciels (SAP, Oracle, etc.)
  • API inventory discovery

Features (planned):

  • Zero modification to requests/responses
  • Capture traffic patterns
  • Auto-generate UAC contracts (HTTP parsing, no ML)
  • Human-in-the-loop validation before promotion

Example:

stoa-gateway --mode=shadow \
--target=http://legacy-erp:8080 \
--output=/var/lib/stoa/uac

Security Requirements (before implementation):

  • PII detection/masking before storage
  • Explicit opt-in per API/tenant
  • Retention < 30 days with auto-purge
  • RGPD Article 25 compliance

Configuration​

Environment Variables​

VariableDescriptionDefault
GATEWAY_MODEDeployment modeedge-mcp
GATEWAY_PORTHTTP port3001
KEYCLOAK_URLKeycloak base URLRequired
KEYCLOAK_REALMKeycloak realmstoa
OPA_ENABLEDEnable OPA policy evaluationtrue
METERING_ENABLEDEnable Kafka meteringtrue

Kubernetes CRDs​

The gateway watches for Tool and ToolSet CRDs:

apiVersion: gostoa.dev/v1alpha1
kind: Tool
metadata:
name: my-api-tool
namespace: tenant-acme
spec:
displayName: My API Tool
description: A sample tool
endpoint: https://api.example.com/v1/action
method: POST

See MCP Tools Reference for full schema.

Current vs Target​

AspectCurrent (Python)Target (Rust)
Directorymcp-gateway/stoa-gateway/
LanguagePython 3.11Rust (Tokio)
FrameworkFastAPIAxum/Hyper
StatusProductionQ4 2026
Modesedge-mcp onlyAll 4 modes