Skip to main content
Glama
mcp-clerk

mcp-clerk

by tembo
README.md
# mcp-clerk

An [MCP](https://modelcontextprotocol.io) server for the [Clerk](https://clerk.com) Backend API. Ask your AI assistant to find users, check their status, update profiles and metadata, and **ban, lock or sign out** abusive accounts.

> **Status: pre-release.** The package is not on npm yet. Until it is, [run it from source](#development).

Clerk's own MCP server (`mcp.clerk.com`) helps you set up and configure Clerk apps. This one is for operating them: support and moderation work on the users you already have.

Not affiliated with or endorsed by Clerk.

## Tools

| Toolset | Tool | What it does |
|---|---|---|
| `users` | `search_users` | Find users by email, phone, username, name or ID, or list an organization's members |
| | `get_user` | Full profile: banned/locked status, emails, connected accounts, metadata, organizations |
| | `create_user` | Create a user |
| | `update_user` | Change name, username, external ID, primary email, locale or timezone |
| | `update_user_metadata` | Merge keys into public, private or unsafe metadata |
| | `delete_user` | Permanently delete a user (only with `--allow-delete`) |
| `moderation` | `ban_user` / `unban_user` | Ban signs the user out everywhere and blocks sign-in until unbanned |
| | `lock_user` / `unlock_user` | Block sign-in until the lock expires or is lifted |
| | `revoke_user_sessions` | Sign the user out on every device |

Both toolsets are on by default. More (sessions, organizations, invitations, allow/blocklists) are coming.

## Install

You need your instance's **secret key** from the Clerk Dashboard → **API keys**. Use a development instance's `sk_test_` key while you try it out.

**Claude Code**

```sh
claude mcp add clerk -e CLERK_SECRET_KEY=sk_live_... -- npx -y @tembo/mcp-clerk
```

**Cursor, Claude Desktop, Windsurf and other JSON-configured clients**

```json
{
  "mcpServers": {
    "clerk": {
      "command": "npx",
      "args": ["-y", "@tembo/mcp-clerk"],
      "env": { "CLERK_SECRET_KEY": "sk_live_..." }
    }
  }
}
```

**VS Code** (`.vscode/mcp.json`)

```json
{
  "inputs": [
    { "id": "clerk-secret-key", "type": "promptString", "description": "Clerk secret key", "password": true }
  ],
  "servers": {
    "clerk": {
      "command": "npx",
      "args": ["-y", "@tembo/mcp-clerk"],
      "env": { "CLERK_SECRET_KEY": "${input:clerk-secret-key}" }
    }
  }
}
```

**Codex** (`~/.codex/config.toml`)

```toml
[mcp_servers.clerk]
command = "npx"
args = ["-y", "@tembo/mcp-clerk"]
env = { CLERK_SECRET_KEY = "sk_live_..." }
```

Using Bun? Replace `npx -y` with `bunx`.

## Options

Pass options as flags after the package name, or set the environment variable.

| Flag | Environment variable | Default | |
|---|---|---|---|
| `--toolsets <list>` | `CLERK_MCP_TOOLSETS` | `users,moderation` | Comma-separated toolsets, or `all` |
| `--read-only` | `CLERK_MCP_READ_ONLY` | off | Only expose tools that read |
| `--allow-delete` | `CLERK_MCP_ALLOW_DELETE` | off | Expose tools that permanently delete data |
| `--protected-user-ids <list>` | `CLERK_MCP_PROTECTED_USER_IDS` | none | Users that can't be banned, locked, signed out or deleted |
| `--protected-org-ids <list>` | `CLERK_MCP_PROTECTED_ORG_IDS` | none | Same, for every member of these organizations |

For example, to give a support teammate lookup-only access:

```sh
claude mcp add clerk -e CLERK_SECRET_KEY=sk_live_... -- npx -y @tembo/mcp-clerk --read-only
```

## Safety

A Clerk secret key has full control of your instance, and this server can act on any user. It has guardrails:

- **Your client asks first.** Every tool that changes something is marked as such, so MCP clients ask you to approve it.
- **Reasons are required** for ban, lock, sign-out and delete.
- **Protect your own team.** Set `--protected-org-ids` to your company's Clerk organization so nobody on it can be banned, locked, signed out or deleted by mistake.
- **Deletes are off** unless you pass `--allow-delete`. Banning is reversible; deleting isn't.
- **Audit log.** Each write prints one JSON line to stderr with the tool, target user, reason and outcome. Most MCP clients keep server stderr in their logs.
- **Read-only mode** for people who only need to look things up.

Keep the secret key out of shared config files and source control.

## Development

```sh
bun install
bun run test        # builds dist/stdio.js, then runs the tests
bun run typecheck
bun run lint
```

Try it from source with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):

```sh
bun run build
CLERK_SECRET_KEY=sk_test_... npx @modelcontextprotocol/inspector node dist/stdio.js
```

Or point a client at your checkout: `claude mcp add clerk -e CLERK_SECRET_KEY=sk_test_... -- node /path/to/mcp-clerk/dist/stdio.js`.

The package is built with Bun into a single Node-compatible file, so `npx` users don't need Bun.

## License

[MIT](LICENSE)