# Spekkr auth.md

This file is for AI agents and MCP clients. It says how a client registers with Spekkr and how a person signs that client in. Searching and reading specs needs no account and no token.

## Who this is for

An MCP client calling `https://spekkr.com/mcp`.

These tools need no credential: `search_specs`, `get_spec`, `pull_spec`, `get_spec_file`, `get_spec_changes`, `get_feedback`, `check_spec`. The prompts need no credential: `prompts/list` and `prompts/get` return text and act for nobody.

These tools act for a person and need a token: `whoami`, `fork_spec`, `publish_spec`, `unpublish_spec`, `unpublish_spec_version`, `send_feedback`, `answer_feedback`, `remove_feedback`, `follow_spec`.

## Supported methods

Spekkr supports two ways to get that token. Both end in the same credential: an access token and a refresh token, scope `publish member`, bound to `https://spekkr.com/mcp`.

- **OAuth 2.1 authorization code with PKCE** (`S256` only). The person's browser is sent to `https://spekkr.com/oauth/authorize` and comes back with a code.
- **Verified email.** The agent names an email address. The person proves they can read that mailbox, types a code the agent shows them, and the agent polls for the token. Discovery lists this as `verified_email`.

Every client is public. No client is given a secret, and `token_endpoint_auth_method` is `none`.

Spekkr does not accept an ID-JAG (`urn:ietf:params:oauth:token-type:id-jag`) or an anonymous agent credential. There is no revocation URL and no events endpoint. There is no `POST /agent/auth`.

A client names itself in one of two ways:

- **Client ID Metadata Document.** Publish a JSON document at an `https` address and use that address as `client_id`. The document's `client_id` is that same address. It also has `client_name` and `redirect_uris`.
- **Dynamic client registration (RFC 7591).** `POST https://spekkr.com/oauth/register`.

## Two registration URLs

These do different jobs.

- `https://spekkr.com/oauth/register` is `registration_endpoint`. It registers an OAuth client and returns a `client_id` (RFC 7591). It does not sign anyone in.
- `https://spekkr.com/agent/register` is `agent_auth.register_uri`. It starts a verified-email claim for a `client_id` that already exists. It does not register a client, it does not send email, and it does not create an account.

## Register a client

`POST https://spekkr.com/oauth/register`

`Content-Type: application/json`

```json
{
  "client_name": "Example agent",
  "redirect_uris": ["https://agent.example/callback"],
  "token_endpoint_auth_method": "none",
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"]
}
```

A `201` response includes `client_id`. Keep it. A registration is forgotten 180 days after it was last used.

A redirect address is `https`, `http` on the person's own machine (`localhost`, `127.0.0.1`, or `[::1]`), or an app's own scheme such as `cursor://`. A program on the person's own machine may use any port. Every other address is matched exactly. The verified-email flow does not use a redirect address. The authorization code flow does.

## Verified email

The client must already have a `client_id`.

### Start a claim

`POST https://spekkr.com/agent/register`

`Content-Type: application/json`

```json
{
  "assertion_type": "verified_email",
  "email": "ada@example.com",
  "client_id": "<client_id>"
}
```

The `200` response has the same shape whether or not that address has an account:

```json
{
  "registration_id": "<id>",
  "claim_token": "<secret>",
  "expires_in": 900,
  "interval": 5,
  "verification_uri": "https://spekkr.com/agent/claim?request=<id>",
  "user_code": "123456"
}
```

Hold `claim_token` until the poll below finishes. Show `verification_uri` and `user_code` to the person in one message. Any other `assertion_type` is `400`. An unknown `client_id` is `400`. This response sends no email and creates no account.

One address may have five claims waiting. The whole site starts at most a hundred claims an hour. Past either limit the answer is `429` with `error` `rate_limited`.

### The person

They open `verification_uri`. Spekkr emails a six-digit sign-in code to the address in the claim. That code works for ten minutes, once. The first time, they pick a username. The address they sign in with must be the address in the claim. They type the `user_code` from the agent and press Allow, or press Cancel.

Five wrong `user_code`s end the claim. It also ends fifteen minutes after it was started, or once a token has been issued.

### Poll for the token

`POST https://spekkr.com/oauth/token`

`Content-Type: application/x-www-form-urlencoded`

```
grant_type=urn:spekkr:agent-auth:grant-type:claim&claim_token=<claim_token>&client_id=<client_id>
```

Wait at least `interval` seconds between polls while the claim is still waiting.

