mcpField
B
better-auth-mcp-server MCP Server

better-auth-mcp-server MCP Server

本地服务
github.com/nahmanmate开发工具4189 周前更新

关于 better-auth-mcp-server MCP Server

better-auth-mcp-server 是一个用于认证管理的 MCP 服务,提供认证项目分析、Better-Auth 配置、从 auth.js/next-auth 迁移规划以及认证流程测试等工具。README 中提及凭据加密、OAuth2、SAML、LDAP 与威胁检测等能力,但具体实现细节有限。

主要功能

  1. 01分析项目结构并给出认证配置建议
  2. 02配置 Better-Auth 认证提供方
  3. 03检测现有 auth.js/next-auth 实现
  4. 04生成迁移计划
  5. 05测试登录、注册、重置与 2FA 流程

适用场景

  1. 01将 next-auth 项目迁移到 Better-Auth
  2. 02检查认证流程与安全配置
  3. 03查看认证日志与监控认证事件

MCP 相关

该项目是一个 MCP 服务,向 MCP 客户端暴露分析、配置、测试与监控类工具,并提供 better-auth://config 和 better-auth://logs 两个资源。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"better-auth": {
"command": "npx",
"args": [
"-y",
"@smithery/cli"
]
}
}
}
启动命令npx -y @smithery/cli

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@smithery/cli

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

better-auth-mcp-server MCP 服务

smithery badge

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

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

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

Better Auth Server MCP server

功能

核心工具
  • analyze_project - 分析项目结构并提供身份验证设置建议
  • setup_better_auth - 使用项目 ID 和 API 密钥配置身份验证提供方
  • analyze_current_auth - 检测现有的 auth.js/next-auth 实现
  • generate_migration_plan - 创建分步迁移路径
测试与安全
  • test_auth_flows - 验证登录/注册/重置/2fa 流程
  • 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 Server:

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 服务通过 stdio 通信,调试可能颇具挑战。我们建议使用 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'
});

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。