Consumer and consumer group mappingv3.14+

Map claims from a validated OAuth2 token to Kong consumers and consumer groups. This lets consumer-aware plugins (such as rate-limiting or ACL) act on MCP traffic without requiring a separate authentication step.

The consumer_claim array sets the path to the claim used for consumer lookup. A single element refers to a top-level claim; multiple elements traverse a nested object. For example, ["sub"] maps the top-level sub claim, while ["realm_access", "user_id"] maps token.realm_access.user_id.

The consumer_groups_claim array works the same way for group membership.

When no consumer is matched, the plugin falls back to credential_claim to set a credential identifier on the request. This allows downstream plugins to identify the caller without requiring a Kong consumer to exist.

If no matching consumer or group is found and you want to allow the request through anyway, set consumer_optional or consumer_groups_optional to true.

Prerequisites

  • At least one Consumer with a username or custom_id matching the value of the configured claim in the access token.

  • At least one Consumer Group matching the values in the groups claim, if using consumer_groups_claim.

Environment variables

  • MCP_RESOURCE_URL: The resource identifier for the MCP server (for example, https://api.example.com/mcp).

  • AUTHORIZATION_SERVER_URL: The authorization server URL (for example, https://auth.example.com).

  • INTROSPECTION_ENDPOINT_URL: The token introspection endpoint. Used by Kong Gateway to validate access tokens.

  • CLIENT_ID: The client ID used by Kong Gateway when calling the introspection endpoint.

  • CLIENT_SECRET: The client secret used by Kong Gateway when calling the introspection endpoint.

Set up the plugin

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!