iamops.dev Search
Argo on X RSS feed
ENEnglish

Labs Practitioner · 30 min

For identity engineers registering AI tool clients in Auth0 who need to map each failure to its cause.

Registering an MCP client with CIMD in Auth0: a lab in five checks

Hands-on lab: register an MCP client in Auth0 with a Client ID Metadata Document, and map each failure to the check that causes it, from 302 to 403 to 400.

Lab screenshot cover: One address, three checks. Auth0 reads an MCP client's metadata URL as its client ID and logs each failed login.
TL;DRA client identifier (ID) metadata document (CIMD) is the whole…
  • A client identifier (ID) metadata document (CIMD) is the whole registration: the metadata document at its own web address (URL), with no registration call.
  • Auth0 gives a 302 to login for a valid request, 403 for a redirect address missing from the document, and 400 for a missing or mismatched document.
  • The full login and token exchange are still open, so this lab proves the checks, not the whole sign-in.
  • The server side of the same sign-in is in the no-passthrough lab, where the server refuses token passthrough.
Repeat this lab 5 steps

I wrote this lab so you can run it yourself. Each step has the commands to copy and the output I got, and you can tick it as done. Your ticks stay in this browser only.

Go to the steps

How this works

Copies a ready-made prompt for Claude Code, Cursor, Codex or any coding agent. For test environments only.

Show prompt
I want to run a hands-on lab from iamops.dev, and I would like your help to do it safely.

Lab: Registering an MCP client with CIMD in Auth0: a lab in five checks
Read the whole lab here (Markdown): https://iamops.dev/cimd-mcp-client-registration-auth0.md

What the lab needs before the first step:
- An Auth0 tenant without active Rules
- curl
- Values I have to set myself (the lab uses placeholders): <TENANT>, <MANAGEMENT_API_TOKEN>

How I want you to work:
1. Read the lab from start to finish first (each step lists its own prerequisites). Then check that the prerequisites are in place and that the tool versions match what the lab expects. Tell me what is missing before you run anything.
2. Run one step at a time. Before each command, show it to me and say in a sentence what it does.
3. Ask me before anything that costs money, creates cloud resources, touches a real tenant or account, or deletes anything. Wait for my answer.
4. Use the placeholders from the lab. Never paste real secrets, tokens or production identities into a command, a file or this chat. If a value is needed, tell me where to set it myself.
5. After each step, compare the output with the expected output in the lab. If it does not match, stop and tell me what differs. Do not carry on or invent a fix without asking me.
6. At the end, report what passed, what failed and which cleanup you did. Then offer to tick the steps off for me. The lab page keeps ticks only in my browser, so if you cannot do that, list the steps I should tick.

This lab is for test environments only. Do not run it against production, or against a tenant or account that holds real data or real users.

You may answer in my language.

A client ID metadata document, called CIMD, is a JSON file that an OAuth client publishes at its own URL. The URL becomes the client ID, so a Model Context Protocol (MCP) client needs no registration call before the first sign-in. Auth0 supports this in early access. I used a lab client hosted on GitHub Pages and probed the authorize endpoint on a development tenant.

What I wanted to know: does a wrong redirect address, a missing file and a wrong client ID each fail with a different status code, and can I tie each code to one rule in the document?

Prerequisites#

  • An Auth0 tenant where you can change tenant settings. I used a development tenant.
  • A host you control that serves JSON over Hypertext Transfer Protocol Secure (HTTPS). The lab document is public at https://iamops-dev.github.io/lab-files/cimd/client/metadata.json, served from the iamops.dev lab files repository. To use your own, host it anywhere that serves JSON over HTTPS and replace the address everywhere below.
  • A token for the Management API, with rights to change tenant settings, exported as MGMT_TOKEN.
  • curl and openssl on the machine where you run the probes.
  • No active Rules in the tenant. Auth0 fails CIMD login flows when Rules are active, so move them to Actions first.

Set the tenant domain once and keep it in your shell:

plaintext
export AUTH0_DOMAIN=your-tenant.us.auth0.com
export CIMD_URL=https://iamops-dev.github.io/lab-files/cimd/client/metadata.json

Step 1: Check the tenant#

Ask the tenant whether it advertises CIMD support. The authorization server metadata is public, so no token is needed:

