返回市场
更好的认证MCP服务器

更好的认证MCP服务器

作者:nahmanmate38 星标更新:2025-02-14

项目介绍

better-auth-mcp-server MCP服务器

smithery徽章

用于身份验证管理的企业级解决方案:

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

<a href="https://glama.ai/mcp/servers/7f1irpro2i"><img width="380" height="200" src="https://gips1.baidu.com/it/u=272520364,2803944438&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Better Auth Server MCP服务器" /></a>

功能

核心工具

  • 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

配置

环境变量

# 必需
BETTER_AUTH_PROJECT_ID=你的项目ID
BETTER_AUTH_API_KEY=你的API密钥

# 可选
BETTER_AUTH_ENV=development|staging|production
LOG_LEVEL=info|debug|error

安全最佳实践

  1. API密钥管理

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

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

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

安装

通过Smithery安装

要通过Smithery自动安装Better Auth MCP服务器到Claude桌面:

npx -y @smithery/cli install @nahmanmate/better-auth-mcp-server --client claude

要在Claude桌面中使用,请添加服务器配置:

在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服务器通过标准I/O通信,调试可能会有挑战。我们建议使用MCP Inspector,它作为包脚本提供:

npm run inspector

Inspector将提供一个URL,以便在浏览器中访问调试工具。

使用示例

项目设置

// 在项目中初始化Better-Auth
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
  }
});

// 测试核心身份验证流程
await mcp.useTool('test_auth_flows', {
  flows: ['login', 'register', '2fa']
});

从Auth.js/NextAuth迁移

// 分析当前的身份验证实现
await mcp.useTool('analyze_current_auth', {
  projectPath: './my-next-app'
});

// 生成迁移步骤
await mcp.useTool('generate_migration_plan', {
  projectPath: './my-next-app',
  currentAuthType: 'next-auth'
});