> For the complete documentation index, see [llms.txt](https://docs.openiam.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-agents.md). Agents can also search and read this documentation through its [MCP server](https://docs.openiam.com/~gitbook/mcp).

# Govern AI agents as non-human identities

Give every MCP client an AI agent record in the non-human identity inventory, set up the SelfService AI assistant's client and the record that switches it on and holds its model connection, register a

**Applies to:** OpenIAM 2026.11.1

## What this is, and when you need it

Every client of the OpenIAM MCP server has an **agent record**: a non-human identity (NHI) of type AI Agent, bound to the client's OAuth 2.0 registration. MCP is the Model Context Protocol, the protocol Claude and other assistants use to call tools on a server. The record is what makes an assistant governable the way a service account is: it names a human sponsor, carries an expiry date and a health score, lists the tools the agent declares it needs, records when it was last used, and can be suspended in one action that also revokes the client's tokens.

Two kinds of agent share the record. An assistant that acts for a signed-in person, such as Claude, gets its record automatically on the first sign-in; the person stays the identity every tool call runs as, and the record is context. An agent that acts alone, with no person in the loop, such as a compliance platform that reads OpenIAM on a schedule, is registered by you: it signs in with its own client credentials and runs as a **service user** the record owns, so its entitlements, its audit trail and its certification look like any other user's.

You are not in the right place if:

* You are deploying the MCP server or connecting Claude for the first time. Start with [Connect AI assistants through the MCP server](https://docs.openiam.com/administration-guide/federation/mcp-server.md). A Claude client's record needs nothing from you beyond one property, described below.
* You want to decide which tools an agent may call, and with what data. That is a policy decision; see [Decide MCP tool calls with policies](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md).
* You are registering a service account, key or bot that does not use the MCP server. Follow [Register a non-human identity](https://docs.openiam.com/administration-guide/nhi/register-an-nhi.md).

## At a glance

|                          |                                                                                                                                                                                                                                                                                                     |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **You will end up with** | One AI Agent record per MCP client, listed under **Webconsole → Non-Human Identities → Inventory** with the **Agents** filter. For an agent that acts alone, a client ID and secret for its operator and a service user whose roles decide its scopes                                               |
| **Where**                | **Webconsole → Non-Human Identities → Inventory → Register agent**; the **Agent** tab of an identity; `idp.ui.properties` and `mcp.ui.properties` for the properties below                                                                                                                          |
| **You need first**       | 2026.10.2 on every component, with the migration applied; the MCP server connected as described in [Connect AI assistants through the MCP server](https://docs.openiam.com/administration-guide/federation/mcp-server.md); `org.openiam.oauth.cimd.agent.owner` set before the first Claude sign-in |
| **Takes**                | Minutes per agent                                                                                                                                                                                                                                                                                   |
| **Reversible**           | Yes — see [Roll it back](#roll-it-back)                                                                                                                                                                                                                                                             |

## Before you begin

* **Set `org.openiam.oauth.cimd.agent.owner`** in `idp.ui.properties` to the user ID of an administrator account, and restart the identity provider (IdP). The IdP creates the record of a self-registering client with that account as owner and sponsor, and refuses to register such a client while the property is empty; the IdP log names the property.
* **Decide whether a new Claude client may be used at once.** `org.openiam.oauth.cimd.agent.approval` ships as `auto`, because the allowed origins already decide which clients may register. Set it to `required` if every new agent must be approved by a person first.
* **For an agent that acts alone**, know its sponsor, the scopes it needs and the tools it needs. The sponsor is an accountable person: under the shipped policies the sponsor's reporting line bounds which people the agent may read, and the sponsor's roles decide whether it may search the audit log.
* **Point Webconsole at the catalog.** Set `org.openiam.mcp.catalog.url` in `webconsole.ui.properties` to the server's catalog document, the same URL the policy service reads, as described in [Before you begin](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md#before-you-begin) on the policies page. Without it the declared-tools picker reports that the catalog is not available.
* **Schedule the two governance jobs.** 2026.10.2 seeds no batch task for the tool-drift job and the orphaned-sponsor job; see [Schedule the jobs](#schedule-the-jobs), which also says how to run either of them at once.
* You hold the rights to register and activate a non-human identity, as described in [Access policies for NHIs](https://docs.openiam.com/administration-guide/nhi/access-policies.md).

## How the record works

|                               | An assistant acting for a person                                                                                                        | An agent acting alone                                                                           |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| **Examples**                  | Claude.ai, Claude Code, any client that signs a person in                                                                               | A compliance platform's scheduled reads, an internal agent, a workflow bot                      |
| **How it obtains a token**    | The authorization code flow, with the person's consent                                                                                  | The `client_credentials` grant, with the client's secret                                        |
| **Who the tool call runs as** | The person who consented                                                                                                                | The record's service user                                                                       |
| **What the record does**      | Supplies context to every policy decision, and is the kill switch                                                                       | Is the principal: its declared tools, drift findings, health and certification govern the agent |
| **How the record is created** | By the IdP on the first sign-in of a client that registers itself; or by the wizard, choosing the **Grant flow** **Authorization code** | By the wizard, choosing the **Grant flow** **Client credentials**                               |

The link lives on the identity: the record stores the ID of the authentication provider that is the client, and a client has at most one record. On every call the server looks the record up from the token's client and keeps it for `org.openiam.mcp.agent.cache.seconds` (60), then admits or refuses the call:

| The client and its record                                                                                                                                           | Result                                                                                                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| An authorization-code client with no record, while `org.openiam.mcp.agent.required` is `false`                                                                      | Admitted as the person, with no agent context: the behaviour of a server before this release                                                                                                                                                                                                                       |
| The same, once `org.openiam.mcp.agent.required` is `true`, or for a client named in `org.openiam.mcp.agent.required.clients` (the AI Assistant's client by default) | Refused with 401 and `The client is not registered as an agent`                                                                                                                                                                                                                                                    |
| The record is a Draft or Pending Approval                                                                                                                           | Refused with 401 and `The client's agent is pending approval`                                                                                                                                                                                                                                                      |
| The record is Suspended or Decommissioned                                                                                                                           | Refused with 401 and `The client's agent is suspended`. The suspension or decommission also revoked the client's tokens, so a client usually meets `The access token is not valid` first; this rule refuses a token the revocation missed. The client cannot repair either by signing in again, which is the point |
| The record's expiry date has passed                                                                                                                                 | Refused with 401 and `The client's agent has expired`                                                                                                                                                                                                                                                              |
| A client-credentials client whose record is Active and owns a service user                                                                                          | Admitted as the service user, with the record as principal                                                                                                                                                                                                                                                         |
| Any other client-credentials client: no record, no service user, or a token minted for another subject                                                              | Refused with 401 and `The access token was not obtained through a user authorization`, as before this release                                                                                                                                                                                                      |

The text quoted is the `error_description` of the 401. The name of the rule that refused the call, such as `AGENT_REQUIRED`, `AGENT_PENDING_APPROVAL`, `AGENT_SUSPENDED`, `AGENT_EXPIRED` or `GRANT_FLOW`, is not sent to the client: it is the `reason` label of the server's `openiam_mcp_auth_failures_total` meter, as listed in [Refusals answered over HTTP](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-server-reference.md#refusals-answered-over-http).

The IdP applies the same rule at its end. A client whose record is not Active receives no token: the token endpoint answers `invalid_client` with `The client's agent is pending approval`, `is suspended`, `is a draft`, `is decommissioned` or `has expired` as the description. Nor does it get a consent page: the authorization endpoint sends the browser back to the client with `error=access_denied` and the same description. The IdP keeps a record for 60 seconds, like the server, so an approval, a new binding, or a change of status or expiry date reaches the token and authorization endpoints up to a minute later.

`org.openiam.mcp.agent.required` ships as `false` so that clients registered before this release keep working. Set it to `true` once every client has a record; a Claude client registered earlier receives its record on its next sign-in, and a client you registered by hand is bound as described in [Bind an existing client](#bind-an-existing-client).

## How a Claude client gets its record

When a client registers itself from its metadata document, as described in [Let an MCP client register itself](https://docs.openiam.com/administration-guide/federation/oauth-and-oidc.md#let-an-mcp-client-register-itself), the IdP creates the agent record in the same request, right after the client:

| Field                                 | Value                                                                                                                                                                                            |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Identity Type                         | AI Agent                                                                                                                                                                                         |
| Name                                  | The client's name as registered, `<client_name> (<host>)`                                                                                                                                        |
| Identifier                            | The URL of the metadata document, which is also the client ID                                                                                                                                    |
| Purpose Statement                     | `MCP client <client_name> calling through the metadata document at <URL>`                                                                                                                        |
| Environment, Risk Classification      | `org.openiam.oauth.cimd.agent.environment` (`PROD`) and `org.openiam.oauth.cimd.agent.risk` (`MEDIUM`)                                                                                           |
| Owner, Backup Owner, AI Agent Sponsor | The account named by `org.openiam.oauth.cimd.agent.owner`. It is the backup owner too: a production record cannot be activated without one, and a self-registered client has nobody else to name |
| Expiry Date                           | Today plus `org.openiam.oauth.cimd.agent.expiry.days` (365)                                                                                                                                      |
| Custom Metadata                       | `ai.invoking_system` = `mcp`, `ai.client_origin` = the host                                                                                                                                      |
| Declared tools, service user          | None. The person's entitlements and the policies decide what the assistant may do                                                                                                                |
| Status                                | Active when `org.openiam.oauth.cimd.agent.approval` is `auto`; submitted for approval, so Pending Approval, when it is `required`                                                                |

With `required`, the person's first sign-in ends at once: the record is created and submitted for approval, then the IdP sends the browser back to the client with `error=access_denied` and `The client's agent is pending approval`, so no consent page is shown and no token is issued. A token issued earlier is refused by the server with 401 and `The client's agent is pending approval`. With the **Agents** filter on, the inventory lists such records under **Agents awaiting approval**, where **Approve** activates one. The person's next sign-in succeeds once the IdP's copy of the record has expired, up to a minute after the approval; a sign-in within that minute still ends with `access_denied`. The approval workflow of [Request and approve registration](https://docs.openiam.com/administration-guide/nhi/request-and-approval.md) applies as well. This is the control for a tenant where a new agent must be looked at by somebody before it answers anyone.

## The SelfService AI assistant's client and record

The AI assistant in SelfService answers a person's questions by calling the MCP server's read tools on their behalf. It cannot reuse the token SelfService already holds: that token comes from an implicit sign-in, which the server refuses, and the IdP offers no token exchange. So 2026.11.1 seeds a client of its own, bound to an agent record, and SelfService obtains a token for it silently in a hidden frame, from the session the person already has. Tool calls then run as the person, with the assistant as agent context, exactly as a Claude client's do.

The migration creates both rows:

| What             | Value                                                                                                                                                                                                                                                                                                                                                                                                 |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OAuth 2.0 client | **AI Assistant**, client ID `openiam-ai-assistant`, under **Access Control → Authentication Providers**                                                                                                                                                                                                                                                                                               |
| Grant flow       | `AUTHORIZATION_CODE_PKCE`, with no client secret: the client runs in the browser, so it is public and proves itself with a PKCE (Proof Key for Code Exchange) verifier instead                                                                                                                                                                                                                        |
| Consent          | Skipped. The person is never asked; the client is first-party and reads only                                                                                                                                                                                                                                                                                                                          |
| Default Scopes   | The three read scopes `openiam:mcp:identity:read`, `openiam:mcp:access:read` and `openiam:mcp:workflow:read`. Never the audit scope                                                                                                                                                                                                                                                                   |
| Token            | 15 minutes, no refresh token, several active per person, so each browser tab holds its own and none of them retires the token SelfService itself uses                                                                                                                                                                                                                                                 |
| Redirect URL     | `https://<host>/selfservice-v2/assistant-callback.html`. See [Set the redirect URL](#set-the-assistants-redirect-url)                                                                                                                                                                                                                                                                                 |
| Agent record     | **AI Assistant**, ID `AI_ASSISTANT_AGENT`, type AI Agent, identifier `openiam-ai-assistant`, owned by the built-in administrator, with no service user and no sponsor: it always acts for whoever is signed in. Seeded Active by 2026.11.1; from 2026.11.2 it ships as Draft, and is the assistant's on/off switch. See [The record switches the assistant on](#the-record-switches-the-assistant-on) |
| Declared tools   | The 23 read tools the assistant calls: every tool of the identity, access and workflow read groups, never `search_audit_events`. See [What the assistant's record shows](#what-the-assistants-record-shows)                                                                                                                                                                                           |
| Who may use it   | The roles **End User** and **Super Security Admin**, which already hold the three scope resources. A token carries only the scopes the person still holds, so anyone outside those roles gets a token the server refuses                                                                                                                                                                              |

The AI assistant service reads the client ID from `assistant.client-id` in `ai-assistant.properties` (environment variable `ASSISTANT_CLIENT_ID`, default `openiam-ai-assistant`) and passes it to SelfService. It checks every token the browser sends at the IdP's introspection endpoint, `/oauth2/introspect`, under `openiam.idp-base` (`OPENIAM_IDP_BASE`, default the origin of `openiam.api-base` plus `/idp`), and uses it only if the IdP confirms it is active and belongs to the same person and to this client. It calls as the assistant's public client, which may introspect its own tokens without a secret because its **Token Introspection** setting is `Own tokens`, as it ships; see [Token introspection](https://docs.openiam.com/administration-guide/federation/oauth-and-oidc/oauth-and-oidc-reference.md#token-introspection). On an install upgraded to 2026.11.2 whose content provider has no `/idp/oauth2/introspect` pattern yet, the gateway sends that request to the sign-in page. The service then cannot check the token, so the assistant answers without the MCP server, and it logs once that **Create default URI patterns** should be pressed. If the IdP refuses the assistant's client as a caller, because its **Token Introspection** setting is not `Own tokens` or its agent record is not Active, the service drops every token it is sent, the assistant answers without the MCP server, and the service logs the refusal once. A token that fails the check is dropped and never used. SelfService then obtains a fresh token and sends the message again, once, so the answer still comes from the MCP server; if no token can be had, the conversation goes on without the MCP server.

### The record switches the assistant on

From 2026.11.2 the **AI Assistant** record does more than carry the assistant's calls: it is the assistant's only on/off switch, and it holds the assistant's model connection, the provider, base URL, model and API key the AI assistant service calls its model with. SelfService offers the assistant only while the record is Active, its expiry date has not passed and it holds a model connection with an API key; the person must still hold the `AI_ASSISTANT` entitlement. The system property `org.openiam.ai.assistant.enabled` that did this in 2026.11.1 is removed.

The 2026.11.2 migration moves a record that is still as seeded back to Draft, adds a model-connection credential to it, and marks it as needing a model connection before it can be activated. So the assistant is off until you add the connection on the record's **Agent** tab and activate the record under the usual rules, with a sponsor and an expiry date. The steps are on [Turn on the AI assistant](https://docs.openiam.com/administration-guide/platform/turn-on-the-ai-assistant.md).

The key gets what every NHI credential gets: an owner and a sponsor through the record, an expiry, a rotated-on date and an audit trail. It is kept in Vault at `vault.secret.nhi.AI_ASSISTANT_AGENT.AI_ASSISTANT_MODEL`, and no screen, API, log or audit record returns it. The record's **Credentials** tab lists it read-only, marked `Managed on the Agent tab`; it is changed only in the **Model connection** section.

### What the assistant's record shows

The record is listed under the inventory's **Agents** filter, and its **Agent** tab works as for any agent, with a **Model connection** section at the top:

* **Model connection** holds the provider, base URL, model and write-only API key the assistant calls its model with, and shows whether the AI assistant service runs on them. See [Add the model connection](https://docs.openiam.com/administration-guide/platform/turn-on-the-ai-assistant.md#add-the-model-connection).
* **Declared tools** lists the 23 tools the assistant calls, seeded by the 2026.11.1 migration. They do not decide what the assistant may do: it acts for a person, so that person's entitlements and the policies decide. They let the drift checker compare what the assistant declares with what people call through it, which otherwise reports every tool as used without being declared.
* **Tool usage, last 30 days** counts the calls people made through the assistant.
* On each call's `MCP_TOOL_CALL` audit event the signed-in person is the principal, with `MCP_PRINCIPAL_KIND` `HUMAN`, and the assistant is the agent, with `MCP_AGENT_NHI_ID` `AI_ASSISTANT_AGENT`.

The shipped policies `MCP - Humans may use the read tools` and the e-mail masking policy apply to these calls. The policies written for an agent acting alone never do, because the assistant is never the principal. To try a stricter policy on the assistant's calls first, put that policy in `SHADOW` as described in [Decide MCP tool calls with policies](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md), read what it would have decided in the decision log, then promote it to `FULL`. The MCP server has no mode of its own to switch.

### When the assistant is suspended

Suspending, decommissioning or letting the record expire switches the whole assistant off, as described in [Suspend or decommission an agent](#suspend-or-decommission-an-agent). Within a minute the **Assistant** entry disappears from SelfService, and a question sent from a page still open is refused with `403`. In that minute the data goes first: SelfService cannot obtain a new token, and the MCP server refuses one it had already accepted, so each question that needs OpenIAM data gets the message `An administrator has switched off the assistant's access to OpenIAM data, so it cannot look this up right now. You can still open the screen that shows it.`, with a button to that screen and no **Retry**. **Activate** the record and the assistant returns, with the model connection it had, within a minute.

A decommission cannot be undone. It deletes the model connection from Vault and clears the record's binding. Only the `AI_ASSISTANT_AGENT` record can switch the assistant on, so binding another AI Agent identity to the `openiam-ai-assistant` client does not bring it back. To stop the assistant, suspend the record rather than decommission it.

### Writes the person confirms in the assistant

The assistant can approve or reject one task, and request access for the person, after the person confirms it on a card. SelfService then sends the same request the **My Tasks** or **Request Access** screen sends, with the header `X-OpenIAM-Assistant-Action: confirmed`. The request's audit event records it as the attribute `AI_ASSISTANT_ACTION` with the value `confirmed`: the decision's `MAKE_DECISION` event, whose child is the workflow's own decision event, and the request's `CREATE_ACCESS_REQUEST_UI` event. The same decision made on **My Tasks** carries no such attribute. The header is a record of where the action came from, never a permission: the person needs the same rights either way.

### Before the assistant can call the server

* **Rebuild the authorization graph** after the migration, as described in [Rebuild the authorization graph](https://docs.openiam.com/administration-guide/operations/rebuild-the-authorization-graph.md), so the role grants of the new client take effect.
* **Point the policy service at the catalog.** Without `org.openiam.pbac.mcp.catalog.url` no MCP action group exists, no policy permits a person's call, and every call through the assistant answers `NOT_PERMITTED`. See [Before you begin](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md#before-you-begin) on the policies page.

### Set the assistant's redirect URL

The IdP compares redirect URLs exactly, so the client must list the address people reach SelfService on. The migration registers it when it can tell: when exactly one host is bound to the default read-only client, and that host is a literal name such as `sso.example.com` or `sso.example.com:8443` rather than a pattern. Otherwise, on a fresh installation, where the content provider is created after the migration runs, or with several hosts, it registers the placeholder `localhost.openiam.com`.

{% stepper %}
{% step %}
In Webconsole, go to **Access Control → Authentication Providers** and open **AI Assistant**.
{% endstep %}

{% step %}
In **Redirect URL**, enter `https://<host>/selfservice-v2/assistant-callback.html`, with the host people use for SelfService.
{% endstep %}

{% step %}
Add one such URL for every other host SelfService answers on.
{% endstep %}

{% step %}
Remove the `localhost.openiam.com` entries, unless the host really is `localhost.openiam.com`.
{% endstep %}

{% step %}
Click **Save**.
{% endstep %}
{% endstepper %}

Use `https`. A plain `http` URL would let the authorization code cross the network unencrypted.

### Make the assistant opt-in

By default everyone with **End User** may use the assistant's MCP tools. To restrict it to a role of your choosing:

{% stepper %}
{% step %}
Remove **End User** from the entitlements of the **AI Assistant** client resource.
{% endstep %}

{% step %}
Remove **End User** from the three `openiam:mcp:*:read` scope resources.
{% endstep %}

{% step %}
Grant the client resource and the three scope resources to the role that should have the assistant.
{% endstep %}

{% step %}
Rebuild the authorization graph.
{% endstep %}
{% endstepper %}

Removing **End User** from the scope resources also withdraws the read tools from that role's other MCP clients, such as Claude. To stop the assistant alone without touching anyone's entitlements, suspend its agent record, as described in [Suspend or decommission an agent](#suspend-or-decommission-an-agent): SelfService takes the assistant away, the IdP issues it no token and the server refuses the ones already issued. An AI Agent cannot be activated without an **AI Agent Sponsor** and an expiry date, and the assistant's record not without a model connection, so check all three before you activate it again.

## Register an agent that acts alone

{% stepper %}
{% step %}
Open **Webconsole → Non-Human Identities → Inventory** and choose **Register agent**. The wizard has four steps: **Identity**, **Client**, **Tools** and **Review**.
{% endstep %}

{% step %}
Under **Identity**, fill in the record as on [Register a non-human identity](https://docs.openiam.com/administration-guide/nhi/register-an-nhi.md): a **Name**, the **Environment** and **Risk Classification**, an **Expiry Date**, a **Purpose Statement**, the **Owner** and the **AI Agent Sponsor**. The **Owner** starts as your own account, shown by its user ID until you choose a person.

The wizard has no **Backup Owner** field, and its **Environment** starts as **Prod**, which needs a backup owner before the record can be activated, as do the **High** and **Critical** risk classifications. Either choose another environment, or add the backup owner on the edit form before you activate the record.

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-9d5f81365eb63789336eebbe895d0c00cdbcce45%2Fmcp-register-agent-identity.png?alt=media" alt="The Identity step of the Register an agent wizard, filled in for hr-reporting-agent: its purpose statement, AI Agent Sponsor sys user, Owner shown as the user ID 3000, Expiry Date Oct 27, 2027, Environment PROD and Risk Classification MEDIUM"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Under **Client**, enter a **Client name** and choose the **Grant flow** **Client credentials**. The other flow, **Authorization code**, is for a vendor assistant that signs people in but publishes no metadata document: it needs a **Callback URI**, creates no service user, and the rest of this procedure does not apply to it. The wizard always creates a new client: a client you registered by hand is bound to a record from the record's **Agent** tab instead, as described in [Bind an existing client](#bind-an-existing-client).
{% endstep %}

{% step %}
Under **Tools**, pick the tools the agent declares from the catalog. You can change the list later on the **Agent** tab.

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-217bf6184edb246994d22e45b9f410c3eb6fb813%2Fmcp-register-agent-tools.png?alt=media" alt="The openiam:mcp:identity:read group of the wizard&#x27;s Tools step, with get_user, list_direct_reports and whoami ticked and get_organization, search_organizations and search_users left clear, each with its description from the server&#x27;s catalog"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Under **Review**, check the summary and choose **Create agent**. The wizard creates the record, the client and, for client credentials, the service user, and binds them to each other. Its last screen shows the client ID and the secret under the warning `This is the only time this secret is shown`: copy the secret now for the agent's operator and store it outside OpenIAM, because it cannot be read again, not on the **Agent** tab and not on the client's page. **Done** and **Open agent** ask `Leave without copying the secret?` if you have not copied it, and the browser asks before a reload or a tab close. A lost secret is replaced, not recovered: see [Replace a lost secret](#replace-a-lost-secret).

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-ce5b51c80e596a7e9c39aa25e637ae8c8c1b4a92%2Fmcp-register-agent-secret-once.png?alt=media" alt="The wizard&#x27;s last screen with all four steps ticked, under the warning This is the only time this secret is shown and its advice to store the secret outside OpenIAM, showing the client ID"><figcaption></figcaption></figure>

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-353bfac70e72dfa89598074c30f32b0accfb3bcb%2Fmcp-register-agent-leave-without-copying.png?alt=media" alt="The Leave without copying the secret? confirmation, explaining that the secret cannot be shown again and that the only way to give an application a working secret is to regenerate it, with the buttons Go back and copy it and Leave anyway"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
The record is a **Draft**. Activate it, or request approval, from the edit form as described in [Lifecycle and status](https://docs.openiam.com/administration-guide/nhi/lifecycle.md). Until it is Active the IdP refuses the client's token requests with `invalid_client`, and the server refuses any token it holds with `The client's agent is pending approval`.
{% endstep %}
{% endstepper %}

### The client the wizard creates

| Setting                      | Value                                                                                                                  |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **Authorization Grant Flow** | `CLIENT_CREDENTIALS`, or `AUTHORIZATION_CODE` for the other choice                                                     |
| **OAuth Client**             | Request body, with a generated client ID and secret                                                                    |
| **Default Scopes**           | Every `openiam:mcp:*` scope resource the deployment has                                                                |
| **Use Refresh Token**        | Off for client credentials: the agent asks for a new token with its secret when one expires. On for authorization code |
| **Redirect URL**             | The callback URI you entered; `urn:ietf:wg:oauth:2.0:oob` for a client that never redirects                            |
| **Token expiration**         | 60 minutes                                                                                                             |
| **Multiple Active Tokens**   | Allowed                                                                                                                |
| **Signing Algorithm**        | `RS256`                                                                                                                |

The client's resource is made public, so the entitlement check does not refuse its subject. Everything else is as for a client registered by hand under **Access Control → Authentication Providers**, where the client can be edited afterwards.

### The service user

Every agent that acts alone owns one user record, created by the wizard. It is what the agent's tool calls run as, so the organization and delegation scoping the backend applies to any requester applies to the agent, and it is the target user on the agent's audit events.

| Field        | Value                                                                                                                                                                               |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Login        | `nhi:<NHI_ID>`, on the default managed system                                                                                                                                       |
| Name         | The record's name as the first name, `agent` as the last name                                                                                                                       |
| User type    | NHI service account (`NHI_SERVICE`), as the user type. A service user created before 2026.11.1 carried it as the employee type, and is moved to the user type when a bind reuses it |
| Status       | Active; disabled when the identity is suspended, deleted when it is decommissioned or when the bind that created it fails                                                           |
| Credentials  | None. It cannot sign in to Webconsole, SelfService or any application                                                                                                               |
| Organization | The sponsor's organization                                                                                                                                                          |

### Grant the scopes

The agent receives an OAuth scope only through the service user's entitlement to the scope resource, exactly as a person does: the IdP filters the client's scopes by the service user's entitlements when it issues the token. Create a role for agents, entitle it to the `openiam:mcp:*:read` scope resources the agent needs under **Access Control → Resources**, and add the role to the service user as described in [Grant and revoke access](https://docs.openiam.com/administration-guide/identities/grant-and-revoke-access.md). [Decide who may use it](https://docs.openiam.com/administration-guide/federation/mcp-server.md#decide-who-may-use-it) explains the four scopes.

The service user's roles also matter to policy. Under the shipped policy pack the audit tool is refused unless the principal, or for an agent acting alone its sponsor, holds the administrator role the policy names; see [The starter pack](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md#the-starter-pack).

## Bind an existing client

A client you registered by hand, as described in [A client without a metadata document](https://docs.openiam.com/administration-guide/federation/mcp-server.md#a-client-without-a-metadata-document), is bound from the record's **Agent** tab: choose **Bind client**, then **Use an existing client**, search the client by name and choose **Bind**. The same dialog offers **Create a new client**, which creates one as the wizard does, and **Bind another client** replaces a binding. The edit form's **Agent client** section shows the binding too. For a client on the `CLIENT_CREDENTIALS` flow the service user is created at binding; without one the IdP refuses the client with `invalid_client` and `The client's agent has no service user`.

Binding is refused for a decommissioned record and for a client already bound to another record, and binding the same client again changes nothing. The service user is created before the binding is written, from 2026.11.1: a bind that fails afterwards deletes the service user it created, and a bind that runs again, because you retried it or the service did, reuses the service user an earlier attempt left instead of failing. A bind is refused when the login `nhi:<NHI_ID>` belongs to a user who is not a service user, so an agent never acts as a person who happens to hold that login. The binding is recorded in the record's audit trail as a `CLIENT_BOUND` lifecycle event. The client's own settings do not change. The IdP keeps its copy of the record for 60 seconds, so for up to a minute after a binding it can still issue a client-credentials client a token for the built-in administrator `0001`, as it did while the client was unbound; request the token again after a minute. A bound client cannot be deleted under **Access Control → Authentication Providers** until its record is decommissioned; the deletion is refused with `AUTH_PROVIDER_BOUND_TO_NHI`.

When **Create a new client** creates the client, the dialog shows its secret once, with the same warning and the same `Leave without copying the secret?` question as the wizard.

## Replace a lost secret

From 2026.11.1 a client secret is shown once, when it is issued, and OpenIAM cannot show it again: no screen and no Webconsole API call returns a stored secret. When the operator has lost it, issue a new one:

{% stepper %}
{% step %}
Open the client under **Access Control → Authentication Providers**. The edit page shows the **Client ID**, and the **Client Secret** masked.
{% endstep %}

{% step %}
Choose **Regenerate secret**, and confirm with **Regenerate**. The new secret replaces the current one at once: an application that still uses the old secret can no longer get tokens. Tokens already issued stay valid until they expire.
{% endstep %}

{% step %}
Copy the new secret from the dialog that shows it, once, and give it to the agent's operator.
{% endstep %}
{% endstepper %}

**Regenerate secret** is not offered for a read-only client, nor for a client that authenticates without a secret.

## Declare the tools an agent needs

An agent declares the tools it needs as declared scope entries on the identity, of resource type `MCP_TOOL` with the tool name as the resource and `READ` as the access right. The **Declared tools** panel of the **Agent** tab fills them from the server's catalog, read from `org.openiam.mcp.catalog.url` in `webconsole.ui.properties`, so you pick names rather than type them; while that property is empty the panel reports that the catalog is not available. A declared tool the catalog does not list is marked **Not in the catalog**. The identity's edit form lists the same entries under **Declared Scope**, by tool name, as **MCP tool** rows that cannot be changed there, with a hint pointing to the **Declared tools** panel; saving the form keeps them as they are.

Declared tools do three things:

* The shipped policy `MCP - Active agent may call a declared tool` permits an active agent acting alone to call a tool it declared, and nothing else; see [A call runs only when a policy permits it](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md#a-call-runs-only-when-a-policy-permits-it) for why every caller needs a permit.
* Any policy can test `context.mcp.declaredTool` and `principal.declaredToolIds`.
* The drift checker compares them with the tools the agent uses, as described in [Drift findings and health](#drift-findings-and-health).

`MCP - Active agent may call a declared tool` reads, as seeded:

{% code overflow="wrap" %}

```
permit(principal is Openiam::Nhi, action in Openiam::McpTool::Action::"openiam:mcp", resource)
when { context.mcp.declaredTool == true && principal.status == "A" };
```

{% endcode %}

A change to the list reaches the server within `org.openiam.mcp.agent.cache.seconds` (60). The IdP declares no tools for a Claude client: an assistant acting for a person is governed by that person's entitlements and by policy, not by a list. The drift checker does not make that distinction, so a Claude client's record collects a finding for every tool people call through it; see [Drift findings and health](#drift-findings-and-health).

## Read the Agent tab

Open an AI Agent identity. Next to the tabs every identity has, an **Agent** tab shows what the bound client has been doing:

| Panel                        | What it shows                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Bound client**             | **Client name**, **Client ID**, **Grant flow**, **Authentication**, **Service user**, **Active tokens** and **Last used** (**Never** until the first call, then a day such as **today** or **3 days ago**; recorded at most once per `org.openiam.mcp.agent.lastused.throttle.seconds`, 300). **Active tokens** is how many access tokens of the client are live, counted through the service user, so zero after a suspension; for a client with no service user, such as a Claude client, it reads **Not counted without a service user**, because that client's tokens belong to the people who consented to it, and OpenIAM counts tokens per user, not per client. A dash means the count could not be read. When no client is bound, **Bind client** instead |
| **Client credentials**       | The client ID. The secret is shown once, by the wizard or the **Bind client** dialog that created the client, and never on this tab                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| **Declared tools**           | The list above, with the picker                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Tool usage, last 30 days** | **Calls**, **Not permitted** and **Last called** per **Tool**, from the audit log; a tool the agent did not declare is marked **Undeclared**. The window can be widened to a year                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| **Drift findings**           | Each reads "Called `<tool>` without declaring it" or "Declared `<tool>` but has not called it", with the calls and when it was last seen, and its status: **Open**, **Acknowledged** or **Resolved**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **Suspend agent**            | The kill switch, with its effects spelled out in the confirmation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| **Model connection**         | Only on an agent that needs one, such as **AI Assistant**: the provider, base URL, model, API key and expiry of the credential it calls its model with, and its **Status**. See [The record switches the assistant on](#the-record-switches-the-assistant-on)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-cc3a92af5e7c6dc020b1a3e11c66b72d79d2c2d5%2Fmcp-agent-tab-bound-client.png?alt=media" alt="The detail page of hr-reporting-agent, an Active PROD AI Agent, on its Agent tab: the Bound client panel lists client hr-reporting-agent-client, its client ID, grant flow Client credentials, authentication REQUEST_BODY, the service user ID, Active tokens 1, Last used today and AI Agent Sponsor sys user, with the Suspend agent button"><figcaption></figcaption></figure>

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-99bdacaa32d85a42ff8a5ad0ce9bd4a740e906ba%2Fmcp-agent-tab-usage-and-drift.png?alt=media" alt="The Tool usage, last 30 days panel with 6 calls, 3 not permitted, for get_user, list_access, list_direct_reports, list_my_requests marked Undeclared, and whoami; below it the Drift findings panel with the open finding Called list_my_requests without declaring it and four resolved findings that a declared tool had not been called"><figcaption></figcaption></figure>

The inventory gains an **Agents** filter, which lists AI Agent identities that have a bound client.

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-cb2c31c89b4bdac4cde20e8763b0f17ec3af4dd3%2Fmcp-inventory-agents.png?alt=media" alt="The Non-Human Identities inventory with the Agents filter and the Prod environment selected, listing two AI Agent records owned by sys user: Claude Code (claude.ai), created by a Claude Code sign-in, with health score 60, and hr-reporting-agent with health score 85"><figcaption></figcaption></figure>

## Suspend or decommission an agent

Suspending or decommissioning the identity is the kill switch. It happens when you choose **Suspend agent** on the **Agent** tab, or **Suspend** or **Decommission** in the header of the identity's detail page; when the expiry job suspends an expired identity; and when the sponsor job suspends an orphaned one. **Suspend agent** asks first, and its confirmation says what follows: the server refuses the agent's next tool call within a minute, its tokens stop working and the client cannot mint new ones, and the record stays suspended until somebody activates it again. The header's **Suspend** and **Decommission** act at once, with no confirmation, and a decommission cannot be undone. Underneath, three things happen that a status change did not do before this release:

1. Every access token and refresh token of the bound client is revoked.
2. The service user, where there is one, is disabled on a suspension and deleted on a decommission.
3. The IdP refuses new tokens, with `invalid_client` and `The client's agent is suspended`, and sends a sign-in back with `access_denied`, while the identity is not Active.

Each outcome is a lifecycle event in the record's audit trail: `TOKENS_REVOKED`, or `TOKEN_REVOKE_FAILED` and `SERVICE_USER_UPDATE_FAILED` when a step could not be completed. A failed step is reported, never rolled back, so read the trail after a suspension you rely on.

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-2665802f72fa883a50a30b80c40921918a0bd74e%2Fmcp-suspend-agent-confirm.png?alt=media" alt="The Suspend hr-reporting-agent? confirmation: suspending the agent stops it at once, the MCP server refuses its next tool call within a minute, its tokens stop working and the client cannot mint new ones, and the record stays suspended until someone activates it again, with Cancel and Suspend buttons"><figcaption></figcaption></figure>

The server keeps the agent record for up to 60 seconds and reads it again on every call, including a call with a token it checked in the last 30 seconds, so the next call is refused as soon as the server's copy of the record changes: at once after a change in Webconsole, at most 60 seconds after one made any other way. A 401 for a token the server had already checked carries `The client's agent is suspended`; one for a token it meets for the first time carries `The access token is not valid`, because the revoked token no longer exists. The body of every 401 names the reason as `reason`, `AGENT_SUSPENDED` or `UNKNOWN`, which the auth-failure meter counts too. A refresh of the client's tokens is refused with `invalid_client` and `The client's agent is suspended`. When a person is behind the client, Claude reports that the server needs authentication; signing in again ends with `access_denied` and the same description until the identity is activated again.

**Activate**, which the header offers on a suspended identity, returns it to Active with an `ACTIVATED` lifecycle event and re-enables the service user. Revoked tokens are not restored: an agent signs in again, and a person consents again. **Decommission** is terminal: it also clears the binding, after which the client can be deleted. Until it is deleted, the client is treated as one with no record: admitted with no agent context, unless `org.openiam.mcp.agent.required` is `true` or `org.openiam.mcp.agent.required.clients` names it, as it names the AI Assistant's client by default.

For the **AI Assistant** record, a suspension or a decommission also switches the SelfService assistant off, and a decommission deletes its model connection from Vault; see [When the assistant is suspended](#when-the-assistant-is-suspended).

## When the sponsor leaves

The governance job `ORPHANED_AGENTS` suspends every AI Agent identity whose sponsor is no longer an active user, records a `SUSPENDED` lifecycle event with the comment `Auto-suspended: sponsor inactive` and no actor, and mails the owner on the `NHI_SPONSOR_INACTIVE` template; a record with no sponsor recorded is skipped. The kill switch applies, so the agent's tokens are revoked. To bring the agent back, set a new **AI Agent Sponsor** first, then **Activate** it; without a sponsor the identity does not pass the activation requirements in [Lifecycle and status](https://docs.openiam.com/administration-guide/nhi/lifecycle.md#activation-requirements). The job runs only once it is scheduled, or when you run it on demand, as described in [Schedule the jobs](#schedule-the-jobs).

## Drift findings and health

For an AI Agent identity with a bound client, a second drift job, `TOOL_DRIFT`, sits next to the declared-scope drift job described in [Health and governance](https://docs.openiam.com/administration-guide/nhi/governance.md). It compares the tools the agent **used**, counted from the `MCP_TOOL_CALL` audit events of the last `org.openiam.nhi.drift.unused.days` (90), against the tools it **declared**:

| Finding                | Meaning                                                                                                                                                                                                           |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UNDECLARED_TOOL_USED` | The agent called a tool it did not declare within the last `org.openiam.nhi.drift.window.days` (30). A drift finding: either the declaration is incomplete, or the agent is doing more than it was registered for |
| `DECLARED_TOOL_UNUSED` | The agent declared a tool it has not called for `org.openiam.nhi.drift.unused.days` (90). A hygiene finding: remove the declaration                                                                               |

The job treats every AI Agent with a bound client alike, including the record the IdP creates for a Claude client. That record declares no tools, so each tool people call through Claude becomes an `UNDECLARED_TOOL_USED` finding on it, and its **Entitlement fit** loses 5 points per open finding, at most 20. No shipped policy reads that score for a person's call: `MCP - Unhealthy or dormant agents are refused` governs agents acting alone, as its principal shows:

{% code overflow="wrap" %}

```
forbid(principal is Openiam::Nhi, action in Openiam::McpTool::Action::"openiam:mcp", resource)
when { principal.healthScore < 60 || principal.lastUsedDaysAgo > 90 };
```

{% endcode %}

The job counts calls by client ID, so a record also inherits the calls its client made before the record was created or bound, with their original dates.

A finding is raised once, mailed to the owner on the `NHI_SCOPE_DRIFT` template, and kept while it holds; it becomes Resolved when the usage no longer supports it, and is reopened if it returns. An acknowledged finding stays acknowledged. Findings are listed on the **Agent** tab and in the identity's **Drift Detection** panel. The job reads the audit log in pages of `org.openiam.nhi.drift.audit.page.size` (500), at most `org.openiam.nhi.drift.audit.max.pages` (40) of them, and keeps the usage it found for `org.openiam.nhi.drift.usage.cache.seconds` (600), so the health score does not sweep the log on every save.

Three health dimensions change for an agent with a bound client. **Activity** starts scoring as soon as the server records a last-used time. **Entitlement fit**, neutral before this release, now costs 5 points per open drift finding, at most 20. A new **Denial rate** dimension costs 10 points when more than a fifth of the agent's calls over the window were refused by a policy, and is not evaluated until the agent has made a call: an agent that is refused often is misconfigured or probing. The score is recomputed when the identity is saved, changes status or is bound, and by the nightly rescore, not when the drift job runs: a finding the job opens or resolves moves the score at the next rescore. The shipped policy `MCP - Unhealthy or dormant agents are refused` refuses an agent acting alone whose score is below 60 or that has not been used for over 90 days. It is enforced from 2026.11.1, unless you had changed it before the upgrade.

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-b62e24071ec4391b7c23bda0fb053750540b989e%2Fnhi-health-score-agent.png?alt=media" alt="The Health Score card of hr-reporting-agent: 85, Healthy, with Entitlement fit at -5 points for open drift findings between the declared and the used tools, Denial rate at -10 points because more than a fifth of its tool calls were refused by policy, Credential age and Segregation of duties not evaluated yet, and the other dimensions at 0 points"><figcaption></figcaption></figure>

### Schedule the jobs

2026.10.2 seeds no batch task for `TOOL_DRIFT` or `ORPHANED_AGENTS`, so neither runs until you create one. Follow [Create a batch task](https://docs.openiam.com/administration-guide/automation/batch-tasks.md) twice, with the execution type **Execute a Spring Bean**, the bean `nhiGovernanceInitializer.perform`, the job code as the task's parameter, and a nightly cron; the shipped `NHI Dormancy Notice` and `NHI Expiry Auto-Suspend` tasks are the pattern. The sponsor job's mail needs the `NHI_SPONSOR_INACTIVE` template, which 2026.10.2 does not seed either; create it under **Administration → Mail and notifications** from the `NHI_DORMANCY_WARNING` template. It also needs an owner with an e-mail address: the mail to an owner without one is not sent, and the e-mail service logs `Send notification failed. User <ID> has no email address on file`.

To run a job at once, for example while you set the feature up, call the Webconsole REST API from a signed-in Webconsole session as an administrator: `POST /webconsole/rest/api/nhi/governance/run?job=TOOL_DRIFT`, or `job=ORPHANED_AGENTS`. The call needs the session's cookie and its cross-site request forgery (CSRF) token, as every Webconsole call does; a bearer token alone is refused. It answers 200 once the job has run, and the NHI service log reports what the job found, in a line that ends `5 finding(s) raised` or `1 agent(s) suspended`. The same call with `job=HEALTH` runs the nightly rescore. A batch task is still what runs the jobs every night.

## Verification

Request a token for an agent that acts alone, then call `whoami` with it. The client authenticates in the request body here; a client set to Basic authentication passes the ID and secret in the `Authorization` header instead.

{% code overflow="wrap" %}

```bash
curl -s -X POST https://<OPENIAM_HOST>/idp/oauth2/token -d grant_type=client_credentials -d client_id=<CLIENT_ID> -d client_secret=<CLIENT_SECRET> -d 'scope=openiam:mcp:identity:read' -d 'resource=https://<OPENIAM_HOST>/mcp'
```

{% endcode %}

{% code overflow="wrap" %}

```bash
curl -s https://<OPENIAM_HOST>/mcp -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"whoami","arguments":{}}}'
```

{% endcode %}

| Check             | Correct result                                                                                                                                                                                                                                                                                              |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The token request | JSON with `access_token`, `token_type` `Bearer` and `expires_in`; no `refresh_token` and no `scope`                                                                                                                                                                                                         |
| The `whoami` call | A user summary whose `login` is `nhi:<NHI_ID>`: the service user, not the built-in administrator                                                                                                                                                                                                            |
| The audit trail   | **Administration → Log Viewer** shows an `MCP_TOOL_CALL` event whose target user is the service user, with `MCP_PRINCIPAL_KIND` `NHI` and `MCP_AGENT_NHI_ID` the identity's ID                                                                                                                              |
| The Agent tab     | **Last used** reads **today** and **Active tokens** is 1                                                                                                                                                                                                                                                    |
| A Claude client   | Signing in creates an AI Agent record named after the client, Active, with the owner from the property, within one sign-in                                                                                                                                                                                  |
| The kill switch   | **Suspend agent**, wait a minute, repeat the `whoami` call: 401 with `The access token is not valid`, because the suspension revoked the token. The token request then answers `invalid_client` with `The client's agent is suspended`, and the record's audit trail shows `SUSPENDED` and `TOKENS_REVOKED` |

The same token against the shipped pack: a person who reports to the sponsor is read, one who does not is refused by `MCP - Agent reads people only inside its sponsor reporting line`, and a workflow tool the agent did not declare is refused with `no policy permits the call`.

<figure><img src="https://2965242200-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0uHWHRgcad6P03ehqgmX%2Fuploads%2Fgit-blob-f4b9a727032665fa8eae738f2561918cf2deee7f%2Fmcp-agent-cli-session.png?alt=media" alt="A terminal session of hr-reporting-agent: a client_credentials token request returns token_type Bearer and expires_in 3600, the token itself shown only by its length; whoami returns its service user nhi:<NHI_ID>; get_user for hrmanager, whose manager is sysadmin, returns the user; get_user for snelson answers NOT_PERMITTED, forbidden by policy MCP-05; and the undeclared list_my_requests answers NOT_PERMITTED, no policy permits the call"><figcaption></figcaption></figure>

## When it goes wrong

| Symptom                                                                                                                                                                                                                    | Likely cause                                                                                                                                                                                             | Resolution                                                                                                                                                                                                                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| A Claude sign-in fails at registration and the IdP log names `org.openiam.oauth.cimd.agent.owner`                                                                                                                          | The property is empty, so the IdP cannot create the agent record                                                                                                                                         | Set it to an administrator's user ID and restart the IdP                                                                                                                                                                                                                                                                 |
| 401 with `The client is not registered as an agent`                                                                                                                                                                        | `org.openiam.mcp.agent.required` is `true` and the client has no record                                                                                                                                  | Bind the client, or let a Claude client sign in again so the IdP creates its record                                                                                                                                                                                                                                      |
| 401 with `The client's agent is pending approval`                                                                                                                                                                          | The record is a Draft or Pending Approval: `org.openiam.oauth.cimd.agent.approval` is `required` and nobody approved it, or the wizard's record was never activated                                      | Approve it under **Agents awaiting approval**, shown with the **Agents** filter on, or activate it from the edit form                                                                                                                                                                                                    |
| 401 with `The client's agent is suspended`, or with `The access token is not valid` right after a suspension                                                                                                               | The identity was suspended by an administrator, by the expiry job or by the sponsor job, or it was decommissioned                                                                                        | Read the identity's audit trail for the reason; renew the expiry or set a new sponsor, then **Activate**                                                                                                                                                                                                                 |
| 401 with `The client's agent has expired`                                                                                                                                                                                  | The expiry date passed and the nightly job has not suspended the identity yet                                                                                                                            | Extend the expiry date                                                                                                                                                                                                                                                                                                   |
| The token endpoint answers `invalid_client` with `The client's agent is a draft`, `is pending approval`, `is suspended`, `is decommissioned` or `has expired`, although the secret is right                                | The record is not Active                                                                                                                                                                                 | Approve, activate or extend the record                                                                                                                                                                                                                                                                                   |
| `invalid_client` with `The client's agent has no service user`                                                                                                                                                             | The record was bound to a client-credentials client without its service user                                                                                                                             | Bind the client from the **Agent** tab, which creates the service user for that flow                                                                                                                                                                                                                                     |
| A person's sign-in through Claude ends with `access_denied` and `The client's agent is …`                                                                                                                                  | The client's record is not Active, or became Active less than a minute ago                                                                                                                               | Approve or activate the record, then wait a minute: the IdP keeps its copy of the record for 60 seconds                                                                                                                                                                                                                  |
| The token endpoint answers `server_error` with `The client's agent record could not be checked`                                                                                                                            | The IdP could not reach the NHI service                                                                                                                                                                  | Check the `openiam-nhi` service and its RabbitMQ virtual host                                                                                                                                                                                                                                                            |
| 401 with `The access token was not obtained through a user authorization` for a client-credentials client                                                                                                                  | The client is not bound to an agent record with a service user, so its token names the built-in administrator; or the token was minted for another subject                                               | Bind the client and create the service user, then request a new token. See the warning below                                                                                                                                                                                                                             |
| The token carries fewer scopes than the client is configured with                                                                                                                                                          | The service user is not entitled to the missing scope resources                                                                                                                                          | Add the role that grants them to the service user                                                                                                                                                                                                                                                                        |
| Every call from an agent answers `NOT_PERMITTED` with `no policy permits the call`                                                                                                                                         | No `FULL` policy permits the call: `MCP - Active agent may call a declared tool` is in `SHADOW`, because you had changed it and the 2026.11.1 migration left it in its mode, or the tool is not declared | Set the policy to `FULL`, declare the tool, or write a policy; see [A call runs only when a policy permits it](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md#a-call-runs-only-when-a-policy-permits-it)                                                                            |
| **Register agent** with **Client credentials**, or **Bind client** for such a client, fails with `The client could not be bound`, leaving a Draft record, an unbound client and an active service user `nhi:<NHI_ID>`      | On MariaDB before 2026.11.1 the bind created the service user inside its own transaction, the link to it was refused, and the automatic retry collided on the login                                      | Upgrade to 2026.11.1, then bind the client from the record's **Agent** tab: the bind reuses the service user the failed attempt left                                                                                                                                                                                     |
| A bind is refused, and the NHI service log reports that the login `nhi:<NHI_ID>` `is held by user <USER_ID>, which is not a service user`                                                                                  | A person or another account holds the login the agent's service user needs                                                                                                                               | Rename that user's login, then bind again                                                                                                                                                                                                                                                                                |
| The SelfService assistant answers, but never uses the MCP tools, and the AI assistant service logs `The SPA could not mint the assistant's MCP token (authorize_timeout)`                                                  | The **AI Assistant** client does not list the address SelfService was reached on, so the IdP shows an error page instead of returning to SelfService; or the person's IdP session has ended              | Add the address as described in [Set the assistant's redirect URL](#set-the-assistants-redirect-url). SelfService tries again five minutes later, or at once after the person signs in again                                                                                                                             |
| The AI assistant service logs `(invalid_issuer)`                                                                                                                                                                           | The `iss` the IdP returned differs from the issuer in its own metadata at `/idp/oauth2/.well-known/oauth-authorization-server`                                                                           | Make `org.openiam.oauth.issuer` and the proxy headers agree, so the IdP names one issuer everywhere                                                                                                                                                                                                                      |
| The AI assistant service logs `(authorize_refused)`                                                                                                                                                                        | The **AI Assistant** agent record is not Active, or the person holds no right to the client while `org.openiam.authorization.oauth.disabled` is `false`                                                  | Activate the record, or grant the client resource to the person's role                                                                                                                                                                                                                                                   |
| The SelfService assistant answers, but never uses the MCP tools, and the AI assistant service logs `The IdP refused the assistant client openiam-ai-assistant as an introspection caller ("Client authentication failed")` | The **AI Assistant** client's **Token Introspection** setting is not `Own tokens`, for example because the client was created after the upgrade ran                                                      | Set **Token Introspection** to `Own tokens` on the **AI Assistant** client, as described in [Token introspection](https://docs.openiam.com/administration-guide/federation/oauth-and-oidc/oauth-and-oidc-reference.md#token-introspection). The IdP picks the change up within its client refresh, by default 72 seconds |
| The assistant's tool calls answer `NOT_PERMITTED` with `no policy permits the call`                                                                                                                                        | The policy service has no MCP catalog, so no policy matches a person's call                                                                                                                              | Set `org.openiam.pbac.mcp.catalog.url` as described in [Before you begin](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md#before-you-begin)                                                                                                                                          |
| The agent's operator has lost the client secret                                                                                                                                                                            | The secret is shown once and cannot be read again                                                                                                                                                        | Issue a new one as described in [Replace a lost secret](#replace-a-lost-secret)                                                                                                                                                                                                                                          |
| A drift finding reads as raised hours before the calls it reports                                                                                                                                                          | It was raised before 2026.11.1 on a server whose time zone is not UTC: its raised and resolved dates were stored shifted by the server's offset                                                          | Nothing to do: findings raised since the upgrade carry the right dates, and older ones keep theirs                                                                                                                                                                                                                       |
| Calls keep succeeding for a minute after a suspension                                                                                                                                                                      | The server's 60-second agent cache                                                                                                                                                                       | Expected                                                                                                                                                                                                                                                                                                                 |
| The identity cannot be activated for a missing related human                                                                                                                                                               | An AI Agent needs a sponsor                                                                                                                                                                              | Set the **AI Agent Sponsor**                                                                                                                                                                                                                                                                                             |
| An agent registered with the wizard cannot be activated for a missing backup owner                                                                                                                                         | The wizard has no **Backup Owner** field, and its environment starts as **Prod**                                                                                                                         | Add a **Backup Owner** on the edit form, then activate the record                                                                                                                                                                                                                                                        |
| A client-credentials client still receives the `0001` subject just after you bound it                                                                                                                                      | The IdP keeps its copy of the agent record for 60 seconds                                                                                                                                                | Request a new token after a minute                                                                                                                                                                                                                                                                                       |
| A bound client cannot be deleted; the refusal is `AUTH_PROVIDER_BOUND_TO_NHI`                                                                                                                                              | Its identity is not decommissioned                                                                                                                                                                       | Decommission the identity first, then delete the client                                                                                                                                                                                                                                                                  |
| The declared-tools picker reports that the catalog is not available                                                                                                                                                        | `org.openiam.mcp.catalog.url` in `webconsole.ui.properties` is empty, or the Webconsole cannot reach the URL                                                                                             | Set it to the server's catalog document and restart Webconsole                                                                                                                                                                                                                                                           |
| No drift finding ever appears, and an agent whose sponsor left stays Active                                                                                                                                                | The `TOOL_DRIFT` and `ORPHANED_AGENTS` batch tasks do not exist                                                                                                                                          | Create them as described in [Schedule the jobs](#schedule-the-jobs), or run the jobs on demand from there                                                                                                                                                                                                                |
| The health score does not change after a drift finding is raised or resolved                                                                                                                                               | The drift job does not rescore; the nightly rescore does                                                                                                                                                 | Wait for the rescore, or run it on demand with `job=HEALTH` as described in [Schedule the jobs](#schedule-the-jobs)                                                                                                                                                                                                      |
| The owner is not mailed when an agent is suspended for its sponsor                                                                                                                                                         | The `NHI_SPONSOR_INACTIVE` mail template is not seeded, or the owner has no e-mail address                                                                                                               | Create the template, or give the owner an e-mail address; the suspension happened regardless                                                                                                                                                                                                                             |

{% hint style="warning" %}
**The `0001` subject is on its way out.** A `client_credentials` client that is not bound to an agent record still receives a token whose subject is the built-in administrator account `0001`, with every scope the client is configured with, while `org.openiam.oauth.client_credentials.legacy.subject` is `true`. 2026.10.2 ships it `true`; the next release ships it `false`, after which such a client is refused at the token endpoint with `invalid_client` and `The client is not bound to an agent record`. While the subject is still issued, the IdP logs a warning once per client that obtains it. The MCP server never admits these tokens. Bind every client-credentials client to an agent with a service user, or set the property to `false` now to find the clients that depend on it.
{% endhint %}

## Roll it back

{% stepper %}
{% step %}
To stop one agent, suspend its identity. Its tokens are revoked at once and the client is refused within a minute.
{% endstep %}

{% step %}
To readmit clients that have no record, set `org.openiam.mcp.agent.required=false` in `mcp.ui.properties` and restart the server; to stop holding new Claude clients for approval, set `org.openiam.oauth.cimd.agent.approval=auto` and restart the IdP.
{% endstep %}

{% step %}
To remove an agent that acts alone, decommission the identity, which deletes its service user and clears the binding, then delete the client under **Access Control → Authentication Providers**. The records created by the IdP for Claude clients are removed the same way; the next sign-in creates a new one.
{% endstep %}
{% endstepper %}

## Related

* [Connect AI assistants through the MCP server](https://docs.openiam.com/administration-guide/federation/mcp-server.md) — deploying the server and connecting Claude
* [Decide MCP tool calls with policies](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-policies.md) — what an agent may call, and what the result may contain
* [MCP tools, errors, properties and limits](https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-server-reference.md) — the admission reasons, every property named here, the audit attributes and the catalog
* [Turn on the AI assistant](https://docs.openiam.com/administration-guide/platform/turn-on-the-ai-assistant.md) — the SelfService assistant's model connection, and activating its record
* [Manage non-human identities](https://docs.openiam.com/administration-guide/nhi.md) — the inventory the record lives in
* [Lifecycle and status](https://docs.openiam.com/administration-guide/nhi/lifecycle.md) — the statuses and transitions, and what suspension does to an agent
* [Health and governance](https://docs.openiam.com/administration-guide/nhi/governance.md) — the health score, the drift job and the sponsor job
* [OAuth endpoints, grants, scopes and signing](https://docs.openiam.com/administration-guide/federation/oauth-and-oidc/oauth-and-oidc-reference.md) — the `client_credentials` grant and the subject it issues


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.openiam.com/administration-guide/federation/mcp-server/mcp-agents.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
