Keycloak
Sign in to Neurouter with Keycloak over OpenID Connect and send Keycloak group membership as a groups claim for roles and MCP access control.
Neurouter works with Keycloak as a standard OpenID Connect provider, and Keycloak can send group membership in the ID token.
1. Create a client in Keycloak
In your realm, create a client:
- Client type: OpenID Connect; Client authentication: on (confidential client); Standard flow: on.
- Valid redirect URIs:
https://mcp.example.com/api/auth/callback(yourPUBLIC_URLfollowed by/api/auth/callback). - Copy the client secret from the client's credentials.
- Add a Group Membership mapper to the client's dedicated scope, with token claim name
groupsand Add to ID token on. Turn Full group path off if you want plain names such asneurouter-adminsrather than paths such as/neurouter-admins.
See the Keycloak server administration guide for details.
2. Configure Neurouter
OIDC_ISSUER=https://keycloak.example.com/realms/<realm>
OIDC_CLIENT_ID=neurouter
OIDC_CLIENT_SECRET=<client-secret>
OIDC_DISPLAY_NAME="Sign in with Keycloak"
OIDC_SCOPES="openid email profile"
OIDC_GROUPS_CLAIM=groups
OIDC_ADMIN_GROUPS=neurouter-admins
OIDC_AUDITOR_GROUPS=security-auditors
Match the group values exactly as Keycloak sends them: with Full group path on, use /neurouter-admins.
Trying it locally
The repository's Docker Compose file includes a Dex identity provider (docker compose --profile oidc up) for testing OIDC sign-in without Keycloak. For Keycloak, the issuer URL must be reachable both from your browser and from the Neurouter container.
How Neurouter uses the claims
- Claims come from the ID token, merged with userinfo where the token doesn't contain them.
- Users must have an email; if Keycloak reports it as unverified, sign-in is refused.
- Group values are matched against
OIDC_ADMIN_GROUPS,OIDC_AUDITOR_GROUPSand the group mappings in the console at every sign-in.