# Authentication

The Kafkai MCP server supports two authentication methods. Both
resolve to your Kafkai account — tools always see your own projects
and spend your own credits, whichever method the client uses.

| Method | Best for | Set up in |
| --- | --- | --- |
| OAuth 2.1 sign-in | Interactive clients (claude.ai, ChatGPT, Claude Code) | The client itself |
| Static API token | Headless clients (Hermes, servers, scripts) | [API tokens page](https://kafkai.com/en/accounts/api-tokens/) |

## OAuth 2.1

The server implements the standard MCP authorization flow, so
compliant clients need nothing beyond the server URL:

- **Discovery.** Clients find the authorization endpoints through the
  standard well-known metadata (RFC 8414 and RFC 9728) published
  under `https://kafkai.com/mcp`.
- **Dynamic client registration.** Clients register themselves on
  first contact. There are no client IDs or secrets to copy.
- **PKCE.** Authorization uses PKCE with the S256 challenge method.
- **Consent.** The browser opens a Kafkai page where you sign in with
  your account and approve the client's access request.
- **Token lifetime.** Access tokens are short-lived. Clients hold a
  refresh token and rotate it automatically, so you sign in once, not
  every hour.
- **Revocation.** The server supports token revocation; removing the
  connector in your client ends the session, and short token
  lifetimes bound how long a stale token stays valid.

### Scopes

Two scopes exist:

- `kafkai:read` — read project and keyword data.
- `kafkai:write` — create and delete projects, queue research updates,
  and publish articles. Both scopes are granted by default.

## Static API tokens

API tokens are long-lived credentials for clients that cannot open a
browser. They are created on the
[API tokens page](https://kafkai.com/en/accounts/api-tokens/) and sent as a Bearer
header:

```
Authorization: Bearer YOUR_API_TOKEN
```

Properties worth knowing:

- The raw token is shown exactly once, at creation. Kafkai stores a
  SHA-256 hash, so a lost token cannot be recovered — only replaced.
- Tokens do not expire until you revoke them.
- Each token records when it was last used, which helps you spot
  tokens that are no longer needed — or used unexpectedly.
- Revocation is immediate.

See [Connect Hermes and Other Clients](https://kafkai.com/en/docs/connect-hermes/) for
client setup.

## What a connected agent can do

Anything you can do with your account's data: read projects,
keywords, and articles; create and delete projects;
queue research updates. Every data-returning call spends credits from
your balance.

Connect only clients you trust, and revoke access you no longer use.

One thing the server never sees: your agent's LLM credentials. The
writing happens on your side of the connection, with whatever model
your agent runs.
