> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiveth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent tokens

> What is inside the short-lived token an AI agent gets for your MCP server, and how to check it.

When a person lets an AI agent reach one of your MCP servers (see [AI agents](https://docs.aiveth.com/agents/overview.md)), Aiveth gives the agent an access token for that one server. The token is a JWT signed with the same keys your apps already use (published at your Aiveth JWKS), so your MCP server can check it without calling Aiveth.

## Lifetime and refresh

* An agent token lasts **10 minutes**. A JWT can't be called back, so its life is kept short.
* The agent keeps going with its refresh token, which rotates on every use.
* Suspending the person, ending their sessions, an admin blocking the agent, or the person disconnecting it all stop the agent at its next refresh, so within 10 minutes.
* Every token, first or refreshed, passes the organization's [controls](https://docs.aiveth.com/agents/controls-and-approvals.md) first.

To stop an agent even sooner, ask Aiveth with [introspection](#introspection) on each call.

## Claims

| Claim | Meaning |
| - | - |
| `iss` | Your Aiveth address, like `https://accounts.aiveth.com`. |
| `aud` | Your MCP server's address, exactly as registered. Nothing else. |
| `sub` | The person the agent acts for. |
| `client_id` | The agent's own client ID (its metadata document address, or its registered ID). |
| `org_id` | Your organization's ID. |
| `scope` | The permissions the person allowed, separated by spaces. |
| `act` | Who is acting: `{"sub": "<the agent's client ID>"}` (RFC 8693). |
| `gty` | How the token was granted: `authorization_code` (the person agreed on Aiveth's screen) or `id-jag` (an enterprise pass). |
| `iat`, `exp` | Issued and expiry times. |
| `jti` | A unique token ID. |
| `auth_time` | When the person signed in. |
| `aid`, `authorization_details` | Only on a token for an approved step: the approval's ID and what the person approved (RFC 9396). See [Human approval](https://docs.aiveth.com/agents/controls-and-approvals.md#human-approval). |

Example payload:

```json theme={null}
{
  "iss": "https://accounts.aiveth.com",
  "aud": "https://mcp.example.com/mcp",
  "sub": "8b1f...",
  "client_id": "https://agent.example.ai/client.json",
  "org_id": "c41e...",
  "scope": "files:read",
  "act": { "sub": "https://agent.example.ai/client.json" },
  "gty": "authorization_code",
  "iat": 1764000000,
  "exp": 1764000600,
  "jti": "Hk2...",
  "auth_time": 1763999950
}
```

## The audience rule

A token is for **one** MCP server. Your server must refuse any token whose `aud` is not its own address. The SDK does this for you:

```ts Node theme={null}
const claims = await aiveth.tokens.verifyMcpToken(bearer, {
  resource: 'https://mcp.example.com/mcp',
  scopes: ['files:read'], // throws InsufficientScopeError if any is missing
});
```

```python Python theme={null}
claims = aiveth.tokens.verify_mcp_token(bearer, resource="https://mcp.example.com/mcp", scopes=("files:read",))
```

The SDK checks the signature, `iss`, `aud`, expiry, that the token is an agent token, and the permissions you name.

When the agent asks for a token at `/oauth/token`, it must send `resource` with your server's address. A code or refresh token for one server can't be used to get a token for another (`invalid_target`).

## Introspection

Your MCP server can ask whether a token is still good right now:

```bash theme={null}
curl -X POST https://accounts.aiveth.com/oauth/introspect \
  -d "token=eyJhbGciOi..."
```

The answer is `{"active": false}` for anything Aiveth would not issue again now: a bad or expired token, a blocked or removed agent, all agents paused, an owner who left, a passed end date, an unanswered access review, or a person who can no longer use apps. When active, it returns `active`, `token_type` and the claims `sub`, `client_id`, `scope`, `aud`, `iss`, `exp`, `iat`, `act`, `aid`, `authorization_details` and `org_id`.

Introspection counts nothing and records nothing, so you can call it on every request. It is limited to 600 calls a minute per network address.

## Enterprise passes (ID-JAG)

> [!NOTE]
>
> Enterprise sign-in for AI agents is available on the Enterprise plan, or as an add-on to Business.

With an enterprise pass, a person who signs in to an AI app with their organization's identity provider (such as Okta or Microsoft Entra ID) can reach your MCP server without Aiveth's consent screen. Their IT team approves the AI app centrally in its identity provider, and the provider issues a pass (an Identity Assertion JWT Authorization Grant, or ID-JAG).

### Set it up

**1. Trust the identity provider**

In **AI agents** → **Enterprise sign-in for AI agents**, your organization's own [single sign-on](https://docs.aiveth.com/sign-in/single-sign-on.md) is trusted while it's on. You can add other issuers under **Trusted identity providers**. This needs **Manage sign-in security**. With no trusted provider, no pass is accepted.

**2. Turn on enterprise passes for the AI app**

Under **Apps**, open the AI app and turn on **Enterprise passes**.

**3. Tell the identity provider's admin**

Give them your **Authorization server** address. It is the pass's audience.

### The request

The AI app sends the pass to `/oauth/token`, proving itself with its client ID and secret:

```
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
assertion=<the pass>
resource=https://mcp.example.com/mcp
scope=files:read
```

Aiveth checks, in order:

1. The AI app proved itself, and enterprise passes are on for it.
2. The pass's header `typ` is `oauth-id-jag+jwt`.
3. Its `iss` is an issuer your organization trusts, and only then its signature, with that issuer's keys.
4. Its `aud` is your Aiveth address, its `client_id` is the app that proved itself, and it is in date.
5. The MCP server named in the pass (and the request, which must agree) is your organization's.
6. The person is found by their single sign-on link, or else by the pass's verified email for a member of your organization. Nobody is ever created.
7. The permissions are what the pass, the server and the request all allow.

The result is a 10-minute token with `gty` set to `id-jag` and **no refresh token**, because the issuing identity provider could not take one back. The AI app presents the pass again, or gets a new one.

## Server-to-server calls

Sometimes one of your MCP servers needs to call another for the same person. Server X exchanges the token it received for a token to server Y (RFC 8693 token exchange).

### Allow it

In **AI agents**, open server X, choose **Calls**, and choose which servers it may call and with which permissions at most. Make X's credential there: a server ID and a secret shown once. An admin can renew the secret. Nothing else may call another server.

### The exchange

Server X calls `/oauth/token` with its own credential (HTTP Basic or in the form):

```
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
subject_token=<the agent's token X received>
subject_token_type=urn:ietf:params:oauth:token-type:access_token
resource=<server Y's address>
scope=<at most what X may use on Y>
client_id=<X's server ID>
client_secret=<X's secret>
```

Aiveth checks X's credential; that the token is Aiveth's, still good, and addressed to X; that Y is X's to call and the scope is within what X may use there; that the chain has at most 4 actors; that the person is still a live member; and that the agent at the end of the chain passes its own controls.

The new token has `sub` the person, `aud` server Y, `client_id` server X, and a nested `act` that records the whole chain:

```json theme={null}
{ "act": { "sub": "<server X>", "act": { "sub": "<the agent>" } } }
```

Its scope is narrowed, it ends no later than the token it came from, and it has no refresh token. If the original token came from an approval, its `aid` travels with it. Removing X's permission to call Y makes introspection answer inactive for tokens already issued.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.