# Authentication for agents: Output

Output (https://theoutput.app) lets AI assistants act for a person through the Output MCP server at `https://mcp.theoutput.app/mcp`. Access is always on behalf of a signed-in Output user: there are no API keys, no service accounts and no anonymous access. Every generation spends that user's tokens or subscription, exactly like on the website.

## Discover

- Call the MCP server without a token: it answers `401` with a `WWW-Authenticate` header that carries `resource_metadata` and the default `scope`.
- Protected resource metadata (RFC 9728): `https://mcp.theoutput.app/.well-known/oauth-protected-resource` (also mirrored at `https://theoutput.app/.well-known/oauth-protected-resource`).
- Authorization server metadata (RFC 8414): `https://mcp.theoutput.app/.well-known/oauth-authorization-server`.
- Server card: `https://mcp.theoutput.app/server-card`. Human docs: https://theoutput.app/mcp.

## Pick a method

OAuth 2.1 authorization code flow with PKCE (S256) is the only method. `agent_auth` identity assertions (`identity_endpoint`, `identity_assertion`, `service_auth`, ID-JAG) are not supported: an Output account belongs to a person, and the person approves access in the browser.

## Register

Use dynamic client registration (RFC 7591) at the `registration_endpoint` from the authorization server metadata. Public clients (no secret) are accepted; send your `redirect_uris` and a `client_name` the user will recognise.

## Claim

Send the user to the `authorization_endpoint` with `response_type=code`, your `client_id`, `redirect_uri`, `code_challenge` (S256), `state` and the scopes you need. The user signs in to Output (Telegram, Yandex ID, Apple, Google or email) and sees a consent page listing the scopes in plain words. Ask only for what the task needs:

- `templates:read`: View templates
- `account:read`: See your name, token balance and subscription
- `works:read`: See your works and generation status
- `generate`: Create photos and videos: spends your tokens or subscription

The legacy scope `mcp` still works and means all user scopes.

## Exchange

Exchange the code at the `token_endpoint` with your `code_verifier`. You get an access token and a refresh token; refresh with `grant_type=refresh_token`.

## Use the access_token

Send `Authorization: Bearer <access_token>` on every MCP request (Streamable HTTP, JSON-RPC over POST). Tools the token has no scope for are hidden from `tools/list`.

## Errors

- `401` with `WWW-Authenticate: Bearer error="invalid_token"`: token missing, expired or revoked; refresh or ask the user to reconnect.
- Tool error naming a missing scope: reconnect with that scope.
- Not enough tokens: the tool error includes a link to https://theoutput.app/pricing for the user. Do not retry in a loop.
- Rate limits: the same limits as the website; wait and retry later.

## Revocation

The user can disconnect any assistant in Output settings, section MCP (https://theoutput.app/settings/mcp). Revoked tokens stop working immediately. Questions: support@theoutput.app.
