Internal Only Policy for API Gateway Routes

The Internal Only policy is now available on every API Gateway route, not just in the AI Gateway. It admits a request only when your own gateway made it with context.invokeRoute, and rejects every request that arrives over the network, whatever credentials, headers, or URL it carries.

Use it on routes that only other routes, handlers, and policies on the same gateway should call. Those calls never leave the gateway, so the policy needs no API key and makes no network calls.

Hide REST routes behind your MCP server

The MCP Server handler calls each tool’s route with context.invokeRoute, so your tools keep working while direct calls to the underlying REST routes are rejected. Set status to 404 and a direct call gets the same response as a path that doesn’t exist:

JSONjson
{
  "name": "internal-only-inbound",
  "policyType": "internal-only-inbound",
  "handler": {
    "export": "InternalOnlyInboundPolicy",
    "module": "$import(@zuplo/runtime)",
    "options": {
      "status": 404
    }
  }
}

Put the policy first in the inbound policies of each route the MCP server exposes, and mark those routes x-internal to keep them out of your Developer Portal too. The MCP server route keeps its own authentication for AI clients.

Choose the response

A rejected request gets 403 Forbidden by default. Set status to any client error status, and detail to add a message to the problem response. By default the response has no detail, so callers outside the gateway learn nothing about how the route is called.

Existing AI Gateway configurations that use the earlier Ensure Gateway Internal Invocation Only names keep working unchanged. Use internal-only-inbound and InternalOnlyInboundPolicy in new configurations.

Getting started

Add Internal Only to a route’s inbound policies in the Zuplo Portal and deploy. See the Internal Only policy reference for every option and Keep REST routes private for the full MCP Server setup.