Skip to main content
Glama
HenkDz

Self-Hosted Supabase MCP Server

delete_auth_user

Remove a user from Supabase authentication by their UUID. This tool deletes user accounts from the auth.users table using a service role key and direct database connection.

Instructions

Deletes a user from auth.users by their ID. Requires service_role key and direct DB connection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYesThe UUID of the user to delete.

Implementation Reference

  • The main handler function for the delete_auth_user tool. It checks for direct PG connection availability, executes a DELETE query on auth.users table using a transaction, and returns success/failure based on rowCount.
    execute: async (input: DeleteAuthUserInput, context: ToolContext) => {
        const client = context.selfhostedClient;
        const { user_id } = input;
    
        // This operation requires elevated privileges and modifies data.
        // Prefer direct DB connection if available and service key is configured.
        if (!client.isPgAvailable()) {
            throw new Error('Direct database connection (DATABASE_URL) is required for deleting users but is not configured or available.');
        }
        // Service role key check remains relevant for awareness, but remove console.warn
        // if (!client.getServiceRoleKey()) {
        //      console.warn('Service role key not explicitly configured, direct DB connection might fail if privileges are insufficient.');
        // }
    
        try {
            // Use executeTransactionWithPg for safety, though it's a single statement
            const result = await client.executeTransactionWithPg(async (pgClient) => {
                // Use parameter binding for safety
                const deleteResult = await pgClient.query(
                    'DELETE FROM auth.users WHERE id = $1',
                    [user_id]
                );
                return deleteResult;
            });
    
            if (result.rowCount === 1) {
                return {
                    success: true,
                    message: `Successfully deleted user with ID: ${user_id}`,
                };
            }
            // If rowCount was not 1, the user wasn't found/deleted
            return {
                success: false,
                message: `User with ID ${user_id} not found or could not be deleted.`,
            };
    
        } catch (error: unknown) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            console.error(`Error deleting user ${user_id}:`, errorMessage);
            // Rethrow for the main handler to format the error response
            throw new Error(`Failed to delete user ${user_id}: ${errorMessage}`); 
        }
    },
  • Zod schemas for input (user_id UUID) and output (success boolean, message string) of the delete_auth_user tool.
    const DeleteAuthUserInputSchema = z.object({
        user_id: z.string().uuid().describe('The UUID of the user to delete.'),
    });
    type DeleteAuthUserInput = z.infer<typeof DeleteAuthUserInputSchema>;
    
    // Output schema: Success status and message
    const DeleteAuthUserOutputSchema = z.object({
        success: z.boolean(),
        message: z.string(),
    });
  • Static JSON schema for MCP input capabilities of the delete_auth_user tool.
    const mcpInputSchema = {
        type: 'object',
        properties: {
            user_id: {
                type: 'string',
                format: 'uuid',
                description: 'The UUID of the user to delete.',
            },
        },
        required: ['user_id'],
    };
  • src/index.ts:26-26 (registration)
    Import of the deleteAuthUserTool.
    import { deleteAuthUserTool } from './tools/delete_auth_user.js';
  • src/index.ts:115-115 (registration)
    Registration of deleteAuthUserTool in the availableTools object used by the MCP server.
    [deleteAuthUserTool.name]: deleteAuthUserTool as AppTool,
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates that this is a destructive operation ('Deletes'), specifies authentication requirements ('Requires service_role key'), and indicates infrastructure needs ('direct DB connection'). It does not mention potential side effects (e.g., cascading deletions) or response format, but covers critical safety and access aspects adequately for a tool with no annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with zero wasted words: the first states the core action and target, and the second specifies prerequisites. It is front-loaded with the primary purpose and efficiently conveys essential information without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (destructive operation with authentication requirements), no annotations, and no output schema, the description does well by covering purpose, prerequisites, and behavioral traits. It lacks details on return values or error handling, but for a single-parameter tool with high schema coverage, it provides sufficient context for safe invocation, though not fully exhaustive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'user_id' fully documented in the schema as a UUID. The description adds no additional parameter semantics beyond implying the ID is used for deletion, which is already clear from the schema. This meets the baseline score of 3 when the schema provides complete parameter information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Deletes'), target resource ('a user from auth.users'), and identifier mechanism ('by their ID'), distinguishing it from sibling tools like update_auth_user or list_auth_users. It provides a precise verb+resource combination that leaves no ambiguity about its function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states prerequisites ('Requires service_role key and direct DB connection'), which helps determine when this tool can be used. However, it does not specify when to use it versus alternatives (e.g., update_auth_user for deactivation vs. deletion) or provide exclusions, limiting its guidance to context setup rather than comparative decision-making.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HenkDz/selfhosted-supabase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server