Apply the configuration, connect Insomnia to the aggregated MCP endpoint, then compare the tools that each team gets.
The configuration creates three conversion-only AI MCP Servers (orders, inventory, and customers) with eight tools, one listener AI MCP Server that aggregates them, an OpenID Connect AI Auth Strategy for your IdP, two AI Consumer Groups (warehouse-ops and customer-support), and a CORS Policy. The tools call https://httpbin.konghq.com/anything, which echoes each request. A kongctl namespace scopes every resource, so you can remove this configuration without affecting anything else on the same AI Gateway. See the kongctl documentation for more on namespaces.
Adopt the quickstart AI Gateway into a kongctl namespace so that kongctl can manage it. Adoption adds the KONGCTL-namespace label to the AI Gateway:
kongctl adopt ai-gateway "${KONNECT_CONTROL_PLANE_NAME}" \
--namespace "${KONNECT_CONTROL_PLANE_NAME}" \
--pat "${KONNECT_TOKEN}"
Export the URL that MCP clients use for the aggregated endpoint. Kong advertises it as the protected resource in its OAuth metadata:
export MCP_RESOURCE_URL='http://localhost:8000/ecommerce-mcp'
The IdP values come from the prerequisites. The same configuration works with Okta and Keycloak. Apply the Kong configuration:
cat <<'EOF' > kong-recipe.yaml
_defaults:
kongctl:
namespace: secure-internal-mcp-gateway-recipe
ai_gateway_auth_strategies:
- ref: secure-internal-mcp-gateway-auth
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: secure-internal-mcp-gateway-auth
display_name: secure-internal-mcp-gateway OIDC auth
type: openid-connect
config:
issuer: !env 'OAUTH_AUTH_SERVER'
introspection_endpoint: !env 'OAUTH_INTROSPECTION_URL'
client_id:
- !env 'OAUTH_CLIENT_ID'
client_secret:
- !secret {source: !env 'OAUTH_CLIENT_SECRET'}
auth_methods:
- introspection
cache_introspection: true
scopes:
- openid
consumer_optional: true
consumer_groups_claim:
- groups
consumer_groups_optional: false
credential_claim:
- sub
cache_tokens_salt: secure-internal-mcp-gateway-oidc-cache
ssl_verify: true
hide_credentials: true
ai_gateway_consumer_groups:
- ref: warehouse-ops
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: warehouse-ops
display_name: Warehouse Operations
- ref: customer-support
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: customer-support
display_name: Customer Support
ai_gateway_mcp_servers:
- ref: orders-mcp
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: orders-mcp
display_name: Orders API MCP tools
type: conversion-only
config:
url: https://httpbin.konghq.com/anything
route:
paths:
- /orders-api
max_request_body_size: 1048576
logging:
payloads: true
tools:
- name: list-orders
description: >-
List recent orders with optional filters for status and date.
Returns order summaries including order ID, status, and total.
method: GET
path: orders
annotations:
read_only_hint: true
title: List orders
access:
acls:
allow:
- warehouse-ops
- customer-support
parameters:
- name: status
in: query
required: false
description: Filter by order status (pending, shipped, delivered, cancelled)
schema:
type: string
- name: date
in: query
required: false
description: Filter by order date (YYYY-MM-DD)
schema:
type: string
- name: get-order
description: >-
Get full details for a specific order including line items,
shipping address, and payment status.
method: GET
path: orders/{orderId}
annotations:
read_only_hint: true
title: Get order details
access:
acls:
allow:
- warehouse-ops
- customer-support
parameters:
- name: orderId
in: path
required: true
description: The order ID
schema:
type: string
- name: cancel-order
description: >-
Cancel a pending order. This action cannot be undone.
Only customer support agents can perform cancellations.
method: POST
path: orders/{orderId}/cancel
annotations:
destructive_hint: true
title: Cancel order
access:
acls:
allow:
- customer-support
parameters:
- name: orderId
in: path
required: true
description: The order ID to cancel
schema:
type: string
- ref: inventory-mcp
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: inventory-mcp
display_name: Inventory API MCP tools
type: conversion-only
config:
url: https://httpbin.konghq.com/anything
route:
paths:
- /inventory-api
max_request_body_size: 1048576
logging:
payloads: true
tools:
- name: list-inventory
description: >-
List inventory items with optional filters for category
or low stock alerts.
method: GET
path: inventory
annotations:
read_only_hint: true
title: List inventory
access:
acls:
allow:
- warehouse-ops
- customer-support
parameters:
- name: category
in: query
required: false
description: Filter by product category
schema:
type: string
- name: low_stock
in: query
required: false
description: Set to true to show only items below restock threshold
schema:
type: string
- name: check-inventory
description: >-
Check current stock level, reorder threshold, and product
details for a specific SKU.
method: GET
path: inventory/{sku}
annotations:
read_only_hint: true
title: Check inventory for SKU
access:
acls:
allow:
- warehouse-ops
- customer-support
parameters:
- name: sku
in: path
required: true
description: The product SKU
schema:
type: string
- name: restock-item
description: >-
Add units to a product's inventory. Only warehouse
operations staff can perform restocking.
method: POST
path: inventory/{sku}/restock
annotations:
destructive_hint: true
title: Restock inventory item
access:
acls:
allow:
- warehouse-ops
parameters:
- name: sku
in: path
required: true
description: The product SKU to restock
schema:
type: string
- name: quantity
in: query
required: true
description: Number of units to add to inventory
schema:
type: integer
- ref: customers-mcp
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: customers-mcp
display_name: Customers API MCP tools
type: conversion-only
config:
url: https://httpbin.konghq.com/anything
route:
paths:
- /customers-api
max_request_body_size: 1048576
logging:
payloads: true
tools:
- name: get-customer
description: >-
Retrieve customer profile including name, contact info,
and account status. Only customer support can access
customer data.
method: GET
path: customers/{customerId}
annotations:
read_only_hint: true
title: Get customer details
access:
acls:
allow:
- customer-support
parameters:
- name: customerId
in: path
required: true
description: The customer ID
schema:
type: string
- name: update-customer-contact
description: >-
Update a customer's contact information. Only customer
support agents can modify customer records.
method: PUT
path: customers/{customerId}/contact
annotations:
destructive_hint: true
title: Update customer contact info
access:
acls:
allow:
- customer-support
parameters:
- name: customerId
in: path
required: true
description: The customer ID to update
schema:
type: string
- name: email
in: query
required: false
description: New email address
schema:
type: string
- name: phone
in: query
required: false
description: New phone number
schema:
type: string
- ref: ecommerce-mcp
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: ecommerce-mcp
display_name: Aggregated Ecommerce MCP Server
type: listener
sources:
- orders-mcp
- inventory-mcp
- customers-mcp
access:
acl_attribute_type: consumer
auth_strategies:
- secure-internal-mcp-gateway-auth
metadata:
resource: !env 'MCP_RESOURCE_URL'
endpoint: /.well-known/oauth-protected-resource/ecommerce-mcp
config:
max_request_body_size: 1048576
logging:
payloads: true
audits: true
route:
paths:
- /ecommerce-mcp
protocols:
- http
- https
server:
forward_client_headers: true
policies:
- secure-internal-mcp-gateway-cors
ai_gateway_policies:
- ref: secure-internal-mcp-gateway-cors
ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
name: secure-internal-mcp-gateway-cors
display_name: secure-internal-mcp-gateway CORS
type: cors
config:
origins:
- '*'
methods:
- GET
- HEAD
- PUT
- PATCH
- POST
- DELETE
- OPTIONS
credentials: false
preflight_continue: false
EOF
kongctl apply -f kong-recipe.yaml -o text --auto-approve --pat "${KONNECT_TOKEN}"
rm -f kong-recipe.yaml
Create an MCP client in Insomnia. When Kong rejects the first request, Insomnia reads Kong’s protected resource metadata, finds your IdP, and runs the sign-in.
- In Insomnia, click MCP Clients in the left pane, name the client
Ecommerce MCP, and click Create.
- In MCP Server URL, enter
http://localhost:8000/ecommerce-mcp.
- Click the Auth tab, select OAuth 2.0, set Grant Type to MCP Auth Flow, and enter the Client ID of the
MCP Client application (Okta) or mcp-client (Keycloak). Leave Client Secret empty.
- Click Connect. Kong answers with
401 and a link to its protected resource metadata. Insomnia opens your IdP in the browser.
- Sign in as your test user. Insomnia connects with the IdP token. The Events tab shows each step of the OAuth flow.
The left pane lists the tools that Kong returns for the warehouse-ops group: list-orders, get-order, list-inventory, check-inventory, and restock-item. Kong removed cancel-order, get-customer, and update-customer-contact.
Call check-inventory with sku set to WIDGET-42. The response is httpbin’s echo of the request, with the URL https://httpbin.konghq.com/anything/inventory/WIDGET-42.
If a client calls a tool that its AI Consumer Group can’t use, for example cancel-order, Kong rejects the tools/call request with 403 Forbidden before it reaches the API (ACL evaluation logic).
The groups claim decides the AI Consumer Group, so you change a user’s tools in the IdP, not in Kong.
- In your IdP, remove the test user from
warehouse-ops and add the user to customer-support.
- In Insomnia, disconnect, delete the access token on the Auth tab, and connect again. Sign in when the browser opens.
The tool list now has seven tools: each tool except restock-item.
The Insomnia sessions confirm the following:
|
Behavior
|
Evidence
|
|
OAuth discovery and sign-in
|
Insomnia gets a 401 from Kong, then opens your IdP’s sign-in page without any OAuth endpoint in its configuration.
|
|
One endpoint for three APIs
|
Tools from the orders, inventory, and customers AI MCP Servers appear in one tool list.
|
|
REST-to-MCP conversion
|
check-inventory returns httpbin’s echo of GET /anything/inventory/WIDGET-42.
|
|
Tool ACLs from IdP groups
|
warehouse-ops gets five tools, and customer-support gets seven. Changing the IdP group changes the list after the next sign-in.
|
To review the created entities and the MCP traffic, open the secure-internal-mcp-gateway-recipe AI Gateway in Konnect. For traffic across all your AI Gateways, use the Observability menu.