Skip to main content
The gateway is the network-boundary runtime that accepts incoming tool calls, applies policy, and forwards allowed requests upstream. This page keeps the configuration surface a gateway integrator normally wires into an application.

Minimal shape

startGatewayServer({
  port: 8088,
  tenant: "my-app",
  targets: {
    orders: "https://orders.internal.example.com",
  },
  policyYaml,
});

const config: MiddlewareConfig = {
  authn: {
    oidc: {
      issuer: process.env.OIDC_ISSUER!,
      audience: process.env.OIDC_AUDIENCE!,
      jwks_uri: process.env.OIDC_JWKS_URI!,
    },
  },
  quotas: {
    adapter: myQuotaAdapter,
  },
  audit: {
    append: (env) => audit.append(env),
    gatewayName: "edge-gateway",
    gatewayVersion: "1.0.0",
  },
  enforcement: {
    mode: "enforce",
    deny_on: ["tool_not_in_allowlist"],
  },
  security: {
    egress_allowlist: ["*.internal.example.com"],
    side_effects: {
      require_idempotency_key: true,
    },
  },
};

startGatewayServer(...) options

KeyTypeRequiredDescription
portnumberYesHTTP listen port
tenantstringYesDefault tenant used by the bootstrapper
targetsRecord<string, string>YesServer name to upstream base URL map
policyYamlstringNoPolicy YAML mapped into runtime config before startup
policyObjectobjectNoObject form of the same override flow
sec0DirstringNoOptional local Sec0 directory hint
audit and quotas are required at runtime. The gateway throws if either is missing.

Policy YAML overrides

When you pass policyYaml or policyObject, the bootstrapper maps the following policy sections into gateway runtime config:
Policy sectionRuntime target
authnauthn
entitlementsentitlements
brokersbrokers
targetstargets
enforcementenforcement
runtime.enforcementruntime.enforcement
securitysecurity
privacyprivacy
ap2 or security.ap2ap2
If you need anything outside that mapping, provide it directly in MiddlewareConfig.

MiddlewareConfig

KeyTypeRequiredDescription
authnobjectNoBearer-token validation config
entitlementsobjectNoTenant and plan entitlements
quotasobjectYesQuota adapter configuration
privacyobjectNoPrivacy controls
enforcementobjectNoObserve/enforce mode plus deny and escalate reasons
ap2objectNoAP2 mandate handling
brokersobjectNoUpstream credential injection rules
securityobjectNoVersion, egress, filesystem, limits, and side-effect rules
dedupeobjectNoIdempotency replay or reject behavior
auditobjectYesAudit writer and gateway identity
runtimeobjectNoLocal or remote runtime evaluation settings

authn

KeyTypeRequiredDescription
authn.allowUnauthenticatedbooleanNoAllow missing bearer token. Default is false
authn.oidcobjectNoOIDC validation settings

OIDCConfig

KeyTypeRequiredDescription
issuerstringYesOIDC issuer
audiencestringYesOIDC audience
jwks_uristringYesJWKS endpoint
tenantClaimstringNoTenant claim name. Default is org
userClaimstringNoUser claim name. Default is email
rolesClaimstringNoRoles claim name. Default is roles
subjectClaimstringNoSubject claim name. Default is sub
clientIdClaimstringNoService principal claim name

entitlements

Entitlements

KeyTypeRequiredDescription
default_planstringYesPlan name for tenants without explicit overrides
plansRecord<string, PlanConfig>YesPlan-level limits
tenantsRecord<string, TenantEntitlement>YesTenant-specific entitlements

TenantEntitlement

KeyTypeRequiredDescription
planstringYesPlan name
allowliststring[]YesAllowed tools
denyliststring[]NoExplicitly denied tools
per_toolobjectNoPer-tool limits
usersobjectNoPer-user overrides
user_idsobjectNoPer-subject overrides
rolesobjectNoPer-role overrides
agentsobjectNoPer-service-agent overrides
agent_nodesobjectNoPer-agent-node overrides

quotas

KeyTypeRequiredDescription
quotas.adapterQuotaAdapterYesStorage adapter for rate and usage limits

QuotaAdapter

MethodSignatureDescription
incrDaily(tenant, tool, limit, now?) => Promise<{ count; resetAt }>Increment daily usage
takeToken(tenant, tool, ratePerSec, burst?, now?) => Promise<{ tokens; resetAt }>Token-bucket rate limiting

