Skip to main content
Glama
README.md
# @authn8/mcp-server

MCP server for [Authn8](https://authn8.com), shared 2FA for teams. It lets AI agents
fetch TOTP codes for the 2FA accounts your team shares in Authn8, so an agent can
finish a sign-in without anyone reading a code out of a phone. Every code it fetches
is recorded in Authn8's access log with the name of the token that asked for it.
An agent can also add a 2FA account from its secret, for example after it turns on
2FA for a new service, and put it in your team's groups.

Works with OpenAI Codex, Cursor, Claude Code, Claude, GitHub Copilot in VS Code and
any other MCP client. Each one has a step-by-step guide at
[authn8.com/integrations](https://authn8.com/integrations).

Listed in the [MCP Registry](https://registry.modelcontextprotocol.io) as
`io.github.authn8/mcp-server`.

## Requirements

- An Authn8 business on the Premium or Enterprise plan, which include MCP and the
  REST API. A business's tokens stop working if its subscription ends.
- An MCP token. In Authn8, open **Settings → Tokens** and the **MCP Tokens** tab
  ([how to create an MCP token](https://authn8.com/knowledge-base/how-to-create-an-mcp-token)).
  Tokens start with `pat_`. A token only reaches the 2FA accounts its creator can
  already access, and you can narrow it further to chosen groups and give it an
  expiry date. It can add accounts to groups its creator owns or has Can manage
  access to, and a token narrowed to groups adds only to those.
- Node.js 18 or later, if you run the npm package. The hosted endpoint needs nothing
  installed.

## Two ways to connect

| | Hosted endpoint | npm package |
|---|---|---|
| Install | None | `npx` runs it locally |
| Transport | Streamable HTTP | stdio |
| Address | `https://api.authn8.com/mcp` | `npx -y @authn8/mcp-server` |
| Token | `Authorization: Bearer pat_...` header | `AUTHN8_API_KEY` environment variable |

Both offer the same five tools: `list_accounts`, `get_otp`, `whoami`, `list_groups`
and `add_account`. Use the hosted endpoint unless your client only runs local
(stdio) servers: there is nothing to install or keep up to date.

## Hosted endpoint

Point any MCP client that supports Streamable HTTP at `https://api.authn8.com/mcp`
and send your token in the `Authorization` header as `Bearer pat_your_token_here`.

Clients that read a config file can take the token from an environment variable, so
it never sits in the file. The examples below use `AUTHN8_TOKEN`:

```bash
# macOS and Linux (add to ~/.zshrc or ~/.bashrc)
export AUTHN8_TOKEN="pat_your_token_here"
```

```powershell
# Windows (PowerShell)
setx AUTHN8_TOKEN "pat_your_token_here"
```

Open a new terminal, or restart your editor, after setting it.

### OpenAI Codex

The Codex CLI and the Codex IDE extension share one config file,
`~/.codex/config.toml`. Let Codex add the server:

```bash
codex mcp add authn8 --url https://api.authn8.com/mcp --bearer-token-env-var AUTHN8_TOKEN
```

Leave `AUTHN8_TOKEN` as it is: `--bearer-token-env-var` takes the variable's name,
not the token. The command writes this table, which you can also add by hand:

```toml
[mcp_servers.authn8]
url = "https://api.authn8.com/mcp"
bearer_token_env_var = "AUTHN8_TOKEN"
```

Type `/mcp` in Codex to see the server. If Codex was already running when you set
the variable, run `codex app-server daemon stop` and start Codex again, so its
background service sees the variable.

Codex asks before it calls an Authn8 tool, so `codex exec` and other runs with no one
to answer refuse the call. To let them read codes, approve `get_otp`:

```toml
[mcp_servers.authn8.tools.get_otp]
approval_mode = "approve"
```

[OpenAI Codex setup guide](https://authn8.com/integrations/openai-codex)

### Cursor

Add this to `~/.cursor/mcp.json` for all projects, or to `.cursor/mcp.json` in a
project. Cursor fills in `${env:AUTHN8_TOKEN}` from your environment:

```json
{
  "mcpServers": {
    "authn8": {
      "url": "https://api.authn8.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:AUTHN8_TOKEN}"
      }
    }
  }
}
```

Cursor's cloud agents take the same URL, with the header
`Authorization: Bearer pat_your_token_here`, from the Cursor dashboard. The
[Cursor setup guide](https://authn8.com/integrations/cursor) also has an Add to
Cursor button.

### Claude Code

```bash
claude mcp add --transport http --scope user authn8 https://api.authn8.com/mcp \
  --header "Authorization: Bearer pat_your_token_here"
```

`--scope user` makes the server available in all your projects. Leave it out to add
it to the current project only.

To share the setup through a repository, commit a `.mcp.json` that reads each team
member's own token from `AUTHN8_TOKEN`:

```json
{
  "mcpServers": {
    "authn8": {
      "type": "http",
      "url": "https://api.authn8.com/mcp",
      "headers": {
        "Authorization": "Bearer ${AUTHN8_TOKEN}"
      }
    }
  }
}
```

[Claude Code setup guide](https://authn8.com/integrations/claude-code)

### Claude (claude.ai and the desktop app)

In Claude, click **Plugins** in the sidebar, then **Add** and **Add custom
connector**. Enter `https://api.authn8.com/mcp` as the server URL, choose **No
sign-in** under Authentication, and add a request header named `authorization` with
the value `Bearer pat_your_token_here`.

- Request headers are a beta that only some Claude organizations have. Without
  them, run the npm package from Claude Desktop's config file (below).
- On Team and Enterprise, an Owner adds the connector once and every member shares
  that one token.
- Claude Code signed in with the same Claude account can use the connector too.

[Claude setup guide](https://authn8.com/integrations/claude)

### VS Code (GitHub Copilot)

Add this to Copilot's user MCP file, `~/.copilot/mcp-config.json`. GitHub Copilot
CLI reads the same file.

```json
{
  "mcpServers": {
    "authn8": {
      "type": "http",
      "url": "https://api.authn8.com/mcp",
      "headers": {
        "Authorization": "Bearer ${AUTHN8_TOKEN}"
      },
      "tools": ["*"]
    }
  }
}
```

[VS Code setup guide](https://authn8.com/integrations/vs-code)

### Other clients

Give the client the server URL and the `Authorization` header over Streamable HTTP.
For Gemini CLI, add this to `~/.gemini/settings.json` (its `httpUrl` key means
Streamable HTTP):

```json
{
  "mcpServers": {
    "authn8": {
      "httpUrl": "https://api.authn8.com/mcp",
      "headers": {
        "Authorization": "Bearer pat_your_token_here"
      }
    }
  }
}
```

[Any MCP client setup guide](https://authn8.com/integrations/any-mcp-client)

## npm package

For clients that only run local (stdio) servers. The package calls the Authn8 REST
API with your token and offers the same five tools.

### Claude Desktop

Open **Settings → Developer → Edit Config**, or edit the file directly:

- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux:** `~/.config/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "authn8": {
      "command": "npx",
      "args": ["-y", "@authn8/mcp-server"],
      "env": {
        "AUTHN8_API_KEY": "pat_your_token_here"
      }
    }
  }
}
```

Quit and restart Claude Desktop after saving.

### Claude Code

```bash
claude mcp add --env AUTHN8_API_KEY=pat_your_token_here --transport stdio --scope user authn8 \
  -- npx -y @authn8/mcp-server
```

### Other clients

Run `npx -y @authn8/mcp-server` as a stdio server with `AUTHN8_API_KEY` set.

### Environment variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `AUTHN8_API_KEY` | Yes | - | Your MCP token (`pat_...`) |
| `AUTHN8_API_URL` | No | `https://api.authn8.com` | API base URL |

On startup the server checks the token and prints the business name, token name,
account count and expiry date to stderr. If the token is missing or rejected, it prints
why and keeps running: clients can still list the tools, and every tool call returns
that error until the token is fixed.

## Tools

All tools declare an output schema and return `structuredContent` alongside the
text block, so clients get typed results without re-parsing JSON out of text.

### list_accounts

Returns all 2FA accounts accessible to this token.

**Example response:**
```json
{
  "accounts": [
    {
      "id": "924c52a6-4457-4970-a39f-4dc620217683",
      "name": "AWS Production",
      "issuerDomain": "amazon.com"
    }
  ]
}
```

### get_otp

Generates a TOTP code for a specific account.

**Parameters:**
- `account_id` (string, optional): UUID of the account
- `account_name` (string, optional): name or issuer domain to search for
  (case-insensitive partial match)

Provide either `account_id` or `account_name`. If more than one account matches
the name, the tool returns them in `multipleMatches` so you can retry with an
`account_id`.

**Example response:**
```json
{
  "name": "AWS Production",
  "code": "483920",
  "length": 6,
  "remainingSeconds": 17
}
```

`remainingSeconds` is the number of seconds until the code changes. To get a fresh
code, wait that long and call once, instead of calling until the code changes.

**Ambiguous match:**
```json
{
  "error": "Multiple accounts match 'aws'. Please be more specific or use account_id.",
  "length": 0,
  "multipleMatches": [
    {
      "id": "924c52a6-4457-4970-a39f-4dc620217683",
      "name": "AWS Production",
      "issuerDomain": "amazon.com"
    }
  ]
}
```

### whoami

Returns information about the current token.

**Example response:**
```json
{
  "tokenName": "Claude Code",
  "businessName": "Acme Ltd",
  "scopedGroups": [
    { "id": "cfeba14a-e990-49e8-b6e5-61d63f7d68c8", "name": "Engineering" }
  ],
  "expiresAt": "2027-06-30T23:59:59Z",
  "accountCount": 12
}
```

### list_groups

Returns the groups this token can add accounts to, sorted by name: groups the token's
creator owns or has Can manage access to, and only the token's scoped groups if it has
any. Call it before `add_account`.

**Example response:**
```json
{
  "groups": [
    { "id": "cfeba14a-e990-49e8-b6e5-61d63f7d68c8", "name": "Engineering" }
  ]
}
```

### add_account

Adds one 2FA account from its secret and puts it in the chosen groups. The account
belongs to the token's creator and counts toward the plan's account limit, and the
secret is encrypted as soon as it arrives.

**Parameters:**
- `secret` (string, required): a Base32 key, or the `otpauth://` link from the setup
  QR code. A Google Authenticator export link (`otpauth-migration://`) holds several
  accounts and is refused: add one account per call.
- `name` (string, optional): the account's name, usually the service it signs in to.
  Required unless `secret` is an `otpauth://` link with an issuer or label.
- `issuer_domain` (string, optional): the service's domain, for example `github.com`.
  Looked up from the name when left out.
- `description` (string, optional): notes about the account.
- `group_ids` (array of UUIDs, optional): groups from `list_groups`, each once. A token
  with scoped groups must name at least one of them, so it can see the account it
  added.

It is all or nothing: if any input or group is refused, nothing is added, and the
tool returns an error that starts with a code such as `GROUP_REQUIRED` or
`SECRET_INVALID`. The response never includes the secret or a code: call `get_otp`
with the returned `id` to read one. Authn8's Activity Log records "Account '[name]'
added" with the device MCP, and one more entry for each group the account went into.

**Example response:**
```json
{
  "id": "5b0f7d1e-2c4a-4e8b-9f3d-7a6c1e2b4d8f",
  "name": "GitHub",
  "issuerDomain": "github.com",
  "groups": [
    { "id": "cfeba14a-e990-49e8-b6e5-61d63f7d68c8", "name": "Engineering" }
  ]
}
```

## Links

- [Authn8](https://authn8.com): shared 2FA for teams
- [Setup guides for each MCP client](https://authn8.com/integrations)
- [2FA codes for AI agents](https://authn8.com/for/ai-agents): scoped tokens, the
  Access Log and revoking
- [How to create an MCP token](https://authn8.com/knowledge-base/how-to-create-an-mcp-token)
- [GitHub repository](https://github.com/authn8/mcp-server)
- [Glama listing](https://glama.ai/mcp/servers/authn8/mcp-server)
- [MCP Registry entry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.authn8/mcp-server)

TDQS

A4.1/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: listing accounts, generating an OTP, checking token identity, listing groups, and adding an account. list_accounts and list_groups both list resources but target different entities and are well explained.

Naming Consistency4/5

Four tools follow a consistent verb_noun pattern: list_accounts, get_otp, list_groups, add_account. whoami is a minor deviation but is a conventional command name and remains understandable.

Tool Count5/5

Five tools are well-scoped for a 2FA account server focused on discovery, OTP retrieval, identity, and adding shared accounts. Each tool has a clear role without excessive surface area.

Completeness3/5

The set covers listing accounts, adding shared accounts, retrieving OTPs, and checking identity/groups. However, it lacks obvious lifecycle operations such as updating or removing accounts, which limits full account management.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues