Skip to content
v1.0.3Apache-2.0

Generic, secure, idempotent and auditable Keycloak administration — discover capabilities and permissions, plan and reconcile realms, clients, scopes, mappers, federation, IdPs, flows, roles, groups, Organizations, snapshots and sanitized/encrypted artifacts via Admin REST API.

Keycloak Power

Keycloak Kiro Power License

The first comprehensive Keycloak Power for Kiro IDE. Manage Keycloak through its Admin REST API and give Kiro grounded workflows for identity architecture, SSO federation, JWT claims, Organizations, and SaaS authorization.

Features

  • Administer realms, clients, users, roles, groups, sessions, events, and client scopes.
  • Configure OIDC, SAML, Google, Microsoft Entra ID, Okta, generic external IdPs, and LDAP/AD guidance.
  • Create and operate Keycloak Organizations for Keycloak 26+ multi-tenant B2B/B2B2C deployments; manage isolated Organization Groups on Keycloak 26.6+.
  • Provision secure BFF clients, fixed SaaS client roles, version-gated LDAP federation inspection, sanitized configuration baselines, and minimal token contracts.
  • Govern changes through environment profiles, capability/permission discovery, target-bound plans, preconditions, audit correlation, snapshots, encrypted artifacts, selective copy and compensating rollback.
  • Manage client scopes, mapper contracts, realms, clients, LDAP/AD, broker IdPs, authentication flows, roles, groups, Organizations, identity reconciliation and cryptographic JWT verification through explicit plan/apply workflows.
  • Inspect JWT structure and claims locally without sending tokens to any service.
  • Design authentication flows, MFA, protocol mappers, and authorization middleware contracts.
  • Use focused skills that distinguish Keycloak authentication from SaaS-domain authorization.

Requirements

  • Kiro IDE with custom Powers enabled.
  • Keycloak 21+ for core Admin REST API operations; Keycloak 26+ and Organizations enabled for organization tools; Keycloak 26.6+ for Organization Groups. The power returns unsupported_feature with the minimum upgrade for older servers.
  • A confidential client with Service Accounts Enabled and a client secret.
  • A service account granted the least-privilege realm-management roles required by the operations you intend to perform. The server uses only Client Credentials Grant; it never uses Resource Owner Password Credentials.
  • Node.js 22+ to run the bundled MCP server.

Quick start

  1. Build the server:
    Set-Location .\mcp-server
    npm ci
    npm run build
    
  2. In Kiro, open Powers, select Add Custom Power, select Import from folder, and choose the keycloak-power directory.
  3. Make these values available to the MCP process:
    KEYCLOAK_URL=https://keycloak.example.com
    KEYCLOAK_REALM=master
    KEYCLOAK_CLIENT_ID=kiro-keycloak-admin
    KEYCLOAK_CLIENT_SECRET=<service-account-secret>
    
  4. Start a new Kiro chat and ask, for example, “Liste os realms do Keycloak” or “Configure Organizations para um SaaS B2B”.

KEYCLOAK_URL may include a reverse-proxy context path, for example https://sso.example.com/auth; trailing slashes are normalized. KEYCLOAK_REALM is the realm where the admin client exists (commonly master), not necessarily the realm being managed.

Configure the Keycloak service account

  1. In the admin console, create a confidential OpenID Connect client, such as kiro-keycloak-admin, in the administration realm.
  2. Turn on Client authentication and Service accounts roles; do not enable Direct Access Grants for this Power.
  3. On Credentials, generate and save the client secret in a secret manager. Do not commit it to the repository or mcp.json.
  4. On Service account roles, select client realm-management and assign only necessary permissions. Typical read-only discovery needs query-realms, query-clients, query-users, and view-realm; realm mutation also needs roles such as manage-realm, manage-clients, manage-users, or manage-identity-providers.
  5. Verify connectivity by asking Kiro to call get_server_info.

Environment configuration

