You need an Okta organization with admin access. The steps below create two Okta applications, configure a groups claim, create two groups, set up a test user (new or existing), and export Kong’s introspection credentials.
Create the Kong Gateway application
This confidential client represents Kong as the resource server. Kong uses its credentials to call Okta’s token introspection endpoint.
- In the Okta Admin Console, go to Applications → Create App Integration.
- Select API Services (machine-to-machine).
- Name it
Kong MCP Gateway.
- From the General tab, copy the Client ID and Client Secret under Client Credentials. Export these as
OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET in the final step.
Create the MCP Client application
This public client represents the MCP client (Insomnia, Claude Code, VS Code, or any MCP-compatible tool). Public clients use Authorization Code + PKCE without a client secret.
- In the Okta Admin Console, go to Applications → Create App Integration.
- Select OIDC - OpenID Connect and Single-Page Application, then click Next.
- Name it
MCP Client.
- Set the sign-in redirect URI to
https://app.insomnia.rest/oauth/redirect. This URL is Insomnia 12+’s built-in OAuth callback. To use a different MCP client later, register that client’s redirect URI here too, as described in Variations and next steps.
- On the application’s General tab under Client Credentials, confirm that Proof Key for Code Exchange (PKCE) is checked. Okta enables it by default for SPA app types.
- Copy the Client ID for use in your MCP client. Insomnia and other MCP clients prompt for this value when they start the OAuth flow; the recipe doesn’t export it as an environment variable.
Use the SPA application type, not Web. Okta SPA integrations are public clients with no client secret and use Authorization Code + PKCE by default. MCP clients perform the PKCE flow without sending a client secret, so Okta’s token endpoint rejects the token exchange against a Web (confidential) integration even if PKCE is enabled on it.
Configure the groups claim
Kong’s AI Auth Strategy uses the groups claim in access tokens to map users to AI Consumer Groups. Configure your Okta authorization server to include this claim:
- Go to Security → API → Authorization Servers and select your authorization server (for example,
default).
- Click the Claims tab and add a new claim:
- Name:
groups
- Include in token type: Access Token
- Value type: Groups
- Filter: Matches regex
.* (or restrict to specific groups)
- Click the Scopes tab and ensure
openid is present.
Set up Okta groups and a test user
Create two groups in Okta that match the Kong AI Consumer Group names, plus one user assigned to one of them:
- Go to Directory → Groups and create:
warehouse-ops
customer-support
- Go to Directory → People and either add a new person (for example,
mcp-test-user@example.com) or pick an existing user. Make sure the user has a password set and can sign in.
- Open the user, click the Groups tab, and assign them to
warehouse-ops. To exercise the other persona later, move the same user to customer-support and reauthenticate from your MCP client. The IdP-issued groups claim drives Kong’s ACLs, so changing the user’s group is all that’s needed.
- Open the
MCP Client application, click the Assignments tab, and assign the same user. Without this assignment, Okta blocks the OAuth flow at sign-in.
Export Kong’s Okta endpoints and credentials
Export the authorization server URL, the introspection endpoint, and the Kong Gateway application’s Client ID and Secret. You don’t export the MCP Client (SPA) Client ID here. The MCP client itself uses it at flow time.
export OAUTH_AUTH_SERVER='https://your-org.okta.com/oauth2/default'
export OAUTH_INTROSPECTION_URL='https://your-org.okta.com/oauth2/default/v1/introspect'
export OAUTH_CLIENT_ID='your-kong-gateway-client-id'
export OAUTH_CLIENT_SECRET='your-kong-gateway-client-secret'
You need a Keycloak instance with admin access. The steps below create a realm and two clients, configure a groups claim, create two groups, set up a test user (new or existing), and export Kong’s introspection credentials.
Create a realm
In the Keycloak Admin Console, create a new realm (for example, mcp-demo), or use an existing one.
Create the Kong Gateway client
This confidential client represents Kong as the resource server. Kong uses its credentials to call Keycloak’s token introspection endpoint.
- Go to Clients → Create client.
- Set Client ID to
kong-mcp-gateway.
- Set Client authentication to On (confidential client).
- Enable Service accounts roles.
- From the Credentials tab, copy the Client Secret. Export the Client ID (
kong-mcp-gateway) as OAUTH_CLIENT_ID and this secret as OAUTH_CLIENT_SECRET in the final step.
Create the MCP Client
This public client represents the MCP client (Insomnia, Claude Code, VS Code, or any MCP-compatible tool). Public clients use Authorization Code + PKCE without a client secret.
- Go to Clients → Create client.
- Set Client ID to
mcp-client.
- Set Client authentication to Off (public client).
- Set Valid redirect URIs to
https://app.insomnia.rest/oauth/redirect. This URL is Insomnia 12+’s built-in OAuth callback. To use a different MCP client later, add that client’s redirect URI here too, as described in Variations and next steps.
- Enable Standard flow (Authorization Code) and confirm PKCE is required for public clients (Keycloak enforces PKCE for public clients automatically).
- Note the Client ID (
mcp-client) for use in your MCP client. Insomnia and other MCP clients prompt for this value when they start the OAuth flow; the recipe doesn’t export it as an environment variable.
Configure the groups claim
By default, Keycloak doesn’t include a groups claim in access tokens. Add a client scope and mapper:
- Go to Client scopes → Create client scope.
- Name it
groups and set its type to Default.
- In the scope, go to Mappers → Create mapper:
- Mapper type: Group Membership
- Name:
groups
- Token Claim Name:
groups
- Full group path: Off
- Add to access token: On
- Go to Clients → kong-mcp-gateway → Client scopes and add the
groups scope.
- Repeat for the
mcp-client client.
Set up groups and a test user
Create two groups that match the Kong AI Consumer Group names, plus one user assigned to one of them:
- Go to Groups and create:
warehouse-ops
customer-support
- Go to Users and either add a new user (for example,
mcp-test-user) or pick an existing one. On the Credentials tab, set a password and clear Temporary so the user can sign in directly.
- Open the user, click the Groups tab, and add the user to
warehouse-ops. To exercise the other persona later, swap the user’s group to customer-support and reauthenticate from your MCP client. The IdP-issued groups claim drives Kong’s ACLs, so changing the user’s group is all that’s needed.
Export Kong’s Keycloak endpoints and credentials
Export the realm URL, the introspection endpoint, and the Kong Gateway client’s ID and Secret. You don’t export the MCP Client’s Client ID here. The MCP client itself uses it at flow time.
export OAUTH_AUTH_SERVER='https://your-keycloak-host/realms/mcp-demo'
export OAUTH_INTROSPECTION_URL='https://your-keycloak-host/realms/mcp-demo/protocol/openid-connect/token/introspect'
export OAUTH_CLIENT_ID='kong-mcp-gateway'
export OAUTH_CLIENT_SECRET='your-kong-gateway-client-secret'
Keycloak groups claim. Ensure you configured the groups client scope and mapper above. Without them, the access token doesn’t contain a groups claim and AI Consumer Group mapping fails.