# Debriefing auth.md

How an AI agent gets access to Debriefing (debriefing.io) for a person. Debriefing is competitive intelligence for companies of 20 to 249 people, in any industry: tracked competitors, evidence-backed signals, digests, and battlecards in one workspace.

## 1. Agent registration

Debriefing does not support agent self-registration. There is no endpoint where an agent creates an account or claims an identity, and the authorization server metadata has no `agent_auth` block. A person creates the account, and the agent then acts for that person with a credential they approve.

## 2. Discover

- An MCP call that needs a credential gets HTTP 401 with `WWW-Authenticate: Bearer resource_metadata="https://debriefing.io/.well-known/oauth-protected-resource/mcp"`.
- Protected resource metadata (RFC 9728): https://debriefing.io/.well-known/oauth-protected-resource/mcp for the MCP endpoint, and https://debriefing.io/.well-known/oauth-protected-resource for the site root.
- Authorization server metadata (RFC 8414): https://debriefing.io/.well-known/oauth-authorization-server. The issuer is `https://debriefing.io`.
- MCP server card: https://debriefing.io/.well-known/mcp/server-card.json
- API catalog (RFC 9727): https://debriefing.io/.well-known/api-catalog

## 3. The person signs up

- Sign up: https://debriefing.io/sign_up (email and password, then email verification, or Google).
- Sign in: https://debriefing.io/sign_in
- The person then sets up a workspace in the app. An agent cannot do these steps for them.

Without an account, an agent can still call the public MCP tools (`search_public_briefs`, `get_public_brief`, `search_guides`, `get_free_brief_link`, `request_free_brief`). They need no credential. Most read only the briefs and guides published on debriefing.io. `request_free_brief` asks for a free brief for the person, with their consent, and returns a claim URL. The person opens it and signs up once, with the same email, to get a workspace that holds the brief.

## 4. Connect with OAuth 2.1 (MCP)

- MCP endpoint: https://debriefing.io/mcp (Streamable HTTP, JSON-RPC 2.0 in a POST).
- Client registration, one of:
  - Dynamic client registration (RFC 7591): POST https://debriefing.io/oauth/register.
  - Client ID metadata document: send the https URL of your metadata document as `client_id`. No registration call.
- Authorization code flow with PKCE (`S256` only) at https://debriefing.io/oauth/authorize. The person signs in and approves on a consent screen.
- Token endpoint: https://debriefing.io/oauth/token. Revocation: https://debriefing.io/oauth/revoke.
- Send `resource=https://debriefing.io/mcp` (RFC 8707).
- Scopes: `read` (always granted), `write` (changes that cost nothing), `spend` (actions that use a plan allowance), and `offline_access`. The person ticks `write` and `spend` on the consent screen.
- Access tokens last 1 hour. Refresh tokens last 60 days and rotate on each use.
- The token works on one workspace, as the person who approved it.

## 5. Or use an API key

- A workspace admin creates the key in Debriefing, in Organization settings, under Integrations. Creating a key needs a paid plan.
- Keys start with `dbk_` and are read-only (scope `read`). Write and spend tools need OAuth.
- The read API (https://debriefing.io/api/v1) takes only API keys. The MCP endpoint takes a key or an OAuth token.
- Send it as `Authorization: Bearer <key>` or `X-API-Key: <key>`. Ask the person for the key. Never guess it, and never write it to a file or a log.

## 6. Errors

- MCP: 401 with `WWW-Authenticate` (no or bad credential). A tool refused by scope, role, or plan answers `isError: true` with the reason and the link that fixes it.
- Read API: RFC 9457 problem details. 401 `invalid_api_key`, 402 `paid_plan_required`, 429 `rate_limited` (wait for `Retry-After`).
- OAuth endpoints: RFC 6749 errors (`error`, `error_description`).

## 7. Revocation

- The client revokes a token family at https://debriefing.io/oauth/revoke (RFC 7009).
- A workspace admin can disconnect an app, or revoke an API key, in Organization settings, under Integrations.

## More

- Developer docs: https://debriefing.io/developers
- Agent skill: https://debriefing.io/.well-known/agent-skills/debriefing-api/SKILL.md