VariableRequiredMeaning
KEYCLOAK_URLYesBase URL of the Keycloak server.
KEYCLOAK_REALMYesRealm that authenticates the service account.
KEYCLOAK_CLIENT_IDYesConfidential client ID for the service account.
KEYCLOAK_CLIENT_SECRETYesSecret for Client Credentials Grant.
KEYCLOAK_TIMEOUT_MSNoPer-request timeout, bounded by the server.
KEYCLOAK_ENVIRONMENTRecommendedLogical environment label bound into plans and audit events.
KEYCLOAK_PROFILENoLogical profile name for the active process.
KEYCLOAK_ALLOWED_HOSTSRecommendedComma-separated Keycloak hosts allowed for the active profile.
KEYCLOAK_ALLOWED_REALMSRecommendedComma-separated target realms allowed for the active profile.
KEYCLOAK_SECRET_SINK_COMMANDFor secret generation/rotationTrusted executable receiving a JSON secret record on stdin.
KEYCLOAK_SECRET_SINK_ARGSNoJSON array of non-secret arguments passed to the sink executable.
KEYCLOAK_SECRET_RESOLVER_COMMANDFor secretRef-backed writesTrusted executable returning one referenced secret on stdout; the value never enters a tool result.
KEYCLOAK_AUDIT_SINK_COMMANDRecommended for durable auditTrusted executable receiving sanitized audit events on stdin.
KEYCLOAK_ARTIFACT_KEYFor encrypted artifacts32-byte base64url/64-hex key held outside the repository.
KEYCLOAK_PROTECTED_REALMSRecommendedComma-separated realms that clone/copy workflows must not mutate as sources.
KEYCLOAK_EXTERNAL_ALLOWED_HOSTSFor metadata/JWKS testsExplicit hosts allowed for external discovery/JWKS validation.
KEYCLOAK_USER_FEDERATION_TESTED_VERSIONFor user-federation adaptersExact version covered by an operator-run integration test.
KEYCLOAK_USER_FEDERATION_TEST_PATHFor connection testExact, version-tested realm-relative Admin REST suffix; no default is assumed.

The Power manifest contains no secret. Use Kiro's environment/secrets configuration or your operating system's environment to provide the values at runtime.

Secret delivery and version gates

create_bff_client requires KEYCLOAK_SECRET_SINK_COMMAND whenever it creates, reconciles, or rotates a BFF client. It sends a JSON record containing type, secretRef, realm, clientId, and the secret through the sink process's stdin, ignores sink stdout/stderr, and returns only { deliveredToVault: true, secretRef }. If Keycloak succeeds and the sink fails, rerun the same target without rotateSecret; the tool reads the current secret again and retries delivery without returning it to chat. Configure the command as a trusted local vault adapter; the MCP server does not implement a vendor-specific vault client or persist secrets.

list_user_federation_providers, get_user_federation_provider, and list_user_federation_mappers require KEYCLOAK_USER_FEDERATION_TESTED_VERSION to exactly match the connected server. test_user_federation_connection additionally requires KEYCLOAK_USER_FEDERATION_TEST_PATH, set only after testing that realm-relative path against that exact Keycloak version. It never accepts a bind password in input.

SkillUse it for
admin-apiSafe, ordered Keycloak Admin REST API administration.
setup-realmRealm bootstrap and security baseline.
setup-clientOIDC/SAML client design and redirect safety.
identity-providersGoogle, Entra ID, OIDC, SAML, and Okta federation.
organizationsKeycloak 26+ Organizations and B2B multi-tenancy.
authentication-flowsBrowser flows, required actions, OTP, and WebAuthn.
token-debugLocal JWT decoding and claim diagnosis.
user-federationLDAP and Active Directory federation planning.
protocol-mappersClaims, audiences, group membership, tenant, and organization mappings.
saas-authorizationMulti-tenant API authorization architecture.
troubleshootingEvents, sessions, client, token, and IdP diagnosis.

MCP tools

