Cloud-Native AI Gateway
AI usage needs routing, policy, budget awareness, and provider resilience
One boundary: rate, budget, fallback, OTel
Andrey Lesnikov · Senior DevOps Platform Engineer · 2026-10-22 · sources checked 2026-10-22
Part of AI infrastructure engineering
Teams often ask for one "AI gateway" and then discover they needed two control planes. llm gateway vs mcp gateway is not a vendor bake-off. It is a boundary question: which requests are model completions, and which requests are tool calls that change the world outside the model.
This guide separates those boundaries using public files from ai-runtime-platform (OpenAI-compatible gateway + MCP execution path) and agent-security-contract (pre-execution tool-call gate), plus the MCP specification's security best practices and the OWASP MCP Security Cheat Sheet. Claims about my own repositories are scoped to those repos and their evidence files.
An agent session usually crosses both planes:
chat/completions (or equivalent): prompts in, tokens out, routing, budgets, provider failover.tools/call (and related MCP methods): concrete side effects through MCP servers (filesystem, HTTP, deploy, mail, …).Policies that make sense on one plane are often meaningless on the other. A token budget does not stop a poisoned tool description. A tool allowlist does not stop an expensive model loop that never calls a tool.
In ai-runtime-platform, the gateway is documented as an OpenAI-compatible front door. docs/architecture.md describes routing on health, latency and unit cost, weighted canary and failover routes, and inspectable outcomes (selected_backend, routing_reason, health_score, estimated_cost, fallback_used). Maturity: OpenAI chat/completions gateway — Supported.
docs/auth-boundary.md lists the protected surface when API keys or JWT verify are configured, including /v1/chat/completions, /v1/models, /v1/decisions/{id}, and also /mcp/*. Public routes stay narrow (/livez, /readyz, /healthz, /metrics, /v1/runtime/jwks). Production profile requires OIDC JWKS + issuer/audience, Control Plane URL and Redis.
Honest limits from the same architecture doc: cost is request attribution from token usage and configured unit rates, not cloud billing; the default health store is in-memory per replica unless REDIS_URL is set.
The product case for this layer is Cloud-Native AI Gateway. Sibling platform context: AI Runtime Platform.
MCP security is about who may call which tool, with which arguments, under which catalog digest, and what evidence you keep. The MCP specification's security best practices forbid token passthrough: MCP servers MUST NOT accept tokens that were not explicitly issued for them, and must not forward client tokens downstream as if the server had validated them for that audience.
The OWASP MCP Security Cheat Sheet (and the related Agent Security Cheat Sheet) push the same direction: least privilege, pinned tool catalogs, isolation, and audit — not "trust the model to refuse".
In agent-security-contract, ASC is a platform gate for agent and MCP tool calls. From README.md and policy/demo-agent.policy.yaml:
capability_digest (sha256:…)REQUIRE_APPROVAL unless approved; some destructive path escapes still BLOCKALLOW / BLOCK / REQUIRE_APPROVAL (exit 0 / 1 / 2)src/asc/sidecar.py): POST /v1/evaluate before execution; callers must fail closed on errors/timeoutsEvidence in docs/EVIDENCE.md is generated from results/results.json. Scope phrasing in that file: on this corpus of 66 scenarios (33 attack, 33 benign): critical false-ALLOW 0, benign false-BLOCK 0/33. That is corpus evidence, not a claim of general agent safety.
For the Kubernetes checklist that sits beside this gate, see MCP security checklist for Kubernetes and the Agent & MCP security hub.
docs/mcp-execution.md describes the runtime sequence:
Agent → Runtime tool call
→ Control Plane evaluate-tool (signed verdict path when enabled)
→ Runtime initialize (when sessionMode requires it) + Mcp-Session-Id
→ Runtime MCP Streamable HTTP tools/call (JSON or SSE)
→ audit-tool (session / capability / request ids)
→ filtered/truncated result to agent
Registry servers are configured via MCP_SERVER_REGISTRY (URL, transport, sessionMode, credentialRef as env:NAME only, optional capabilityDigest). Execution without the Control Plane is rejected (503 mcp_governance_required) unless MCP_ALLOW_UNGOVERNED=true for local demos. Maturity matrix: MCP Streamable HTTP (JSON) and MCP session / SSE lifecycle are Supported; MCP session HA is process-local (sticky sessions or a shared store for multi-replica).
That is an execution and governance path for tools, not a substitute for ASC's CI-oriented corpus gate — and not a substitute for LLM routing policy on /v1/chat/completions.
| Question | LLM gateway | MCP gate / MCP path |
|---|---|---|
| Primary request | Model completion (/v1/chat/completions, …) |
Tool call (tools/call, evaluate-before-exec) |
| Typical policy | Route, failover, canary, token/cost admission, authn to the gateway | Capability catalog, digests, arg constraints, approvals, rate limits |
| Failure mode example | Wrong backend, unbounded spend, auth gap on the API | Tool misuse, poisoned catalog, token passthrough, unapproved high-impact action |
| Evidence shape in these repos | Routing metadata, usage/budget envelopes (gateway) | ASC evidence envelope (schemas/evidence-envelope.schema.json) |
| Identity focus | Client → gateway (API key / JWT); backend credentials | Workload identity + tokens issued for the MCP server (no passthrough) |
Complementary products named in the ASC README (Promptfoo for red-team detection, LiteLLM-style proxy guardrails for request/response filtering) sit beside these planes; they do not replace a tool-capability admission gate. LiteLLM's own docs cover proxy/guardrail configuration if you use that stack: https://docs.litellm.ai/
Cases
AI usage needs routing, policy, budget awareness, and provider resilience
One boundary: rate, budget, fallback, OTel
AI workloads often start as API calls but become production systems that need identity, policy, scaling, telemetry, and clear ownership
Every model call: policy + trace + budget
Agent and MCP stacks expand the attack surface beyond prompt text: tool misuse, poisoned tool descriptions, argument injection, and unapproved high-impact actions run without a pre-execution gate
0 false-ALLOW · 0 false-BLOCK on this corpus