Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Tools, servers, and other agents

The assistant does not lay out the book or choose the photos alone: it calls a layout tool and hands photo selection to the printer's own agent. This lesson treats each tool as an OAuth resource server, follows how the assistant discovers how to get access, why each token is for one audience only, and how authority narrows as it passes to another agent.

A tool is a resource server

For the layout the assistant calls a page layout service at layout.example, which you have used before and which keeps your saved layouts. For choosing photos it asks the printer's own selection agent at agent.printer.example, which knows how each photo will look on the printer's paper. Each of these adds a party to the chain, and each one needs to know who is calling and with what authority.

To the assistant's language model, a tool is a description of an action it can take, such as "create a layout from these photos with this many pages." Behind that description is a server, and to that server the assistant is a client sending requests.

So the layout service faces the same questions as the photo API. Who is calling? For whom? With what authority? In OAuth terms, a tool server is a resource server. It accepts access tokens from an authorization server it trusts, and it checks each token's audience and permissions before acting.

The Model Context Protocol, or MCP, which many agents use to connect to tools, takes exactly this approach. In its 2026-07-28 authorization revision, an MCP server that requires authorization over HTTP acts as an OAuth resource server, and the agent connecting to it is an OAuth client. The authorization rules build on OAuth 2.1, the OAuth profile that revision refers to. Check which revision the implementation you are building supports.

Discovering how to get access

The assistant has not connected to layout.example before. It calls the tool, and the layout service refuses the request without a token, pointing to a description of itself:

POST /mcp HTTP/1.1
Host: layout.example
Content-Type: application/json

{ "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": { "name": "create_layout", "arguments": { "pages": 32 } } }

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://layout.example/.well-known/oauth-protected-resource", scope="layouts.create"

All domains, credentials, and tokens in these examples are fictional. MCP messages are JSON-RPC: a small JSON envelope that names a method, here tools/call, and its params, with an id that matches the answer to the request. The refusal itself is ordinary OAuth. That URL leads to the layout service's protected resource metadata, the same kind of document that Protected resource metadata follows for the photo API. It tells the assistant which authorization server issues tokens for the layout service:

{
  "resource": "https://layout.example",
  "authorization_servers": ["https://auth.layout.example"],
  "scopes_supported": ["layouts.create"],
  "bearer_methods_supported": ["header"]
}

Before using those endpoints, the assistant checks that the metadata's resource is exactly the server it called, picks an issuer it is willing to trust, and validates that issuer's own metadata. A discovery pointer is a place to look, not a reason to trust. One problem remains: the authorization server has never heard of the assistant. An agent may connect to hundreds of tool servers it has never seen, so registering with each one in advance does not scale.

A client registered in advance keeps using that registration. For a client with no prior relationship, MCP now prefers a client ID metadata document. The assistant's client ID is an HTTPS URL, and the authorization server fetches the document at that URL to learn about the client:

{
  "client_id": "https://assistant.example/oauth/client.json",
  "client_name": "assistant.example",
  "redirect_uris": ["https://assistant.example/oauth/callback"],
  "token_endpoint_auth_method": "private_key_jwt",
  "jwks_uri": "https://assistant.example/oauth/jwks.json"
}

The domain in the URL becomes part of the client's identity. Only whoever controls assistant.example can publish that document, and only a client holding the matching private key can authenticate as it. This is the Client ID metadata documents approach, defined in an OAuth working group draft that the MCP revision refers to, so check the draft's current version and status before implementing it. The older approach is dynamic client registration, which Registering a client dynamically covers: the agent submits its metadata and receives a client ID in return. MCP now marks it as deprecated and keeps it only for authorization servers that do not support metadata documents.

Because the assistant works with many authorization servers at once, it also checks which one sent each authorization response, so a response from one server cannot be passed off as coming from another. Checking the response issuer shows what the check covers and what it leaves to other defenses.

The assistant validates the discovery chain and obtains a token for the tool. The figure shows the pre-registered client path; a client ID metadata document, where supported, replaces that one step. The tool then validates its actual audience and authority.

Tokens for one audience

When the assistant asks for a token, it includes a resource parameter naming https://layout.example. You sign in at the layout service and approve, and the token the assistant receives is meant for the layout service alone. MCP requires agents to send that parameter, and requires tool servers to check that every token they receive was issued for them, the check Audience restrictions and validation describes at the photo API.

