首页
学习
活动
专区
圈层
工具
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
首页
学习
活动
专区
圈层
工具
MCP广场
MCP广场 >详情页
better-auth-mcp-server2025-05-210分享
github
启用企业级身份验证管理,具有安全的凭据处理和多协议身份验证支持,并提供用于分析、设置和测试身份验证系统的工具。
By nahmanmate
2025-05-210
github
详情内容

better-auth-mcp-server MCP 服务器

smithery 徽章

用于身份验证管理的 MCP 服务器

企业级身份验证解决方案,提供:

  • 🔐 使用 AES-256 加密的安全凭证管理
  • ⚙️ 多协议认证(OAuth2、SAML、LDAP)
  • 🛡️ 实时威胁检测和预防

Better Auth Server MCP 服务器

功能

核心工具

  • 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

安全最佳实践

  1. API 密钥管理

    • 将 API 密钥存储在环境变量中
    • 定期轮换密钥
    • 为每个环境使用不同的密钥
  2. 访问控制

    • 实施速率限制
    • 配置 IP 白名单
    • 使用最小权限原则
  3. 监控

    • 启用审计日志
    • 监控身份验证失败
    • 设置对可疑活动的警报

安装

通过 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'
});

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档