plaintext
curl -s https://$AUTH0_DOMAIN/.well-known/openid-configuration | grep -o '"client_id_metadata_document_supported"[^,]*'

Expected result: "client_id_metadata_document_supported":true. On this tenant, the value is true.

Terminal output: the discovery document of the Auth0 test tenant returns client_id_metadata_document_supported true.
Step 1. The tenant advertises CIMD support. The tenant name is replaced by a placeholder.

To turn the feature on, change the tenant settings. Dynamic registration needs the first flag, and the first flag cannot go off while the second is on:

plaintext
curl -s -X PATCH https://$AUTH0_DOMAIN/api/v2/tenants/settings \
  -H "Authorization: Bearer $MGMT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"client_id_metadata_document_supported": true, "client_id_metadata_document_dynamic_registration_supported": true}'

The PATCH call is covered under Limits. The discovery check above is the only result from this step.

Step 2: Host the metadata document#

The document must sit at the exact URL that is also its client_id. This is the lab document, as served by the lab files repository:

plaintext
{
  "client_id": "https://iamops-dev.github.io/lab-files/cimd/client/metadata.json",
  "client_name": "iamops.dev CIMD lab client",
  "redirect_uris": ["http://localhost:8765/callback"],
  "grant_types": ["authorization_code"],
  "response_types": ["code"],
  "token_endpoint_auth_method": "none"
}

Three things here are the checks Auth0 applies. The client_id equals the address it came from. The redirect_uris list is the only set of callbacks Auth0 accepts. token_endpoint_auth_method is none, because a public client has no secret and relies on PKCE (Proof Key for Code Exchange) instead.

Confirm that the file is served as JSON with a 200 status:

plaintext
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' "$CIMD_URL"

Expected result: 200 application/json; charset=utf-8. The result matches.

Terminal output: the lab metadata document answers 200 with the content type application/json.
Step 2. The document comes back as JSON with status 200.

Step 3: Send the authorize request#

Create a PKCE verifier and its S256 challenge:

plaintext
VERIFIER=$(openssl rand -base64 64 | tr -d '=+/' | cut -c1-64)
CHALLENGE=$(printf '%s' "$VERIFIER" | openssl dgst -sha256 -binary | openssl base64 | tr '+/' '-_' | tr -d '=')

Send the authorize request with the metadata URL as client_id, URL-encoded, and without following the redirect:

plaintext
curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' \
  "https://$AUTH0_DOMAIN/authorize?response_type=code&client_id=https%3A%2F%2Fiamops-dev.github.io%2Flab-files%2Fcimd%2Fclient%2Fmetadata.json&redirect_uri=http%3A%2F%2Flocalhost%3A8765%2Fcallback&code_challenge=$CHALLENGE&code_challenge_method=S256&state=lab1"

Expected result: 302 with a Location that points back at Auth0, to /authorize/resume with a state value. The result matches. The valid request passed every check: fetch, client_id match, redirect address match, and the PKCE fields.

What I saw: 302 to /authorize/resume. The tenant log (below) shows what Auth0 did with it: it created a dynamic client from the document and then stopped the login with no connections enabled for the client. So a 302 here means the document passed the checks, not that a user can sign in yet.

Terminal output: the authorize request with the metadata document address as client ID returns 302 to the Auth0 resume endpoint.
Step 3. A valid request is accepted and sent on to /authorize/resume.
Sequence diagram: an MCP client authorizes with its metadata URL as client ID. Auth0 fetches the document, answers 403 when the redirect address is not listed, and answers 302 to login for a valid request.
One address, three checks. A valid request reaches login, a bad callback gets 403, and a bad document gets 400.
Sequence diagram: the MCP client calls Auth0 authorize with its metadata URL as client ID, Auth0 fetches the document from GitHub Pages and checks the client ID and redirect URI, then answers 302 to login, 403 or 400.
Three outcomes, one fetch. Auth0 downloads the document, compares it with the request, and answers with login, 403 or 400.

Step 4: Preview the document through the Management API#

The preview call validates a document without creating a client. The request shape is:

plaintext
curl -s -X POST https://$AUTH0_DOMAIN/api/v2/clients/cimd/preview \
  -H "Authorization: Bearer $MGMT_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"external_client_id\": \"$CIMD_URL\"}"

