企业认证服务端
启用企业级身份验证管理,具有安全的凭据处理和多协议身份验证支持,并提供用于分析、设置和测试身份验证系统的工具。
可用工具 (8 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
analyze_project 1 个参数 需填 1 项
Analyze project structure and dependencies to recommend Better-Auth setup approach
必填参数:projectPath
setup_better_auth 2 个参数 需填 2 项
Install and configure Better-Auth in the project
必填参数:projectPath、config
analyze_current_auth 1 个参数 需填 1 项
Detect and analyze existing auth.js/next-auth implementation
必填参数:projectPath
generate_migration_plan 2 个参数 需填 2 项
Create step-by-step migration plan from existing auth to Better-Auth
必填参数:projectPath、currentAuthType
test_auth_flows 1 个参数 需填 1 项
Test authentication workflows
必填参数:flows
test_security 1 个参数 需填 1 项
Run security tests on Better-Auth setup
必填参数:tests
analyze_logs 1 个参数 需填 1 项
Analyze Better-Auth logs for issues
必填参数:timeRange
monitor_auth_flows 1 个参数 需填 1 项
Real-time monitoring of authentication processes
必填参数:duration
服务介绍
better-auth-mcp-server MCP 服务器
用于身份验证管理的 MCP 服务器
企业级身份验证解决方案,提供:
- 🔐 使用 AES-256 加密的安全凭证管理
- ⚙️ 多协议认证(OAuth2、SAML、LDAP)
- 🛡️ 实时威胁检测和预防
功能
核心工具
analyze_project- 分析项目结构以获取身份验证设置建议setup_better_auth- 使用项目 ID 和 API 密钥配置身份验证提供者analyze_current_auth- 检测现有的 auth.js/next-auth 实现generate_migration_plan- 创建逐步迁移路径
测试与安全
test_auth_flows- 验证登录/注册/重置/两步验证流程test_security- 运行符合 OWASP 的安全检查analyze_logs- 审查身份验证系统日志中的问题monitor_auth_flows- 实时身份验证监控
可用资源
better-auth://config- 当前 Better-Auth 配置设置better-auth://logs- 身份验证系统日志
开发
克隆并安装:
git clone https://github.com/better-auth-mcp-server/better-auth-mcp-server.git
cd better-auth-mcp-server
npm install
构建服务器:
npm run build
开发时自动重建:
npm run watch
配置
环境变量
# Required
BETTER_AUTH_PROJECT_ID=your-project-id
BETTER_AUTH_API_KEY=your-api-key
# Optional
BETTER_AUTH_ENV=development|staging|production
LOG_LEVEL=info|debug|error
安全最佳实践
-
API 密钥管理
- 将 API 密钥存储在环境变量中
- 定期轮换密钥
- 为每个环境使用不同的密钥
-
访问控制
- 实施速率限制
- 配置 IP 白名单
- 使用最小权限原则
-
监控
- 启用审计日志
- 监控身份验证失败
- 设置对可疑活动的警报
安装
通过 Smithery 安装
要通过 Smithery 自动安装适用于 Claude Desktop 的 Better Auth MCP 服务器:
npx -y @smithery/cli install @nahmanmate/better-auth-mcp-server --client claude
要在 Claude Desktop 中使用该服务器,请添加服务器配置:
在 MacOS 上:~/Library/Application Support/Claude/claude_desktop_config.json
在 Windows 上:%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"better-auth-mcp-server": {
"command": "node",
"args": ["/path/to/better-auth-mcp-server/build/index.js"],
"disabled": false,
"alwaysAllow": []
}
}
}
调试
由于 MCP 服务器通过标准输入输出通信,调试可能具有挑战性。我们建议使用 MCP Inspector,它作为一个包脚本提供:
npm run inspector
Inspector 将提供一个 URL 以便您在浏览器中访问调试工具。
使用示例
项目设置
// Initialize Better-Auth in your project
await mcp.useTool('setup_better_auth', {
projectPath: './my-next-app',
config: {
projectId: process.env.BETTER_AUTH_PROJECT_ID,
apiKey: process.env.BETTER_AUTH_API_KEY
}
});
// Test core authentication flows
await mcp.useTool('test_auth_flows', {
flows: ['login', 'register', '2fa']
});
从 Auth.js/NextAuth 迁移
// Analyze current auth implementation
await mcp.useTool('analyze_current_auth', {
projectPath: './my-next-app'
});
// Generate migration steps
await mcp.useTool('generate_migration_plan', {
projectPath: './my-next-app',
currentAuthType: 'next-auth'
});