🔐 支票员MCP服务器
MCP(模型上下文协议)服务器,用于Clerk用户的全面管理。此项目使您能够轻松地将Clerk的功能集成到任何兼容的MCP客户端中,包括Cursor AI、Claude Desktop和VS Code。
✨ 功能
这个MCP服务器暴露了 4个必备工具 用于管理Clerk用户:
🛠️ 可用工具
| 工具 | 描述 | 参数 |
|---|---|---|
list-users | 带分页的用户列表 | limit (1-100) offset, orderBy |
delete-user 永久删除一个用户 userId (必填) | ||
lock-user | 锁定用户(阻止登录) | userId (必填) |
unlock-user | 解锁一个用户(允许登录) | userId (必填) |
⚠️(警告或注意的符号,无具体文字含义,可理解为“注意”或“警告”) 注意手术 delete-user é(在葡萄牙语中相当于英语中的e,但在发音上可能有所不同,具体发音需根据语境判断) 不可逆的! 使用时务必小心。🚀 快速安装
1. 克隆仓库
git clone https://github.com/correaito/mcp_clerk.git
cd mcp_clerk2. 安装依赖项
npm install3. 配置环境变量
选项A:复制示例文件
cp env.example .env.local选项B:手动创建文件 .env.local
# Clerk API Keys
CLERK_SECRET_KEY=your_secret_key_here
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_publishable_key_here
# Server Configuration
PORT=50004. 从出纳员那里获取您的钥匙
- 访问 职员仪表盘
- 选择您的项目
- 去吧 API密钥
- 副本:
- 密钥 (以……开始 sk_live_ 或者 sk_test_) - 可公开密钥 (以……开始 pk_live_ 或者 pk_test_)
5. 编译项目
npm run build⚙️ MCP客户端配置
🎯 Cursor AI(推荐)
- 打开光标设置 (
Ctrl/Cmd + ,) - 搜索“MCP” 在搜索栏里
- 添加配置:
{
"mcpServers": {
"Clerk": {
"command": "node",
"args": ["caminho/para/mcp_clerk/dist/server-stdio.js"],
"env": {
"CLERK_SECRET_KEY": "your_secret_key_here",
"NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY": "your_publishable_key_here"
}
}
}
}完整路径示例:
{
"mcpServers": {
"Clerk": {
"command": "node",
"args": ["C:\\projetos\\mcp_clerk\\dist\\server-stdio.js"],
"env": {
"CLERK_SECRET_KEY": "your_secret_key_here",
"NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY": "your_publishable_key_here"
}
}
}
}- 重启光标
- 测试输入
@Clerk没有聊天功能来查看可用工具
Claude 桌面版
- 打开配置文件:
- Windows: %APPDATA%\Claude\claude_desktop_config.json - macOS(发音为“Mac OS”,其中“OS”代表“Operating System”,即操作系统): ~/Library/Application Support/Claude/claude_desktop_config.json
- 添加配置:
{
"mcpServers": {
"Clerk": {
"command": "node",
"args": ["caminho/para/mcp_clerk/dist/server-stdio.js"],
"env": {
"CLERK_SECRET_KEY": "your_secret_key_here",
"NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY": "your_publishable_key_here"
}
}
}
}- 重启 Claude 桌面应用
💻 VS Code(Visual Studio Code,一款轻量级的源代码编辑器)
- 安装MCP扩展 (如可用)
- 通过 settings.json 进行配置:
{
"mcp.servers": {
"Clerk": {
"command": "node",
"args": ["caminho/para/mcp_clerk/dist/server-stdio.js"],
"env": {
"CLERK_SECRET_KEY": "your_secret_key_here",
"NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY": "your_publishable_key_here"
}
}
}
}🌐 HTTP 模式(开发用)
如果更喜欢使用HTTP服务器进行测试:
1. 启动HTTP服务器
npm start2. 使用MCP Inspector进行测试
npx @modelcontextprotocol/inspector- 连接至:
http://localhost:5000/mcp
3. 使用cURL进行测试
健康检查:
curl http://localhost:5000列出用户:
curl -X POST http://localhost:5000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list-users",
"arguments": {
"limit": 10,
"offset": 0
}
},
"id": 1
}'阻止用户:
curl -X POST http://localhost:5000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "lock-user",
"arguments": {
"userId": "user_xxxxxxxxxxxxx"
}
},
"id": 2
}'📚 使用示例
无光标AI
@Clerk list-users limit=5
@Clerk lock-user userId=user_2abc123def456
@Clerk unlock-user userId=user_2abc123def456没有Claude桌面版
Use a ferramenta Clerk para listar os últimos 10 usuários cadastrados
Bloqueie o usuário com ID user_2abc123def456🔧 可用脚本
# Desenvolvimento
npm run dev # Servidor HTTP em modo dev
npm run dev:stdio # Servidor STDIO em modo dev
# Produção
npm run build # Compila o projeto
npm start # Servidor HTTP (porta 5000)
npm run start:stdio # Servidor STDIO📁 项目结构
mcp_clerk/
├── src/
│ ├── server.ts # Servidor HTTP (porta 5000)
│ ├── server-stdio.ts # Servidor STDIO (para Cursor/VS Code)
│ └── clerk-tools.ts # Implementação das ferramentas
├── dist/ # Arquivos compilados
├── env.example # Exemplo de configuração
├── .env.local # Suas credenciais (NÃO commitado)
├── .gitignore # Arquivos ignorados pelo Git
├── package.json # Dependências e scripts
├── tsconfig.json # Configuração TypeScript
└── README.md # Este arquivo🛡️ 安全
- ✅ 没有硬编码的密钥 在代码中
- ✅ 档案
.env.local受保护的 pelo(葡萄牙语).gitignore - ✅ 环境变量 通过(某种方式)装载
dotenv - ⚠️ 永远不要分享 其书记员的资格证书
- ⚠️(警告符号,无具体文字含义,可理解为“注意”或“警告”的意思) “Operação”在葡萄牙语中意为“行动”或“手术”。根据上下文,它可以翻译为相应的中文词汇。例如,在军事或政治语境中,可以翻译为“行动”;在医学语境中,则翻译为“手术”。
delete-user这是不可逆转的 - 用的时候要小心!
🐞 故障排除
问题:“未找到 CLERK_SECRET_KEY”
解决方案检查文件 .env.local 存在并且包含正确的密钥。
问题:“连接 Clerk 时出错”
解决方案请检查您的Clerk密钥是否正确且处于激活状态。
问题:“工具未显示在光标上”
解决方案:
- 在配置文件中检查路径
- 完全重启光标
- 检查项目是否已编译
npm run build)
问题:“端口5000已被占用”
解决方案在文件中修改门(或“更改文件中的门”) .env.local:
PORT=3001🤝 贡献(或“助力”)
- Fork 该项目
- 为你的功能创建一个分支
git checkout -b feature/AmazingFeature) - 提交你的更改
git commit -m 'Add some AmazingFeature') - 推送至分支
git push origin feature/AmazingFeature) - 提交一个拉取请求(或合并请求)
📄 许可证
这个项目遵循MIT许可证。请参阅文件。 LICENSE 以获取更多详情。
🙏 感谢
- 职员 - 用户认证与管理
- 模型上下文协议 - 与人工智能(IAs)集成协议
- Cursor AI(Cursor人工智能) - 集成AI的代码编辑器
______________________________________________________________________
为开发者社区用心打造
