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,

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description should disclose behavioral traits. It only states a read operation ('Lists users'), but omits details like pagination behavior, authentication requirements, or side effects. The minimal description does not compensate for missing annotations.

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

Conciseness4/5

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

The description is a single concise sentence with no wasted words. While it is extremely brief, it is still efficient; however, it could be more informative without sacrificing conciseness.

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?

The description lacks completeness for a listing tool with no output schema. It does not explain the return format (e.g., array of user objects) or mention pagination behavior beyond parameter defaults. Given the tool's relative simplicity and the 100% schema coverage, more contextual details are needed.

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 coverage is 100% with descriptions for both parameters (limit, offset). The tool description adds no additional meaning beyond what the schema already provides, resulting in a baseline score of 3.

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 verb 'Lists' and the resource 'users from the auth.users table', making the tool's purpose unambiguous. It distinguishes itself from sibling tools like get_auth_user (single user) and create_auth_user (creation), but does not explicitly highlight this distinction.

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 such as get_auth_user or search-like tools. The description lacks context for selecting this tool over siblings.

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