Skip to main content
Glama
abushadab

Self-Hosted Supabase MCP Server

by abushadab

list_migrations

Track and display applied database migrations from the supabase_migrations.schema_migrations table for self-hosted Supabase instances. Useful for managing and verifying database schema changes.

Instructions

Lists applied database migrations recorded in supabase_migrations.schema_migrations table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the tool logic: queries the database for applied migrations using a SQL statement and processes the response.
    execute: async (input: ListMigrationsInput, context: ToolContext) => {
        const client = context.selfhostedClient;
    
        // SQL to query the Supabase migrations table
        const listMigrationsSql = `
            SELECT
                version,
                name,
                inserted_at
            FROM
                supabase_migrations.schema_migrations
            ORDER BY
                version
        `;
    
        // This table might not exist if migrations haven't been run
        // The RPC call will handle the error, which handleSqlResponse will catch
        const result = await executeSqlWithFallback(client, listMigrationsSql, true);
    
        return handleSqlResponse(result, ListMigrationsOutputSchema);
    },
  • Zod schema defining the output structure: an array of migration objects containing version, name, and inserted_at.
    const ListMigrationsOutputSchema = z.array(z.object({
        version: z.string(),
        name: z.string(),
        inserted_at: z.string(), // Keep as string from DB
    }));
  • Zod schema for input (empty object since no parameters required) and inferred type.
    const ListMigrationsInputSchema = z.object({});
    type ListMigrationsInput = z.infer<typeof ListMigrationsInputSchema>;
  • The tool object definition including name, description, schemas, and execute handler, exported for use in the MCP server.
    export const listMigrationsTool = {
        name: 'list_migrations',
        description: 'Lists applied database migrations recorded in supabase_migrations.schema_migrations table.',
        inputSchema: ListMigrationsInputSchema,
        mcpInputSchema: mcpInputSchema,
        outputSchema: ListMigrationsOutputSchema,
        execute: async (input: ListMigrationsInput, context: ToolContext) => {
            const client = context.selfhostedClient;
    
            // SQL to query the Supabase migrations table
            const listMigrationsSql = `
                SELECT
                    version,
                    name,
                    inserted_at
                FROM
                    supabase_migrations.schema_migrations
                ORDER BY
                    version
            `;
    
            // This table might not exist if migrations haven't been run
            // The RPC call will handle the error, which handleSqlResponse will catch
            const result = await executeSqlWithFallback(client, listMigrationsSql, true);
    
            return handleSqlResponse(result, ListMigrationsOutputSchema);
        },
    }; 
  • src/index.ts:102-102 (registration)
    Registers the listMigrationsTool in the availableTools map used to populate MCP server capabilities.
    [listMigrationsTool.name]: listMigrationsTool as AppTool,

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
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. It only states the purpose but does not disclose read-only nature, authentication requirements, or any side effects.

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?

Single sentence, front-loaded, no extraneous information. Efficient and to the point.

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?

For a simple tool with no parameters and no output schema, the description is adequate. It could mention that it's a read-only operation or the format of results, but overall it's sufficient.

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?

There are zero parameters, so schema coverage is 100%. The description adds no parameter details, but per guidelines, baseline is 4 for 0 parameters.

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 action ('Lists') and the specific resource ('applied database migrations') and the source table, making it distinct from sibling tools like apply_migration.

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 on when to use this tool versus alternatives, such as apply_migration. The description does not provide context or exclusion criteria.

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