# auth.md

Public technical notes for agents that connect to STAS through MCP.

## STAS Agent Auth

Agent Auth is a separate gateway flow. Treat it as available only when
https://intervals.stas.run/.well-known/oauth-authorization-server includes an `agent_auth` block.

When Agent Auth is enabled:

1. The agent registers without email by calling `https://intervals.stas.run/gw/agent/identity` with identity type `anonymous`.
2. The user confirms the pending connection through Intervals on the gateway claim page.
3. The agent polls `https://intervals.stas.run/gw/oauth/token` with grant type `urn:workos:agent-auth:grant-type:claim`.
4. After confirmation, the gateway returns a bearer token for STAS MCP with scope `stas.mcp.read`.

Agent Auth currently supports only `stas.mcp.read`. Write access is not available through this flow.
Agent Auth V1 tokens are read-only for MCP. Destructive or write MCP tools should not be advertised to these tokens and should fail safely if called.

Agent Auth endpoints:

- Identity endpoint: https://intervals.stas.run/gw/agent/identity
- register_uri compatibility alias: https://intervals.stas.run/gw/agent/identity
- Claim endpoint: https://intervals.stas.run/gw/agent/identity/claim
- claim_uri compatibility alias: https://intervals.stas.run/gw/agent/identity/claim
- Token endpoint: https://intervals.stas.run/gw/oauth/token
- Revocation endpoint: https://intervals.stas.run/gw/oauth/revoke

## STAS MCP

- STAS MCP endpoint: https://stas.run/api/mcp
- OAuth protected resource metadata: https://stas.run/.well-known/oauth-protected-resource
- OAuth protected resource metadata for MCP: https://stas.run/.well-known/oauth-protected-resource/api/mcp
- OAuth authorization server metadata: https://intervals.stas.run/.well-known/oauth-authorization-server

## OAuth Authorization Server

- Real issuer: https://intervals.stas.run
- Authorization endpoint: https://intervals.stas.run/gw/oauth/authorize
- Token endpoint: https://intervals.stas.run/gw/oauth/token
- Dynamic client registration endpoint: https://intervals.stas.run/gw/oauth/register

## Access Rules

- User data requires OAuth user authorization.
- Anonymous agents can read public discovery metadata only.
- Anonymous agents cannot read private training data.
- Normal OAuth and Agent Auth are distinct paths.
- Normal OAuth uses `authorization_code` and may expose the existing Intervals-backed MCP write tools after the user authorizes them.
- Agent Auth uses anonymous registration plus Intervals user confirmation and is limited to `stas.mcp.read` in V1.
- Write access, calendar writes, profile commits, strategy saves, deletes, and restores are not available through Agent Auth V1.
- The stas.run authorization server metadata does not include jwks_uri because no public JWKS endpoint is published for this integration.
- This document publishes no secrets, private data, or unsupported OAuth claims.
