Skip to main content
Glama
HenkDz

Self-Hosted Supabase MCP Server

list_auth_users

Retrieve user accounts from Supabase authentication tables to manage access permissions and monitor active sessions.

Instructions

Lists users from the auth.users table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax number of users to return
offsetNoNumber of users to skip

Implementation Reference

  • The execute function that performs a paginated SQL query on the auth.users table using direct PostgreSQL connection, validates the response with Zod schema, and returns the list of auth users.
    execute: async (input: ListAuthUsersInput, context: ToolContext): Promise<ListAuthUsersOutput> => {
        const client = context.selfhostedClient;
        const { limit, offset } = input;
    
        // Check if direct DB connection is available, as it's likely needed for auth.users
        if (!client.isPgAvailable()) {
            context.log('Direct database connection (DATABASE_URL) is required to list auth users.', 'error');
            throw new Error('Direct database connection (DATABASE_URL) is required to list auth users.');
        }
    
        // Construct SQL query - ensure schema name is correct
        const listUsersSql = `
            SELECT
                id,
                email,
                role,
                raw_app_meta_data,
                raw_user_meta_data,
                created_at::text, -- Cast timestamp to text for JSON
                last_sign_in_at::text -- Cast timestamp to text for JSON
            FROM
                auth.users
            ORDER BY
                created_at DESC
            LIMIT ${limit}
            OFFSET ${offset}
        `; // No semicolon needed here
    
        console.error('Attempting to list auth users using direct DB connection...');
        // Use direct connection (executeSqlWithPg) as it likely has necessary privileges
        const result = await client.executeSqlWithPg(listUsersSql);
    
        // Validate and return
        const validatedUsers = handleSqlResponse(result, ListAuthUsersOutputSchema);
    
        console.error(`Found ${validatedUsers.length} users.`);
        context.log(`Found ${validatedUsers.length} users.`);
        return validatedUsers;
    },
  • Zod schemas for input (limit/offset pagination) and output (array of AuthUser objects with fields like id, email, role, metadata, timestamps). Includes type inferences.
    const ListAuthUsersInputSchema = z.object({
        limit: z.number().int().positive().optional().default(50).describe('Max number of users to return'),
        offset: z.number().int().nonnegative().optional().default(0).describe('Number of users to skip'),
        // Add filters later (e.g., by email pattern, role)
    });
    type ListAuthUsersInput = z.infer<typeof ListAuthUsersInputSchema>;
    
    // Output schema - Zod for validation
    const AuthUserZodSchema = z.object({
        id: z.string().uuid(),
        email: z.string().email().nullable(),
        role: z.string().nullable(),
        // Timestamps returned as text from DB might not strictly be ISO 8601 / Zod datetime compliant
        created_at: z.string().nullable(),
        last_sign_in_at: z.string().nullable(),
        raw_app_meta_data: z.record(z.unknown()).nullable(),
        raw_user_meta_data: z.record(z.unknown()).nullable(),
        // Add more fields as needed (e.g., email_confirmed_at, phone)
    });
    const ListAuthUsersOutputSchema = z.array(AuthUserZodSchema);
    // Use AuthUser[] for the output type hint
    type ListAuthUsersOutput = AuthUser[];
  • Static JSON schema for MCP tool capabilities, mirroring the Zod input schema.
    const mcpInputSchema = {
        type: 'object',
        properties: {
            limit: {
                type: 'number',
                description: 'Max number of users to return',
                default: 50,
            },
            offset: {
                type: 'number',
                description: 'Number of users to skip',
                default: 0,
            },
        },
        required: [],
    };
  • src/index.ts:113-113 (registration)
    Adds listAuthUsersTool to the availableTools registry object used by the MCP server.
    [listAuthUsersTool.name]: listAuthUsersTool as AppTool,
  • src/index.ts:24-24 (registration)
    Imports the listAuthUsersTool for registration in the MCP server.
    import { listAuthUsersTool } from './tools/list_auth_users.js';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action is a list operation, implying read-only behavior, but doesn't cover critical aspects like authentication requirements, rate limits, pagination details (beyond implied by limit/offset), or error conditions. This leaves significant gaps for a tool accessing user data.

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 a single, clear sentence with zero wasted words. It's front-loaded with the core purpose and efficiently conveys the essential information without unnecessary elaboration, making it highly concise and well-structured.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that lists users from an authentication table. It misses details like return format (e.g., array of user objects), error handling, security implications, or how it interacts with sibling tools. For a data-access tool with no structured support, this leaves the agent under-informed.

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 both parameters ('limit' and 'offset') well-documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as default behaviors or constraints, so it meets the baseline for high schema coverage without compensating value.

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

Purpose4/5

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

The description clearly states the action ('Lists') and resource ('users from the auth.users table'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'get_auth_user' (which likely retrieves a single user), but the plural 'users' implies a listing operation versus retrieval of a specific user.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_auth_user' for single-user retrieval or 'list_tables' for broader table listings, nor does it specify prerequisites such as authentication or database access.

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