DomainTools
Realmslist_realms, get_realm, validate_realm, plan_realm, create_managed_realm, update_managed_realm, plan_realm_clone, clone_realm, plan_delete_realm, delete_managed_realm (legacy direct mutators are blocked)
Clientslist_clients, get_client, update_client (legacy direct mutation blocked; use plan_client + apply_plan), get_client_secret (blocked to prevent secret retrieval)
BFF clientsplan_bff_client, create_bff_client, validate_bff_client (confidential Authorization Code + PKCE S256; secrets go only to the configured vault sink)
Userslist_users, get_user, plan_user_operation, apply_user_operation, plan_role_mapping, apply_role_mapping, plan_identity_reconciliation (legacy direct mutators are blocked)
Roleslist_roles, get_role, plan_role, update_role, delete_role, plan_role_mapping, apply_role_mapping, plan_saas_default_roles, provision_saas_default_roles, assign_saas_client_role, remove_saas_client_role
Groupslist_groups, plan_group, update_group, delete_group, remove_user_from_group, get_group_members (legacy direct mutators are blocked)
Organization Groupsget_organization_groups_capability, list_organization_groups, create_organization_group, move_organization_group, delete_organization_group, assign_organization_group_member (Keycloak 26.6+ only; no realm-group fallback)
Identity providerslist_identity_providers, get_identity_provider, validate_identity_provider_metadata, plan_identity_provider, create_managed_identity_provider, update_managed_identity_provider, delete_managed_identity_provider, plan_clone_identity_provider, clone_identity_provider, generate_broker_callback, get_identity_provider_mapper_types, list_identity_provider_mappers
User federationlist_user_federation_providers, get_user_federation_provider, plan_user_federation_provider, create_user_federation_provider, update_user_federation_provider, delete_user_federation_provider, plan_clone_user_federation_provider, clone_user_federation_provider, list_user_federation_mappers, list_user_federation_mappers_full, plan_create_user_federation_mapper, create_user_federation_mapper, update_user_federation_mapper, delete_user_federation_mapper, test_user_federation_connection, plan_sync_user_federation, sync_user_federation
Organizationslist_organizations, get_organization, plan_organization, update_organization, delete_organization, plan_organization_member, add_member_to_organization_managed, remove_member_from_organization_managed, plan_organization_identity_provider, list_organization_identity_providers, add_identity_provider_to_organization_managed, remove_identity_provider_from_organization_managed
Authenticationlist_auth_flows, get_auth_flow, get_auth_flow_tree, plan_clone_auth_flow, clone_auth_flow, plan_create_auth_flow, create_auth_flow, plan_create_auth_subflow, create_auth_subflow, plan_auth_execution, apply_auth_execution_plan, plan_bind_auth_flow, bind_auth_flow, list_required_actions, update_required_action, validate_flow_safety
Sessions and eventsget_user_sessions, get_server_info, get_realm_events
Tokensdecode_token, get_token_endpoint_info, test_discovery, test_jwks, validate_token_signature, inspect_claim_inventory, test_token_endpoint, validate_token_contract
Protocol mapperslist_protocol_mappers, plan_create_protocol_mapper, create_managed_protocol_mapper, plan_update_protocol_mapper, update_protocol_mapper, plan_delete_protocol_mapper, delete_protocol_mapper, get_effective_token_contract, plan_clone_protocol_mapper, clone_protocol_mapper (legacy direct create blocked)
Artifacts and governanceget_environment_profile, validate_connection, get_server_capabilities, get_admin_permissions, create_snapshot, export_encrypted_baseline, import_encrypted_baseline, plan_resource_copy, copy_resource, get_audit_events
Baseline and token contractexport_sanitized_baseline, diff_sanitized_baseline, validate_token_contract

Tool inputs are validated for required strings and JSON-shaped configuration values. Every REST request surfaces Keycloak's HTTP status and message to make permissions, malformed request bodies, and unsupported server features diagnosable.

Example Kiro conversations

List the clients in the saas realm and show the redirect URIs for portal-web.
Create the acme organization with alias acme, domain acme.example, and add alice as a member.
Decode this JWT and explain why the API isn't receiving the tenant_id claim.
I need a client for an SPA. Use Authorization Code with PKCE, safe origins, and a groups mapper.

Development

Set-Location .\mcp-server
npm ci
npm run build

The server speaks MCP over standard input/output. Do not write log messages to stdout; diagnostics belong on stderr. See CONTRIBUTING.md for development, security, and pull-request rules.

Privacy and support

Documentation sources

The implementation follows the Keycloak documentation and Admin API reference. Organization guidance follows Keycloak's Organizations announcement. Content was rephrased for compliance with licensing restrictions.

License

Copyright 2026 Lucas Magalhães. Licensed under Apache-2.0.

Governed administration

The extended server keeps the existing read tools for compatibility and adds a plan-first control plane. Start with get_environment_profile, validate_connection, get_server_capabilities, and get_admin_permissions. A mutating workflow should then call a plan_* tool, show its sanitized diff and requiredConfirmation, optionally call create_snapshot, and only then call the matching apply tool with planId, planDigest, and the exact confirmation. Plans are held in memory for the current MCP process, include an expiry and a precondition fingerprint, and fail when the target changed after planning.

Core governance tools include plan_resource_operation, get_plan, list_plans, apply_plan, rollback_operation, get_audit_events, create_snapshot, list_snapshots, get_snapshot, plan_snapshot_restore, export_encrypted_baseline, import_encrypted_baseline, plan_resource_copy, and copy_resource. Generic plans reject token/credential endpoints and plaintext secret-shaped fields. Encrypted artifacts use AES-256-GCM with KEYCLOAK_ARTIFACT_KEY; the key and decrypted content never appear in the MCP response.

