NGINX Predicate Routing for MCP and AI Traffic: Route by Request Body @devcentral
NGINX Predicate Routing for MCP and AI Traffic: Route by Request Body  @devcentral
Uploaded October 2026 | Updated November 2026, 3 hours ago
Path-based reverse proxying breaks down for AI workloads. MCP clients and AI agents send every request to a single endpoint such as /mcp, so a heavy inference or reporting job looks identical to a lightweight read. This demo shows how NGINX predicate routing, available in NGINX Open Source and NGINX Plus, routes on the request body instead of the URL path.

What the video covers:
- The problem: a proxy that only sees the URL path sends heavy and light MCP requests to the same CPU worker, causing resource contention.
- The workaround and its cost: fragmenting URLs forces developers to hard-code backend infrastructure into client applications, so every backend change can break a client.
- How predicate routing works: NGINX buffers the request body as soon as the connection is established, extracts the tool name from the JSON payload using its native C-based JSON parser, maps it with a regular expression to a dynamic routing variable, and evaluates that variable at runtime in a predicate location block.
- Why it stays fast: the evaluation runs inside NGINX's compiled C memory space, with no Lua or JavaScript interpreter spinning up per request.

Demo walkthrough:
1. Backend setup with two local Model Context Protocol (MCP) servers. Port 8001 is a standard low-resource CPU worker and port 8002 is a high-performance worker for heavy tasks such as database queries and reporting.
2. The traditional configuration, where NGINX acts as a blind reverse proxy. A heavy generate-report request sent to the generic MCP endpoint falls back to the standard worker on port 8001. The client has to switch to a dedicated heavy-worker path to reach port 8002.
3. The predicate routing configuration. Requests to the same /mcp URL with different JSON payloads are routed to different backends, and a custom response header confirms which worker handled each request.

Why it matters: developers keep a single, unbroken API endpoint, and operations teams can apply routing, security, and rate limits based on actual payload intent. The configuration replaces complex map chains, nested if blocks, and Lua scripting with clean declarative syntax that is easier to maintain.

Who it's for: platform engineers, DevOps and NetOps teams, and API owners running MCP servers or other AI agent traffic behind NGINX.

Keywords: NGINX, NGINX Open Source, NGINX Plus, predicate routing, MCP, Model Context Protocol, AI traffic, AI agents, reverse proxy, request body routing, JSON routing, payload-aware routing, load balancing, API gateway

▬▬▬ ABOUT DEVCENTRAL ▬▬▬

We're DevCentral: the how of F5, since 2003. A community of engineers, architects, and IT folks pushing each other forward, one hard-won answer at a time. We dig in, tackle the hard stuff, figure out what actually works, and share what we learn.

Keep going:
Forums, articles, CodeShare: community.f5.com
LinkedIn: linkedin.com/showcase/f5-devcentral
X: https://x.com/devcentral

The DevCentral advocates behind the videos:
Alessandro Fael Garcia → linkedin.com/in/alessfg · github.com/alessfg
Buu Lam → linkedin.com/in/buulam · https://x.com/buulam
Chase Abbott → linkedin.com/in/chaseabbott1
Jason Rahm → linkedin.com/in/jrahm · https://x.com/jasonrahm
Marko Sluga → linkedin.com/in/markosluga
Scott McAllister → linkedin.com/in/stmcallister
NGINX Predicate Routing for MCP and AI Traffic: Route by Request BodyLearning k8s - ep 6 - KCNA exam-prep app is live!Enforce policy-driven AI data delivery with F5 BIG-IPF5 Bot Defense Made Easy - Introducing the new self-service UIMigration from Citrix to F5 DemoWhats new in F5 BIG-IP SSL Orchestrator v14?Exploring Microsoft’s Journey and Future with Wasm | Ep25 | WebAssembly UnleashedBIG-IP APM Access Security IntroDiscover AI Threats with F5 AI Red TeamSimplify & Scale: Hybrid App Delivery with F5 BIG‑IP VE Across Multi‑Cloud and Virtual EnvironmentsOptimize AI data ingestion and S3 cluster reliability with F5 BIG-IPF5 AI Guardrails Agent Security
F5 DevCentral Community |

NGINX Predicate Routing for MCP and AI Traffic: Route by Request Body

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER