Skip to main content
Glama
abushadab

Self-Hosted Supabase MCP Server

by abushadab

list_auth_users

Retrieve user data from the auth.users table in a self-hosted Supabase instance. Specify the number of users to return and skip for precise querying, enabling efficient user management and analysis.

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 the tool's core logic: extracts input parameters, checks for PG connection, constructs and executes SQL query on auth.users with LIMIT/OFFSET, validates response using Zod schema via handleSqlResponse, logs results, 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 defining the input (limit/offset pagination) and output structure (array of AuthUser objects with id, email, role, metadata, timestamps) for the list_auth_users tool. Includes type inferences and AuthUserZodSchema.
    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[];
  • src/index.ts:24-24 (registration)
    Import statement that brings the listAuthUsersTool into the main index file for registration in the MCP server.
    import { listAuthUsersTool } from './tools/list_auth_users.js';
  • src/index.ts:113-113 (registration)
    Registers the listAuthUsersTool in the availableTools object, which is used to populate MCP server capabilities and handle tool calls.
    [listAuthUsersTool.name]: listAuthUsersTool as AppTool,
Behavior2/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 states it's a list operation, implying read-only behavior, but doesn't cover critical aspects like authentication requirements, rate limits, error conditions, or the format of returned data. This leaves significant gaps for a tool that interacts with authentication 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 easy for an agent to parse quickly.

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 insufficient for a tool that lists authentication users. It doesn't explain what data is returned (e.g., user fields, pagination metadata), security implications, or error handling, which are critical for an agent to use this tool effectively in a real-world context.

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?

The schema description coverage is 100%, with both parameters ('limit' and 'offset') well-documented in the schema. The description doesn't add any parameter-specific information beyond what the schema provides, so it meets the baseline for adequate but not enhanced parameter semantics.

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 distinguishes itself from siblings like 'get_auth_user' (singular retrieval) and 'create_auth_user' (creation), though it doesn't explicitly mention pagination or filtering capabilities that might differentiate it further from other list tools.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention scenarios like bulk user retrieval, pagination needs, or comparisons with other list tools (e.g., 'list_tables'), leaving the agent to infer usage based on the name and schema alone.

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

Related 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/abushadab/selfhosted-supabase-mcp-basic-auth'

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