Use Clerk's MCP server
Clerk provides a remote Model Context Protocol (MCP) 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.
Alternatively, you can manually configure it:
- 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. - In the sidenav, select Tools & MCP.
- Select the New MCP Server option, which will open up a new tab with the MCP configuration JSON file.
- Add the following configuration to the JSON file:
{
"mcpServers": {
"clerk": {
"url": "https://mcp.clerk.com/mcp"
}
}
}- Once added, you should see a green active status.
- Run the following command to add Clerk's MCP server:
claude mcp add clerk --transport http https://mcp.clerk.com/mcp - Run
/mcponce you've opened a Claude Code session to verify the connection.
- Navigate to Settings in the sidebar on web or desktop.
- Scroll to Integrations at the bottom and select Add more.
- In the prompt, enter the following:
- Integration name: Clerk
- Integration URL:
https://mcp.clerk.com/mcp
- Make sure to enable the tools in any new chat.
- Open the following file:
~/Library/Application Support/Claude/claude_desktop_config.json. - Add the following configuration and restart the Claude Desktop app:
{ "mcpServers": { "clerk": { "command": "npx", "args": ["-y", "mcp-remote", "https://mcp.clerk.com/mcp"] } } }
Connecting VSCode to Clerk's MCP server
-
Press
Cmd/Ctrl + Shift + Pand search for MCP: Add Server. -
Depending on your preferred transport method, follow the instructions below:
Enter the following URL and hit enter:
https://mcp.clerk.dev/mcpEnter the following command and hit enter:
npx mcp-remote https://mcp.clerk.com/mcp -
Enter the name Clerk and hit enter.
Connecting Windsurf to Clerk's MCP server
- Press
Ctrl/Cmd + ,to open Windsurf settings. - Scroll to Cascade -> MCP Servers.
- Select Open MCP Marketplace.
- Under Installed MCPs, select the gear icon in the top right corner of the section.
- Add the following configuration to the JSON file:
{ "mcpServers": { "clerk": { "command": "npx", "args": ["-y", "mcp-remote", "https://mcp.clerk.com/mcp"] } } }
Connecting Zed to Clerk's MCP server
- Press
Ctrl/Cmd + ,to open Zed settings. - Select Edit in settings.json to open the
setting.jsonfile. - Add the following configuration to the JSON file:
{ "context_servers": { "clerk": { "command": { "path": "npx", "args": ["-y", "mcp-remote", "https://mcp.clerk.com/mcp"] } } } }
Run the following command in the terminal:
codex mcp add clerk https://mcp.clerk.com/mcp- Open the
~/.codex/config.tomlconfig file in your preferred editor. - Add the following configuration:
[mcp_servers.clerk] type = "url" url = "https://mcp.clerk.com/mcp"
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:
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.
Feedback
Last updated on
Edit on GitHub