# Managing apps from an assistant (MCP)

> Manage apps, API keys and users from Claude Code: access tokens, levels, and how keys stay out of the conversation.

authbase has an [MCP](https://modelcontextprotocol.io) server at `/mcp`. A
client such as Claude Code can create apps, change their settings, create
and revoke API keys, and look after users, with the same checks and the
same audit log as the dashboard.

## Connect Claude Code

1. In the dashboard, open your account and create an **access token**. It
   needs your password, and it is shown once.
2. Run the command shown with it, **in your own terminal**, so the token
   never enters a conversation:

   ```sh
   claude mcp add --transport http --scope user authbase https://auth.example.com/mcp \
     --header "Authorization: Bearer mt_…"
   ```

3. Start a new session and ask it to list your apps.

Any client that speaks Streamable HTTP with a Bearer header works.
Clients that need OAuth (claude.ai connectors) are not supported yet.

## Access levels

| Level | Can |
|---|---|
| `read` | see apps, settings, users, API key names, signing keys and the audit log |
| `write` (default) | also create apps, change settings and users, create, rotate and revoke API keys, sign users out |
| `full` | also delete apps and users, and rotate signing keys |

A token acts as you on **all** your apps. It expires after 90 days unless
you choose otherwise, works only on `/mcp`, and cannot reach your account,
password, sessions or other tokens. Revoking it takes effect at once.
Changing or resetting your password revokes every token.

Users cannot be created or given a password this way: your backend does
that with its API key.

## How API keys get where they belong

An API key never appears in the conversation. `create_api_key` and
`rotate_api_keys` answer a **claim**, a code that works once within 10
minutes, and a command that stores the key in a file without printing it:

```sh
umask 077 && curl -fsS -X POST 'https://auth.example.com/v1/api-key-claims' \
  -H 'Content-Type: application/json' \
  -d '{"claim":"kc_…","env_name":"AUTHBASE_API_KEY"}' >> .env
```

The key is created when the claim is redeemed, and a rotation starts then.
A claim that is not redeemed lapses and changes nothing. A redeemed code
is worthless, so it does no harm in a transcript. If a fresh claim is
refused, look at the app's API keys and revoke any you do not know.

## Before you connect

- **Personal data reaches the assistant.** Listing users sends their
  emails, roles and metadata to it. Use it only where that is acceptable.
- **Users can write text the assistant reads** (metadata, usernames).
  The server tells it to treat these as data, but keep approval prompts on
  for changes, and prefer `read` where it is enough.
- `write` is powerful: changing an app's password reset URL or a user's
  email can lead to taking over accounts. Treat the token like your
  password.
- Anything a token does is in the audit log as your account, with the
  token's name.

## Limits

10 live tokens per account; 300 calls a minute per token; 20 failed
authentications a minute per IP; 10 claim redemptions a minute per IP.
