Skip to main content
Glama
HenkDz

Self-Hosted Supabase MCP Server

list_tables

Retrieve all database tables organized by schema to understand database structure and relationships in a self-hosted Supabase instance.

Instructions

Lists all accessible tables in the connected database, grouped by schema.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes a PostgreSQL query to list all accessible tables, excluding system and internal Supabase schemas, using utility functions for SQL execution and response handling.
    execute: async (input: ListTablesInput, context: ToolContext) => {
        const client = context.selfhostedClient;
    
        // SQL query to get tables from pg_catalog and information_schema
        // Excludes system schemas like pg_catalog, information_schema, and Supabase internal schemas
        const listTablesSql = `
            SELECT
                n.nspname as schema,
                c.relname as name,
                pgd.description as comment
            FROM
                pg_catalog.pg_class c
            JOIN
                pg_catalog.pg_namespace n ON n.oid = c.relnamespace
            LEFT JOIN
                pg_catalog.pg_description pgd ON pgd.objoid = c.oid AND pgd.objsubid = 0
            WHERE
                c.relkind = 'r' -- r = ordinary table
                AND n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast')
                AND n.nspname NOT LIKE 'pg_temp_%'
                AND n.nspname NOT LIKE 'pg_toast_temp_%'
                 -- Exclude Supabase internal schemas
                AND n.nspname NOT IN ('auth', 'storage', 'extensions', 'graphql', 'graphql_public', 'pgbouncer', 'realtime', 'supabase_functions', 'supabase_migrations', '_realtime')
                AND has_schema_privilege(n.oid, 'USAGE')
                AND has_table_privilege(c.oid, 'SELECT')
            ORDER BY
                n.nspname,
                c.relname
        `;
    
        const result = await executeSqlWithFallback(client, listTablesSql, true);
    
        return handleSqlResponse(result, ListTablesOutputSchema); // Use a helper to handle response/errors
    },
  • Zod schema defining the output structure: an array of objects containing schema name, table name, and optional comment.
    const ListTablesOutputSchema = z.array(z.object({
        schema: z.string(),
        name: z.string(),
        comment: z.string().nullable().optional(), // Add comment if available
    }));
  • Zod schema for input parameters, which is an empty object since no inputs are required for this tool.
    const ListTablesInputSchema = z.object({ // No specific input needed for listing tables
        // Optional: add schema filter later if needed
        // schema: z.string().optional().describe('Filter tables by schema name.'),
    });
  • src/index.ts:11-11 (registration)
    Import statement bringing the listTablesTool into the main index file.
    import { listTablesTool } from './tools/list_tables.js';
  • src/index.ts:100-100 (registration)
    Registration of the listTablesTool in the availableTools object, which is used to populate the MCP server's tool capabilities.
    [listTablesTool.name]: listTablesTool 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 mentions grouping by schema, which is helpful, but doesn't cover important aspects like pagination, rate limits, authentication requirements, error conditions, or what 'accessible' means in practice. For a tool with zero annotation coverage, this leaves significant gaps.

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, efficient sentence that gets straight to the point. Every word earns its place—'Lists' (action), 'all accessible tables' (scope), 'in the connected database' (context), and 'grouped by schema' (organizational detail). No wasted words or redundancy.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but has clear gaps. It explains what the tool does but doesn't provide enough behavioral context (like how results are structured or what 'accessible' entails). For a read-only listing tool, it meets minimum viability but could be more complete.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the lack of inputs. The description doesn't need to add parameter information, and it appropriately focuses on what the tool does rather than inputs. A baseline of 4 is appropriate for zero-parameter tools.

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 resource ('all accessible tables in the connected database'), and adds useful context about grouping by schema. It doesn't explicitly distinguish from siblings like 'list_extensions' or 'list_migrations', but the resource specificity makes the purpose clear.

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. The description doesn't mention prerequisites, timing considerations, or how it differs from other listing tools like 'list_extensions' or 'list_migrations' in the sibling set.

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