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 is a confidential client that 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
DECK_OAUTH_CLIENT_ID and DECK_OAUTH_CLIENT_SECRET in the final step.
Create the MCP Client application
This is a public client that 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 is Insomnia 12+’s built-in OAuth callback. To use a different MCP client later, register that client’s redirect URI here too. The section in Variations and next steps covers this.
- 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 does not 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
The AI MCP OAuth2 Plugin uses the groups claim in access tokens to map users to Kong 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).
- Go to 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)
- Go to 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 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, go to 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 created above, go to the Assignments tab, and assign the same user. Without this, 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. The MCP Client (SPA) Client ID is not exported here. It is used at flow time by the MCP client itself.
export DECK_OAUTH_AUTH_SERVER='https://your-org.okta.com/oauth2/default'
export DECK_OAUTH_INTROSPECTION_URL='https://your-org.okta.com/oauth2/default/v1/introspect'
export DECK_OAUTH_CLIENT_ID='your-kong-gateway-client-id'
export DECK_OAUTH_CLIENT_SECRET='your-kong-gateway-client-secret'
You need a Keycloak instance with admin access. The steps below create a realm, 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 is a confidential client that 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 DECK_OAUTH_CLIENT_ID and this secret as DECK_OAUTH_CLIENT_SECRET in the final step.
Create the MCP Client
This is a public client that 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 is Insomnia 12+’s built-in OAuth callback. To use a different MCP client later, add that client’s redirect URI here too. The section in Variations and next steps covers this.
- 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 does not export it as an environment variable.
Configure the groups claim
By default, Keycloak does not include a groups claim in access tokens. Add a client scope and mapper:
- Go to Client scopes → Create client scope.
- Name it
groups, set 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 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, go to the Groups tab, and join
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. The MCP Client’s Client ID is not exported here. It is used at flow time by the MCP client itself.
export DECK_OAUTH_AUTH_SERVER='https://your-keycloak-host/realms/mcp-demo'
export DECK_OAUTH_INTROSPECTION_URL='https://your-keycloak-host/realms/mcp-demo/protocol/openid-connect/token/introspect'
export DECK_OAUTH_CLIENT_ID='kong-mcp-gateway'
export DECK_OAUTH_CLIENT_SECRET='your-kong-gateway-client-secret'
Keycloak groups claim. Ensure you configured the groups client scope and mapper above. Without it, the access token does not contain a groups claim and Consumer Group mapping fails.