Aller au contenu
Choisir la langueFrançais

Client ID Metadata Documents (CIMD) Setup

Ce contenu n’est pas encore disponible dans votre langue.

Client ID Metadata Documents (CIMD) let an application use an https URL that serves its metadata as its client_id. Keycloak reads that document, creates one client for the application and reuses it on every later request, so AI clients and MCP servers no longer register a new client for each connection.

A complete setup has two parts: the cimd feature flag on the cluster, which Skycloak applies for you, and a client policy in each realm that decides which metadata URLs are accepted. This page covers both.

  • Minimum version. cimd needs Keycloak 26.6.0 or later. Turning it on for an older cluster is refused in the dashboard, the API, MCP and Terraform, and the message names the flag, the cluster version and the minimum version. Upgrade the cluster first.
  • Plan and access. Feature management is available on the Launch, Business and Enterprise plans. The API and Terraform need an API key with the clusters:read and clusters:write scopes.
  • One flag is enough. cimd is all the CIMD setup needs. resource-indicators is a separate experimental flag with the same minimum version, and turning it on is optional.

Every change to the enabled flags restarts Keycloak on the cluster, and the restart interrupts live sign-ins for a short time.

  • With a maintenance window, a change made through the API, MCP or Terraform stays pending until the next window opens, then moves to applying while Keycloak restarts.
  • With no maintenance window, the change applies at once.
  • With apply now, the restart starts immediately whatever the window says. Use it on a development cluster, or when you have picked a quiet moment for production.

You can set the window on the cluster edit page, see Auto-upgrade & Maintenance Windows.

Each surface sets the complete list of enabled flags. A flag you leave out is turned off, so read the current list first and send it back with cimd added. Flags that only Skycloak can set are never listed and never changed.

  1. Open your cluster’s edit page.
  2. Expand Advanced Keycloak Configuration.
  3. Under Protocol Support, turn on Client ID Metadata Documents. It shows the experimental badge.
  4. Confirm the warning that asks you to accept the risk, then save.

Read the enabled flags and any change still rolling out:

curl "https://api.skycloak.io/clusters/$CLUSTER_ID/features" \
  -H "API-Key: $SKYCLOAK_API_KEY" \
  -H "API-Version: 2026-06-01.beta"
{
  "features": ["token-exchange"]
}

While a change is pending or applying, the response also carries a change object whose state is pending or applying, and features lists the requested set. To see which flags you can enable, with their minimum versions and whether they are experimental, call GET /cluster-features.

Replace the set with PUT:

curl -X PUT "https://api.skycloak.io/clusters/$CLUSTER_ID/features" \
  -H "API-Key: $SKYCLOAK_API_KEY" \
  -H "API-Version: 2026-06-01.beta" \
  -H "Content-Type: application/json" \
  -d '{"features": ["token-exchange", "cimd"], "apply_now": false}'

The response lists the features after the change and sets restarts_keycloak. Its change.state says whether the restart is pending for the window or applying now, and impact describes how disruptive the restart is for the cluster’s size. Set apply_now to true to skip the window. See the API reference for every field.

The Skycloak MCP server has one tool to read the flags and one to replace them:

  • skycloak_get_cluster_features reads the enabled flags and any pending or applying change.
  • skycloak_set_cluster_features replaces the whole set. Pass cluster_id and features. To restart at once, pass apply_now together with confirm, set to true.

The result of the set tool states whether Keycloak restarts, whether the change is pending or applying, and which of the enabled flags are experimental. skycloak_list_cluster_features lists the flags you can enable.

The skycloak_cluster_features resource of the Skycloak Terraform provider owns the cluster’s whole flag set:

resource "skycloak_cluster_features" "cimd" {
  cluster_id = skycloak_cluster.example.id
  features   = ["cimd"]

  # By default the change waits for the maintenance window.
  # apply_now = true restarts at once and waits for Keycloak to finish.
}
  • Changes update the resource in place, and a plan that changes flags warns that Keycloak restarts.
  • Removing a flag from features turns it off. Destroying the resource turns off every flag you set and leaves the ones only Skycloak sets.
  • Import an existing cluster’s flags with terraform import skycloak_cluster_features.cimd $CLUSTER_ID.
  • Use one resource per cluster.

The flag only makes Keycloak able to read metadata documents. Until a realm has a client policy, nothing uses it. Create one profile and one policy in each realm that should accept metadata URLs:

  1. In the realm’s admin console, go to Realm Settings, then Client Policies, then Profiles.
  2. Create a client profile, for example cimd-profile, and add the client-id-metadata-document executor.
  3. Set Trusted domains on the executor to the domains whose metadata documents you accept. An empty list denies every domain.
  4. Go to the Policies tab and create a client policy, for example cimd-policy.
  5. Add the client-id-uri condition with URI scheme https and the same trusted domains. With no trusted domains the condition never matches, so the profile is never applied.
  6. Under Associated client profiles, attach cimd-profile.

The domains depend on the client. Claude Code, for example, uses claude.ai. Using claude.ai itself needs Keycloak 26.8.0 or later and the executor option that accepts a public client with a confidential-client-only grant. The blog post on CIMD for MCP authorization in Keycloak walks through every executor option and the profiles for Claude Code and VS Code.

Send an authorization request to the realm with an https metadata URL as the client_id. Keycloak accepts it and creates one client for that URL. Sending the same request again reuses that client and creates no new one.

To go back, remove cimd from the cluster’s flags with any of the surfaces above. The change restarts Keycloak in the same way.