privacy

KeyTypeRequiredDescription
privacy.redact_identitiesbooleanNoRedact identity data in gateway spans

enforcement

KeyTypeRequiredDescription
enforcement.mode"observe" or "enforce"NoEnforcement mode
enforcement.deny_onstring[]NoDeny reasons
enforcement.escalate_onstring[]NoEscalation reasons

brokers

brokers is keyed by upstream server name:
KeyTypeRequiredDescription
brokers.<server>.type"vendor_key_pool", "oidc_on_behalf", or "static"YesBroker type
brokers.<server>.key_refsstring[]NoKey references
brokers.<server>.inject.headerstringYesHeader name to inject
brokers.<server>.inject.format"raw", "bearer", or "template"YesInjection format

security

KeyTypeRequiredDescription
security.allow_versionsRecord<string, string[]>NoAllowed versions per server
security.egress_allowliststring[]NoAllowed host patterns
security.fs_allowliststring[]NoAllowed path patterns
security.limitsobjectNoPayload or duration limits
security.side_effectsobjectNoSide-effect rules

security.limits

KeyTypeRequiredDescription
security.limits.max_payload_kbnumberNoMax payload size
security.limits.max_duration_msnumberNoMax duration

security.side_effects

KeyTypeRequiredDescription
security.side_effects.require_idempotency_keybooleanNoRequire idempotency for side effects
security.side_effects.approve_high_riskbooleanNoEnable escalation creation
security.side_effects.human_escalationobjectNoSnake-case approval strategy config
security.side_effects.humanEscalationobjectNoCamel-case approval strategy config

security.side_effects.human_escalation / humanEscalation

KeyTypeRequiredDescription
approval_strategyauto_allow, single_approver, or human_quorumNoApproval strategy
timeout_actionauto_approve or auto_rejectNoAction when escalation expires
min_approvalsnumberNoApproval quorum
min_rejectionsnumberNoRejection quorum
required_rolesstring[]NoRoles that must appear on approval votes
veto_rolesstring[]NoRoles that can force rejection
approval_set_idstringNoExplicit reviewer set override

dedupe

KeyTypeRequiredDescription
dedupe.enabledbooleanNoEnable dedupe
dedupe.duplicatePolicy"replay" or "reject"NoBehavior for duplicates
dedupe.ttlSecnumberNoCache window in seconds
dedupe.namespacestringNoKey prefix
dedupe.redisUrlstringNoRedis URL

audit

KeyTypeRequiredDescription
audit.appendfunctionYes(env) => Promise<void> writer
audit.gatewayNamestringYesGateway name
audit.gatewayVersionstringYesGateway version
audit.clientNamestringNoOptional client name
This page keeps audit at the integration level. The full envelope shape is intentionally left out of the main reference.

ap2

KeyTypeRequiredDescription
ap2.enabledbooleanNoEnable AP2 checks
ap2.requireForSideEffectsbooleanNoRequire AP2 for side effects
ap2.headers.intentstringNoHeader name for intent mandate
ap2.headers.cartstringNoHeader name for cart mandate
ap2.headers.bundlestringNoHeader name for bundle
ap2.trust.didMethodsstring[]NoAllowed DID methods
ap2.trust.issuersAllowliststring[]NoAllowed issuers
ap2.trust.clockSkewSecnumberNoClock skew seconds
ap2.tools.allowstring[]NoAllowed tools
ap2.mode"", "observe", "partial", or "full"NoAP2 enforcement mode
ap2.policyWebhookUrlstringNoPolicy webhook URL

runtime

runtime.enforcement

KeyTypeRequiredDescription
runtime.enforcement.mode"local" or "remote"NoRuntime adapter mode
runtime.enforcement.protocolVersionstringNoRuntime protocol version
runtime.enforcement.failureMode"local", "allow", or "deny"NoFallback behavior when remote runtime fails
runtime.enforcement.remote.endpointstringNoRemote evaluate endpoint
runtime.enforcement.remote.timeoutMsnumberNoRemote timeout
runtime.enforcement.remote.maxRetriesnumberNoRetry count
runtime.enforcement.remote.retryBackoffMsnumberNoRetry backoff base
runtime.enforcement.remote.headersobjectNoExtra request headers
runtime.enforcement.remote.apiKeystringNoRemote runtime API key