home / mcp / better auth mcp server

Better Auth MCP Server

Enterprise-grade authentication management with AES-256 security, multi-protocol support, and real-time threat detection.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "nahmanmate-better-auth-mcp-server": {
      "command": "node",
      "args": [
        "/path/to/better-auth-mcp-server/build/index.js"
      ],
      "env": {
        "LOG_LEVEL": "info",
        "BETTER_AUTH_ENV": "production",
        "BETTER_AUTH_API_KEY": "YOUR_API_KEY",
        "BETTER_AUTH_PROJECT_ID": "YOUR_PROJECT_ID"
      }
    }
  }
}

This MCP Server provides enterprise-grade authentication management with secure credential handling, multi-protocol support, and real-time threat detection. It offers core tools to analyze, configure, migrate, and test authentication setups, with clear guidance for deploying and running the server alongside your applications.

How to use

You integrate Better Auth MCP Server with your client applications through an MCP client. Use the available tools to set up providers, analyze existing auth implementations, and create migration plans. You can run end-to-end tests of authentication flows and security checks, then monitor and review logs to keep your auth system healthy. If you need to adjust settings or review current configuration, you can consult the Better Auth configuration and logs endpoints exposed by the server.

How to install

Prerequisites: ensure you have Node.js and npm installed on your system.

git clone https://github.com/better-auth-mcp-server/better-auth-mcp-server.git
cd better-auth-mcp-server
npm install

Build the server to produce the runnable assets.

npm run build

For development with automatic rebuilds, start the watch mode.

npm run watch

To install Better Auth MCP Server for Claude Desktop automatically via Smithery, run this command.

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

Add the MCP server configuration to Claude Desktop on macOS or Windows as shown below.

{
  "mcpServers": {
    "better_auth_mcp_server": {
      "command": "node",
      "args": ["/path/to/better-auth-mcp-server/build/index.js"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

Additional sections

Configuration and security considerations help you run a robust, secure authentication system. Set environment variables to control how the MCP server authenticates and operates, implement access control and monitoring, and follow best practices for key management and auditing.

Environment variables shown in the source include the following, which you should set in your deployment environment.

# 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

Security best practices include managing API keys securely, rotating keys regularly, applying IP allowlists, enforcing least privilege, enabling audit logging, and setting up alerts for suspicious activity. Regularly review and monitor authentication failures and system logs to detect anomalies early.

Key operational notes for deploying and testing the MCP server include using the provided tools to analyze your project, set up authentication providers, test flows, and monitor security. The server exposes logs and configuration data through dedicated endpoints to help you observe behavior and troubleshoot issues effectively.

Available tools

analyze_project

Analyze project structure to identify where authentication should be configured and provide recommendations for integrating Better Auth.

setup_better_auth

Configure authentication providers for your project using project ID and API key, wiring them into your app.

analyze_current_auth

Detect existing authentication implementations (auth.js, next-auth) within your project to plan migration or integration steps.

generate_migration_plan

Create a step-by-step migration plan to move from existing auth solutions to Better Auth.

test_auth_flows

Run end-to-end tests for login, registration, password reset, and two-factor flows to ensure correctness.

test_security

Execute OWASP-aligned security checks to identify and fix potential weaknesses in the authentication stack.

analyze_logs

Review authentication system logs for issues, anomalies, and usage patterns.

monitor_auth_flows

Provide real-time monitoring of authentication events to detect and respond to threats.