Extended catalog

AreaTools
Discovery and governanceget_environment_profile, validate_connection, get_server_capabilities, get_admin_permissions, plan_resource_operation, get_plan, list_plans, apply_plan, rollback_operation, get_audit_events
Realms and copyvalidate_realm, plan_realm, create_managed_realm, update_managed_realm, plan_realm_clone, clone_realm, plan_delete_realm, delete_managed_realm, create_snapshot, plan_snapshot_restore
Clients and profilesplan_client, validate_client, plan_delete_client, delete_client, plan_clone_client, clone_client, plan_rotate_client_secret, rotate_client_secret, plan_client_profile
Client scopeslist_client_scopes, get_client_scope, plan_client_scope, create_client_scope, update_client_scope, plan_delete_client_scope, delete_client_scope, plan_clone_client_scope, clone_client_scope, list_client_scope_mappers, plan_create_client_scope_mapper, create_client_scope_mapper, plan_update_client_scope_mapper, update_client_scope_mapper, plan_delete_client_scope_mapper, delete_client_scope_mapper, plan_attach_client_scope, attach_client_scope, plan_detach_client_scope, detach_client_scope
Protocol mappers/contractsplan_create_protocol_mapper, create_managed_protocol_mapper, plan_update_protocol_mapper, update_protocol_mapper, plan_delete_protocol_mapper, delete_protocol_mapper, get_effective_token_contract, plan_clone_protocol_mapper, clone_protocol_mapper
LDAP/AD federationplan_user_federation_provider, create_user_federation_provider, update_user_federation_provider, delete_user_federation_provider, plan_delete_user_federation_provider, plan_clone_user_federation_provider, clone_user_federation_provider, list_user_federation_mappers_full, plan_create_user_federation_mapper, create_user_federation_mapper, update_user_federation_mapper, delete_user_federation_mapper, plan_sync_user_federation, sync_user_federation
Identity providers/brokervalidate_identity_provider_metadata, plan_identity_provider, create_managed_identity_provider, update_managed_identity_provider, delete_managed_identity_provider, plan_clone_identity_provider, clone_identity_provider, generate_broker_callback, list_identity_provider_mapper_types_safe
Flows and required actionsget_auth_flow_tree, plan_clone_auth_flow, clone_auth_flow, plan_create_auth_flow, create_auth_flow, plan_create_auth_subflow, create_auth_subflow, plan_auth_execution, apply_auth_execution_plan, plan_bind_auth_flow, bind_auth_flow, list_required_actions, update_required_action, validate_flow_safety
Users and authorizationplan_user_operation, apply_user_operation, plan_role_mapping, apply_role_mapping, plan_identity_reconciliation, plan_role, update_role, delete_role, plan_group, update_group, delete_group, remove_user_from_group
Organizationsplan_organization, plan_organization_member, add_member_to_organization_managed, remove_member_from_organization_managed, plan_organization_identity_provider, add_identity_provider_to_organization_managed, remove_identity_provider_from_organization_managed, list_organization_identity_providers
Token diagnosticstest_discovery, test_jwks, validate_token_signature, inspect_claim_inventory, test_token_endpoint, validate_token_contract
Artifacts/copyexport_sanitized_baseline, diff_sanitized_baseline, export_encrypted_baseline, import_encrypted_baseline, plan_resource_copy, copy_resource

Secret references

For write operations that need a Keycloak credential, pass a reference such as clientSecretRef, bindCredentialSecretRef, certificateRef, or secretRef. The configured resolver receives the reference and operation metadata through stdin and returns the value only to the in-process request handler. Secret generation and rotation send the generated value to the sink and return only delivery metadata. If the resolver or sink is not configured, the operation fails closed before mutation or before a generated credential can be accepted.

Compatibility and rollback limits

The server probes read capabilities and reports 401/403/404 separately. LDAP test/sync adapters require an exact operator-tested version and explicit test path; Organization Groups require Keycloak 26.6+. Built-in authentication flows are read-only for clone workflows and must be copied before changes. Rollback uses captured before representations where the Admin REST operation is reversible; it does not claim to restore deleted users, external LDAP/Entra state, sessions, already issued tokens, external IdP registrations or secrets invalidated by rotation.