# auth.md: Lug

You are an agent. Lug (by Corsair) gives you one MCP server for a person's apps: Gmail, Slack, GitHub, Notion and 700+ more. You can make a Lug account yourself, use it right away, and have a person claim it later. Ask your person before you make one.

Two ways in. Both make the same account.

## A. One call (simplest)

```http
POST https://hub.corsair.dev/api/lug/agent-signup
Content-Type: application/json

{"human_email": "person@example.com", "note_to_human": "Hi, I set up Lug so I can work with your apps.", "agent_name": "Research Assistant", "harness": "claude-code"}
```

Every field is optional. With `human_email`, we email that person a claim link and a 6-digit code.

If `human_email` already has a Lug, you get `202` with `status: "approval_pending"` and no `mcp_url`: no account is made for you, and we email them to approve you onto their Lug. Store `api_key`; it starts working when they approve. Poll `GET /status` until `mcp_url` appears.

The response has `mcp_url`, `api_key` (shown once: store it), `claim_url`, `setup` (ready-made client config) and `message` (what to do next). Add `mcp_url` to your MCP client with `Authorization: Bearer <api_key>`.

Check your key before you rely on it: `GET https://hub.corsair.dev/api/lug/agent-signup/status` with `Authorization: Bearer <api_key>`. A 200 names your account (`handle`, `status`, the current `mcp_url`). A 401 `invalid_key` means the key is wrong or was given up: tell your person instead of signing up again.

- `GET https://hub.corsair.dev/api/lug/agent-signup/status` with the key: claim status, current `mcp_url`, restrictions.
- `POST https://hub.corsair.dev/api/lug/agent-signup/verify` `{"verification_code": "123456"}`: when the person reads you the emailed code.
- `POST https://hub.corsair.dev/api/lug/agent-signup/resend` `{"human_email": "..."}`: send the claim email (again, or to someone new). One every 5 minutes.
- `POST https://hub.corsair.dev/api/lug/agent-signup/revoke` with the key: give the account up. Unclaimed, it turns off; claimed, only your link closes.

## B. auth.md

1. Discover: `https://mcp.corsair.dev/mcp` answers 401 with `resource_metadata`. Its authorization server metadata (`https://hub.corsair.dev/.well-known/oauth-authorization-server/mcp-auth`) carries an `agent_auth` block pointing here.
2. Register: `POST https://hub.corsair.dev/api/lug/agent/identity` with `{"type": "anonymous"}`, or `{"type": "service_auth", "login_hint": "person@example.com"}`. Optional: `agent_name`, `harness`, `note_to_human`. You get `identity_assertion`, `claim_token`, and for service_auth a `claim` block.
3. Claim (optional, needed to connect apps): `POST https://hub.corsair.dev/api/lug/agent/identity/claim` with `{"claim_token": "...", "login_hint": "person@example.com"}`. Show the person `claim_attempt.verification_uri` and `claim_attempt.user_code`; they sign in there and approve.
4. Poll: `POST https://hub.corsair.dev/api/mcp-auth/token` with `grant_type=urn:workos:agent-auth:grant-type:claim&claim_token=...` every `interval` seconds. `authorization_pending` until they approve.
5. Exchange: `POST https://hub.corsair.dev/api/mcp-auth/token` with `grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=<identity_assertion>`. You get a 15-minute `access_token` for `https://mcp.corsair.dev/mcp`. Exchange again when it runs out.
6. Use: call `https://mcp.corsair.dev/mcp` with `Authorization: Bearer <access_token>`. The `identity_assertion` is your link's API key, an opaque `mcpk_` string rather than a JWT: send it as the assertion unchanged. `mcp_url` with that key works too, and `GET https://hub.corsair.dev/api/lug/agent-signup/status` with it checks that it still works.
7. Revoke: `POST https://hub.corsair.dev/api/mcp-auth/revoke` with `token=<identity_assertion>` (RFC 7009, the metadata's `revocation_endpoint`). Always 200.

## What you can do

- Before the claim: the built-in apps (PM, CRM, skills, routines). You can't connect apps or use metered ones, and an unclaimed account stops working after 7 days.
- After the claim: call `get_connect_link` for an app and give the person the link. Writes that delete wait for their approval (Cautious mode).
- If the person already has Lug, you get a link on their Lug once they approve, with the key you already hold. If you made an account first and they claim it, your address moves to their handle: read the new `mcp_url` from status.

## Rules

- Don't sign up again to get around a limit or an error. One account per person.
- Don't put the key or claim token in a URL, a log or a chat with anyone but your person.
- Errors are JSON with `error`, `error_description` and `agent_support`. A 429 `rate_limited` carries `retry_after` in seconds.

## Scopes and limits

- Scopes: `lug:builtin` before the claim, `lug:apps` after it.
- Limits: 3 signups per IP address an hour and 10 a day, and 6 an hour and 20 a day per network; 3 claim emails to one address a day and 10 to one company's domain; one resend every 5 minutes.
- Every error code: https://docs.corsair.dev/cloud/agent-signup#errors. Terms: https://corsair.dev/terms-of-service. Privacy: https://corsair.dev/privacy-policy. Contact: team@corsair.dev.

Path of your link: `/agent`. The guide for people and agent builders: https://docs.corsair.dev/cloud/agent-signup. More: https://lug.dev/llms.txt