The response body is not saved, so it is listed under Limits. Check the response for warnings before you go on, because Auth0 reports unsupported properties as warnings rather than errors.

Failure cases#

Each failure below changes one thing in the Step 3 request, so you can see which check fired.

Terminal output: the valid request returns 302, a wrong redirect address returns 403 and a missing document returns 400.
Failure cases. One change per request, three different answers.
  1. Redirect address not in the document. Change redirect_uri to http://localhost:9999/callback. What you see: 403. Auth0 fetched the document, but the callback is not in redirect_uris, so it refuses the request. Auth0 checks this on every authorization request, not only at first registration.
  2. Document missing. Point client_id at a path that does not exist, for example .../client/missing.json. What you see: 400. Auth0 could not fetch a valid document at the address, so there is nothing to trust.
  3. Client ID mismatch. Serve a document whose client_id differs from its own address, or send a client_id for a different path. What you see: 400. The rule is that the document must name the address it was fetched from, so one client cannot borrow another client’s metadata.

The Auth0 dashboard writes each probe to the tenant log, so the same three failures are visible there with their own wording:

Auth0 dashboard, Monitoring, Logs: two Failed Login entries for an unknown client, two for a callback URL mismatch, two with no connections enabled for the client, and an API Operation entry that creates a dynamic CIMD client.
The tenant log. Cropped to the log table: the bad document paths and the bad callback fail with their own descriptions, and the valid request created a dynamic CIMD client.

The three codes map to three different owners. A 403 is a policy answer about the callback. A 400 is a document problem, either missing or identity-mismatched. The fix for 403 is in the redirect list, and the fix for 400 is in hosting.

Cleanup#

The cleanup steps are listed under Limits. When a manual or dynamic client exists, remove it through the Management API. To switch the feature off, turn the dynamic flag off first, then the support flag, because Auth0 rejects the reverse order:

plaintext
curl -s -X PATCH https://$AUTH0_DOMAIN/api/v2/tenants/settings \
  -H "Authorization: Bearer $MGMT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"client_id_metadata_document_dynamic_registration_supported": false}'

Then send the second PATCH with client_id_metadata_document_supported set to false.

Limits#

  • The settings PATCH in Step 1 is not run. The discovery check is the only result from that step.
  • No connection is enabled for the dynamic client. The log shows no connections enabled for the client, so the login stops there.
  • No full login or token exchange. The authorize request stops at the login redirect, and a sign-in needs a user in a browser. Without it, no code is issued and nothing is exchanged at /oauth/token.
  • No preview response body. The call shape is valid, but the output was not saved, so any warnings are unknown.
  • No Management API lookup of the resulting client by external client ID. The tenant log is the only record of it.
  • No cleanup or tenant reset is run.

The next step is to run the login in a browser, complete the token exchange with the verifier, and then decode the access token to check the client_id claim. That is when the real registration appears in the tenant.

The walkthrough for the same sign-in checks on the MCP server side is in the no-passthrough lab. The token rules for when a client calls a downstream API are in the token exchange article.

Repeat this lab#

You need an Auth0 tenant, a Management API token and curl. You probe the CIMD (client ID metadata document) checks with a lab client you host yourself and watch one change per request move the status code. About 30 minutes. Steps that I have not run yet are marked in the article.

Every value in angle brackets is a placeholder for your own test environment. Nothing on this page is a real identifier or secret.

Set your variables once

bash · env.sh
export AUTH0_DOMAIN='<TENANT>.us.auth0.com'   # your tenant domain
export MGMT_TOKEN='<MANAGEMENT_API_TOKEN>'   # token that may change tenant settings
export CIMD_URL='https://iamops-dev.github.io/lab-files/cimd/client/metadata.json'
Step 1Check that the tenant supports CIMD

Goal. Read the public discovery document and turn on the two CIMD tenant flags if the tenant does not advertise support yet.

Prerequisites

  • An Auth0 tenant without active Rules
  • curl
bash · discovery.sh
curl -s https://$AUTH0_DOMAIN/.well-known/openid-configuration | grep -o '"client_id_metadata_document_supported"[^,]*'
bash · enable.sh
curl -s -X PATCH https://$AUTH0_DOMAIN/api/v2/tenants/settings \
  -H "Authorization: Bearer $MGMT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"client_id_metadata_document_supported": true, "client_id_metadata_document_dynamic_registration_supported": true}'