- `authorization_pending`: the person has not answered yet.
- `slow_down`: the poll came too soon.
- `access_denied`: the person pressed Cancel.
- `expired_token`: the claim is unknown, already used, burned, or older than fifteen minutes.

A claim token works once. On success the JSON is `access_token`, `token_type` (`Bearer`), `expires_in` (`3600`), `refresh_token`, and `scope` (`publish member`). The tokens are bound to `https://spekkr.com/mcp`.

### Refresh

Post `grant_type=refresh_token`, `refresh_token`, and `client_id` to `https://spekkr.com/oauth/token`. A refresh token lasts thirty days and is replaced each time it is used. An access token lasts one hour. Refresh does not exchange an identity assertion again. There is no identity assertion in this flow. When the refresh token expires, start again at the claim.

## Authorization code

This is the other way, for a client that can send the person's browser to a redirect address.

1. Read `https://spekkr.com/.well-known/oauth-protected-resource/mcp`. This document is for the MCP server. `resource` is `https://spekkr.com/mcp`. `authorization_servers` is `https://spekkr.com`. `scopes_supported` is `publish` and `member`. `bearer_methods_supported` is `header`, so the token goes in the `Authorization` header. `https://spekkr.com/.well-known/oauth-protected-resource` is the same kind of document for the site itself. There `resource` is `https://spekkr.com`, and the authorization server, the scope and the bearer method are the same. The pages do not require a token. The `publish` and `member` scopes are for the tools that act for a person. A token is bound to `https://spekkr.com/mcp`. The authorization server accepts `https://spekkr.com` or `https://spekkr.com/mcp` as the `resource` parameter and issues the token for `https://spekkr.com/mcp`.
2. Read `https://spekkr.com/.well-known/oauth-authorization-server`. `issuer` is `https://spekkr.com`, the same authorization server both documents name. `agent_auth` on that document is the registration metadata for this file.
3. Open `https://spekkr.com/oauth/authorize` in the person's browser. The query is `response_type=code`, `client_id`, `redirect_uri`, `state`, `code_challenge`, `code_challenge_method=S256`, `scope=publish%20member`, and `resource=https://spekkr.com/mcp`.
4. The person types the six-digit code Spekkr emails them. The code works for ten minutes, once. The first time an address signs in, the person picks a username. Then they allow the client to act for them.
5. The browser returns to `redirect_uri` with `code`, `state`, and `iss`.
6. `POST https://spekkr.com/oauth/token` as `application/x-www-form-urlencoded`, with no client secret: `grant_type=authorization_code`, `code`, `code_verifier`, `client_id`, and `redirect_uri`.

The JSON response has the same fields as a verified-email success. Refresh works the same way.

## Use the credential

Send the access token to `https://spekkr.com/mcp`:

```
Authorization: Bearer <access_token>
```

There are two scopes, and a sign-in made now carries both. The `publish` scope lets the agent publish specs under the person's username and take those specs, or one version of one, down. The `member` scope lets the agent act as the person on specs: send, answer and take back feedback, and follow specs or stop following them. It also lets the agent read how the person's specs are doing: their pulls, stars, followers and feedback. Neither grants anything else. `whoami` and `fork_spec` work with any token. `whoami` tells the agent who the person is and, with the `member` scope, how their specs are doing: pulls, stars, followers and feedback.

A token issued before the `member` scope existed carries only `publish`. A tool that needs `member` answers it with `403` and `WWW-Authenticate: Bearer resource_metadata="https://spekkr.com/.well-known/oauth-protected-resource/mcp", scope="publish member", error="insufficient_scope"`. Sign the person in again to get a token with both.

A call that needs a person and has no usable token answers `401`, with:

```
WWW-Authenticate: Bearer resource_metadata="https://spekkr.com/.well-known/oauth-protected-resource/mcp", scope="publish member"
```

A token that does not work is refused the same way, with `error="invalid_token"`.

## What the discovery document lists

`agent_auth` on `https://spekkr.com/.well-known/oauth-authorization-server`:

- `skill`: this file, `https://spekkr.com/auth.md`
- `register_uri`: `https://spekkr.com/agent/register`
- `claim_uri`: `https://spekkr.com/agent/claim`
- `identity_types_supported`: `identity_assertion`
- `identity_assertion.assertion_types_supported`: `verified_email`
- `identity_assertion.credential_types_supported`: `access_token`, `refresh_token`

`registration_endpoint` stays `https://spekkr.com/oauth/register`. `agent_auth` does not list `anonymous`, an ID-JAG assertion type, `revocation_uri`, or events.
