Keycloak — OAuth Setup
This is a briefer guide for self-hosted Keycloak. Verify steps with your Keycloak admin — versions vary.
Step 1: Create or choose a Realm
Use an existing realm or create a new one for the MCP server:
- In the Keycloak Admin Console, select the realm from the top-left dropdown (or create one under Add realm).
- Note the realm name — it appears in all endpoint URLs.
Step 2: Create a Client (the resource server)
- Navigate to Clients → Create Client.
- Client type: OpenID Connect.
- Client ID:
illumio-mcp-server. - Click Next.
- Client authentication: Off (public client — the resource server does not need to authenticate to Keycloak; it only validates tokens).
- Authorization: Off.
- Click Save.
Step 3: Configure the audience
Keycloak access tokens include the aud claim as the client ID by default. Set MCP_OAUTH_AUDIENCE=illumio-mcp-server to match.
Alternatively, add an Audience mapper to include a custom URI:
- In the client, go to Client scopes → illumio-mcp-server-dedicated → Add mapper → By configuration → Audience.
- Name:
mcp-audience - Included Custom Audience:
https://mcp.illumio.example - Add to access token: On.
Step 4: Create a client scope for illumio-mcp.use
- Navigate to Client Scopes → Create client scope.
- Name:
illumio-mcp.use - Type: Optional.
- Click Save.
- Assign this scope to the MCP client registrations (see Step 6).
Step 5: Add a groups mapper
- In the realm, go to Client Scopes → select a shared scope (or the dedicated scope for the MCP client) → Mappers → Add mapper.
- Mapper type: Group Membership.
- Name:
groups - Token Claim Name:
groups - Full group path: Off (emits bare group names, not
/path/to/group). - Add to access token: On.
Verify with your Keycloak admin — the mapper configuration differs between Keycloak versions.
Step 6: Register MCP client applications
For each MCP client, create a new client registration in Keycloak:
- Clients → Create Client.
- Client type: OpenID Connect.
- Client ID: e.g.,
illumio-mcp-claude-desktop. - Authentication: Off (PKCE flow).
- Valid redirect URIs: Set the client’s redirect URI.
- In Client scopes, add
illumio-mcp.useas a default or optional scope.
Step 7: Collect env vars
REALM=your-realm-name
KEYCLOAK_URL=https://keycloak.example.com
export MCP_PUBLIC_URL=https://mcp.illumio.example
export MCP_OAUTH_ISSUER=${KEYCLOAK_URL}/realms/${REALM}
export MCP_OAUTH_JWKS_URL=${KEYCLOAK_URL}/realms/${REALM}/protocol/openid-connect/certs
# Use your custom audience URI or the client ID:
export MCP_OAUTH_AUDIENCE=https://mcp.illumio.example
export MCP_OAUTH_REQUIRED_SCOPE=illumio-mcp.use
# Role mapping — group names as they appear in the groups claim
export MCP_ROLE_GROUPS_ADMIN=illumio-mcp-admin
export MCP_ROLE_GROUPS_OPERATOR=illumio-mcp-operator,illumio-mcp-admin
export MCP_ROLE_GROUPS_READER=illumio-mcp-readonly,illumio-mcp-operator,illumio-mcp-admin
Verify with your Keycloak admin — endpoint paths, realm-specific URLs, and group claim configuration vary across Keycloak versions and deployment types.