# Use Clerk's MCP server

> Clerk MCP is currently in beta. The API may change before general availability.

Clerk provides a remote [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction){{ target: '_blank' }} server that allows AI agents like Claude, Cursor, and Github Copilot to access Clerk SDK snippets and implementation patterns. This provides AI agents with up-to-date code examples when developing with Clerk.

The Clerk MCP server provides:

- **SDK snippets**: Ready-to-use code patterns for common Clerk features.
- **Implementation guides**: Best practices for authentication flows, organizations, and more.
- **Framework-specific examples**: Patterns optimized for Next.js, React, and other supported frameworks.

## Setup instructions

To complete the integration, you'll need to connect your AI agent to Clerk's MCP server. Because each AI agent connects differently, select the appropriate tab below to see the specific setup instructions.

**Cursor**

### Connecting Cursor to Clerk's MCP server

[Add to Cursor](https://cursor.com/en-US/install-mcp?name=clerk&config=eyJ1cmwiOiJodHRwczovL21jcC5jbGVyay5jb20vbWNwIn0%3D)

Alternatively, you can manually configure it:

1. Navigate to **Cursor Settings**. To find this, open the **Command Palette** (`Cmd/Ctrl + Shift + P`) and search for **Cursor Settings**, or select the gear icon in the top right corner of the app.
2. In the sidenav, select **Tools & MCP**.
3. Select the **New MCP Server** option, which will open up a new tab with the MCP configuration JSON file.
4. Add the following configuration to the JSON file:

```json
{
  "mcpServers": {
    "clerk": {
      "url": "https://mcp.clerk.com/mcp"
    }
  }
}
```

5. Once added, you should see a green active status.

**Claude**

### Connecting Claude to Clerk's MCP server

**Claude Code**

1. Run the following command to add Clerk's MCP server:
   ```bash
   claude mcp add clerk --transport http https://mcp.clerk.com/mcp
   ```
2. Run `/mcp` once you've opened a Claude Code session to verify the connection.

**Claude.ai**

1. Navigate to **Settings** in the sidebar on web or desktop.
2. Scroll to **Integrations** at the bottom and select **Add more**.
3. In the prompt, enter the following:
   - **Integration name**: Clerk
   - **Integration URL**: `https://mcp.clerk.com/mcp`
4. Make sure to enable the tools in any new chat.

**Claude Desktop**

1. Open the following file: `~/Library/Application Support/Claude/claude_desktop_config.json`.
2. Add the following configuration and restart the Claude Desktop app:
   ```json
   {
     "mcpServers": {
       "clerk": {
         "command": "npx",
         "args": ["-y", "mcp-remote", "https://mcp.clerk.com/mcp"]
       }
     }
   }
   ```

**VSCode**

### Connecting VSCode to Clerk's MCP server

1. Press `Cmd/Ctrl + Shift + P` and search for **MCP: Add Server**.
2. Depending on your preferred transport method, follow the instructions below:

   **HTTP**

   Enter the following URL and hit enter: `https://mcp.clerk.dev/mcp`

   **Stdio**

   Enter the following command and hit enter:

   ```bash
   npx mcp-remote https://mcp.clerk.com/mcp
   ```
3. Enter the name **Clerk** and hit enter.

**Windsurf**

### Connecting Windsurf to Clerk's MCP server

1. Press `Ctrl/Cmd + ,` to open Windsurf settings.
2. Scroll to **Cascade → MCP Servers**.
3. Select **Open MCP Marketplace**.
4. Under **Installed MCPs**, select the gear icon in the top right corner of the section.
5. Add the following configuration to the JSON file:
   ```json
   {
     "mcpServers": {
       "clerk": {
         "command": "npx",
         "args": ["-y", "mcp-remote", "https://mcp.clerk.com/mcp"]
       }
     }
   }
   ```

**Zed**

### Connecting Zed to Clerk's MCP server

1. Press `Ctrl/Cmd + ,` to open Zed settings.
2. Select **Edit in settings.json** to open the `setting.json` file.
3. Add the following configuration to the JSON file:
   ```json
   {
     "context_servers": {
       "clerk": {
         "command": {
           "path": "npx",
           "args": ["-y", "mcp-remote", "https://mcp.clerk.com/mcp"]
         }
       }
     }
   }
   ```

**Codex**

### Connecting Codex to Clerk's MCP server

**Configuration via CLI**

Run the following command in the terminal:

```bash
codex mcp add clerk https://mcp.clerk.com/mcp
```

> If this is the first time you are using an MCP in Codex, you may need to enable the `rmcp` feature. To do so, add the following into your `~/.codex/config.toml` file:
>
> ```toml
> [beta]
> rmcp = true
> ```

**Configuration through the config file**

1. Open the `~/.codex/config.toml` config file in your preferred editor.
2. Add the following configuration:
   ```toml
   [mcp_servers.clerk]
   type = "url"
   url = "https://mcp.clerk.com/mcp"
   ```

**Other clients**

### Connecting other clients to Clerk's MCP server

Many other tools now support MCP servers. The easiest way is to use the streamable HTTP endpoint: `https://mcp.clerk.com/mcp`.

## Available tools

Clerk's MCP server provides the following tools:

| Tool                      | Description                                                 |
| ------------------------- | ----------------------------------------------------------- |
| `clerk_sdk_snippet`       | Access SDK code snippets and patterns for specific features |
| `list_clerk_sdk_snippets` | List all available snippets and bundles                     |

### Example usage

Once connected, you can ask your AI assistant questions such as:

- "How do I use the useUser hook in Clerk?"
- "Show me how to set up B2B SaaS with Clerk Organizations"
- "How do I implement a waitlist with Clerk?"
- "What's the best way to protect routes in Next.js with Clerk?"

The MCP server will provide accurate, up-to-date code snippets and implementation patterns.

### Available snippet bundles

For comprehensive implementations, you can request these bundles:

- **b2b-saas**: Complete B2B SaaS setup with organizations, billing, and role-based access
- **waitlist**: Waitlist and early access setup
- **auth-basics**: Core authentication hooks
- **custom-flows**: Build custom sign-in/sign-up flows
- **organizations**: Organization management for multi-tenant apps
- **server-side**: Server-side authentication patterns

## Frequently asked questions (FAQ)

### When or why should I use the Clerk MCP server?

We recommend that all developers building with Clerk use the MCP server to get the best experience out of their agents.

### Why am I seeing an internal server error when trying to connect?

This usually indicates a network or transport issue. Try disconnecting and reconnecting the MCP server, and ensure your client supports Streamable HTTP transport.

### Does the MCP server support Server-Sent Events (SSE)?

No. Clerk's MCP server only supports Streamable HTTP transport, available at `https://mcp.clerk.com/mcp`.

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