Expected output

output
"client_id_metadata_document_supported":true
Step 2Host and check the metadata document

Goal. Serve the client metadata document at the exact address that is also its client_id, and confirm it comes back as JSON with status 200.

Prerequisites

  • A host you control that serves JSON over HTTPS, GitHub Pages works
json · metadata.json
{
  "client_id": "https://iamops-dev.github.io/lab-files/cimd/client/metadata.json",
  "client_name": "iamops.dev CIMD lab client",
  "redirect_uris": ["http://localhost:8765/callback"],
  "grant_types": ["authorization_code"],
  "response_types": ["code"],
  "token_endpoint_auth_method": "none"
}
bash · check-doc.sh
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' "$CIMD_URL"

Expected output

output
200 application/json; charset=utf-8
Step 3Send a valid authorize request

Goal. Create a PKCE verifier and challenge, then call /authorize with the metadata URL as client_id and read the status without following the redirect.

Prerequisites

  • curl and openssl
  • The three variables from the first step
bash · pkce.sh
VERIFIER=$(openssl rand -base64 64 | tr -d '=+/' | cut -c1-64)
CHALLENGE=$(printf '%s' "$VERIFIER" | openssl dgst -sha256 -binary | openssl base64 | tr '+/' '-_' | tr -d '=')
REDIRECT='http%3A%2F%2Flocalhost%3A8765%2Fcallback'
bash · authorize.sh
curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' \
  "https://$AUTH0_DOMAIN/authorize?response_type=code&client_id=https%3A%2F%2Fiamops-dev.github.io%2Flab-files%2Fcimd%2Fclient%2Fmetadata.json&redirect_uri=$REDIRECT&code_challenge=$CHALLENGE&code_challenge_method=S256&state=lab1"

Expected output

output
302 https://<TENANT>.us.auth0.com/authorize/resume?state=<STATE>
Step 4Break one check at a time

Goal. Change one thing in the authorize request: a callback that is not in the document, a document path that does not exist, and a client_id for a different path. Compare the status codes.

Prerequisites

  • The valid request from the previous step working
bash · bad-redirect.sh
REDIRECT='http%3A%2F%2Flocalhost%3A9999%2Fcallback'
curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' \
  "https://$AUTH0_DOMAIN/authorize?response_type=code&client_id=https%3A%2F%2Fiamops-dev.github.io%2Flab-files%2Fcimd%2Fclient%2Fmetadata.json&redirect_uri=$REDIRECT&code_challenge=$CHALLENGE&code_challenge_method=S256&state=lab1"
bash · missing-document.sh
curl -s -o /dev/null -w '%{http_code}\n' \
  "https://$AUTH0_DOMAIN/authorize?response_type=code&client_id=https%3A%2F%2Fyour-org.github.io%2Flab-cimd-client%2Fclient%2Fmissing.json&redirect_uri=http%3A%2F%2Flocalhost%3A8765%2Fcallback&code_challenge=$CHALLENGE&code_challenge_method=S256&state=lab1"

Expected output

output
bad redirect address: 403
missing document: 400
client_id mismatch: 400
Step 5Clean up

Goal. Turn the CIMD tenant flags off again in the order Auth0 accepts: the dynamic registration flag first, then the support flag.

Prerequisites

  • Only if you turned the flags on in this lab
bash · flags-off.sh
curl -s -X PATCH https://$AUTH0_DOMAIN/api/v2/tenants/settings \
  -H "Authorization: Bearer $MGMT_TOKEN" -H "Content-Type: application/json" \
  -d '{"client_id_metadata_document_dynamic_registration_supported": false}'
curl -s -X PATCH https://$AUTH0_DOMAIN/api/v2/tenants/settings \
  -H "Authorization: Bearer $MGMT_TOKEN" -H "Content-Type: application/json" \
  -d '{"client_id_metadata_document_supported": false}'

Expected output

output
Both PATCH calls answer 200 and the discovery check no longer shows true.

Sources#

Discuss this on X or LinkedIn

Follow on X

New posts by email

One email a week with new posts and labs. Unsubscribe anytime.

Your address is stored with Kit, which sends the emails. Details

Related research and labs

Type to search every page. Use the arrow keys to move through the results.

    Open the full search page