# Authentication for agents Sinatra's MCP server and HTTP API live at https://api.sinatra.dev. Every request needs a credential that acts as one Sinatra user, with that user's role in each workspace they belong to. There is no anonymous access. A workspace the user doesn't belong to answers `404`. ## OAuth 2.0 (MCP clients and the CLI) - Grant: `authorization_code` with PKCE, the agent-safe grant for public clients. The user signs in and approves the app in their own browser; the agent never sees a password or a client secret. `refresh_token` renews the access token. There is no `client_credentials` or `password` grant. - PKCE: required, with `code_challenge_method=S256` only (`code_challenge_methods_supported: ["S256"]`). A request without a code challenge, or with `plain`, is rejected. - Grant types (`grant_types_supported`): `authorization_code`, `refresh_token`. - Clients register through dynamic client registration or a client ID metadata document. Public clients use no client secret; clients that declare `private_key_jwt` in their metadata document authenticate with it. - Issuer: https://api.sinatra.dev. Authorization server metadata (RFC 8414): https://api.sinatra.dev/.well-known/oauth-authorization-server - Protected resource metadata (RFC 9728) for the MCP server: https://api.sinatra.dev/.well-known/oauth-protected-resource/v1/mcp - Resource: https://api.sinatra.dev/v1/mcp. An unauthenticated request gets `401` with `WWW-Authenticate: Bearer resource_metadata="https://api.sinatra.dev/.well-known/oauth-protected-resource/v1/mcp", scope="mcp"`. - The user approves each app in the browser. A sign-in lasts up to 90 days, or until it goes 30 days unused. The user can disconnect an app at any time under Connected apps on https://app.sinatra.dev/tokens. ### Scopes `scopes_supported`: `mcp`, `offline_access`. Request `mcp`; it is the narrowest scope that works. - `mcp`: use Sinatra's MCP tools as the user, with that user's role in each workspace. - `offline_access`: accepted and ignored; every grant includes a refresh token anyway. MCP clients that support OAuth need only the server URL; they find the rest from the `401`. Server card: https://www.sinatra.dev/.well-known/mcp/server-card.json ## Personal access tokens (HTTP API, scripts, headless CLI) - Self-serve: [create a token](https://app.sinatra.dev/tokens) under **CLI & API** in the dashboard, without approval from anyone else. It expires after 30, 90 or 365 days, starts with `sntr_`, and is shown once. - Tokens have no narrower scopes: a token acts as the user in every workspace they belong to, with their role in each. - Send it as a bearer token on every request. MCP clients that take a URL and headers can send it to the MCP server the same way. ```sh curl -s https://api.sinatra.dev/v1/me -H "Authorization: Bearer $SINATRA_TOKEN" ``` - Revoke it on the same page, or with `DELETE /v1/me/token` sent with the token itself. - A missing, malformed, expired or revoked token gets `401` with `invalid_token`. More: https://docs.sinatra.dev/docs/cli-and-api. Questions: contact@sinatra.dev.