Suppose the layout service wanted your original photos rather than the copies the assistant sends it. It might be tempted to take the token it received and present it to the photo API. That fails, as it should, because the token's audience is the layout service. Now suppose the assistant had handed the layout service its photo token instead. The layout service could then read your photos while the photo service believed the assistant was calling. Your authority would be spent by a party you never approved, and no record would show it.

This is the confused deputy from Keeping an agent's authority narrow, one hop further along. MCP forbids tool servers from passing on tokens they received. If a tool needs access somewhere else, it must obtain its own authority for that audience, so the service it calls can see who is really asking.

Handing off to another agent

The printer's selection agent does need your photos. It should not receive the assistant's photo token. Instead, the authority is passed along through token exchange, in the same way the printer's services passed your order along in Keeping context across services.

First, the assistant asks the photo service's authorization server to exchange its token for one meant for the selection agent. Your consent covered reading the album to make a book. The photo service's policy treats passing that read access to a registered printing partner, for the same task and nothing more, as part of it. A stricter service would ask you again. The assistant sends the new token to the selection agent with the job.

Then the selection agent exchanges that token at the same authorization server, authenticating with the registration the printer holds for it, printer-selection-agent. It receives a token for the photo API:

{
  "iss": "https://auth.photos.example",
  "sub": "user-2048",
  "aud": "https://api.photos.example",
  "client_id": "printer-selection-agent",
  "authorization_details": [{
    "type": "photo_album",
    "locations": ["https://api.photos.example"],
    "actions": ["read"],
    "datatypes": ["images", "captions"],
    "identifier": "73"
  }],
  "act": {
    "sub": "printer-selection-agent",
    "act": { "sub": "assistant" }
  },
  "iat": 1790864400,
  "exp": 1790865300
}

The subject is still you. The authority is still reading one album. The current actor is the selection agent, and the nested act records that it is acting within the assistant's delegation. The actors are named by the client IDs the photo service knows them by. The photo API decides from the subject and the current actor, and keeps the full chain in its record.

Here the hand-off was simple, because the printer is already registered at the photo service. If the selection agent belonged to an organization the photo service had never dealt with, the photo service would first need an explicit arrangement saying which issuer it trusts for that hand-off and what it will allow, and trust in one direction does not imply trust in the other. The OAuth working group has proposed a pattern for chaining identity and authorization across trust domains, in which the first domain's authorization server issues a grant for the hand-off and the receiving domain's authorization server decides whether to accept it and what access to give. A proposal is not deployed trust, though: two organizations still have to set up and agree that arrangement themselves.

Agent-to-agent protocols cover how one agent finds another and talks to it. In the Agent2Agent protocol, each agent publishes an agent card describing what it can do and how a caller must authenticate, such as with OAuth 2.0 or mutual TLS. The card says how to present credentials. What authority those credentials carry is still decided by tokens like the one above.

When the chain gets long

Chains of agents and tools can grow deeper than this one. A few rules keep them safe:

  • Authority only narrows. Each exchange produces a token for one next audience. Its scope may keep or reduce the authority it came from, or express part of it in the next service's terms, but never broaden it, and its lifetime may only stay or shrink. The authorization server enforces this, not the agents.
  • The subject stays. Every token in the chain still names you. A hop that drops the subject and calls with its own broad identity has laundered your authority into its own, and the service it calls can no longer tell whose request it is.
  • Lifetimes shrink. A token derived from another should not outlive the one it came from.
  • Depth has limits. An authorization server can refuse chains longer than its policy allows.
  • Every hop is recorded. When every service records the nested actors it validated, and a reference from each request to the one that caused it, the record shows the path. A request ID on its own identifies one HTTP request; it says nothing about which earlier request caused it unless each service records that link.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

The layout service wants your original photos, so it takes the token it received, whose audience is the layout service, and sends it to the photo API. What should happen? 1 of 3

Choose one answer.

A tool answers the assistant with 401 and a resource_metadata URL naming auth.layout.example as its authorization server. What should the assistant do before asking that server for a token? 2 of 3

Choose one answer.

The printer's selection agent receives a token through token exchange. Which property must hold? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity