Skip to main content
Glama
mabeldata

PocketBase MCP Server

by mabeldata

apply_all_migrations

Apply all pending database migrations by providing an array of already applied migration filenames to determine which migrations remain to be executed.

Instructions

Apply all pending migrations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appliedMigrationsNoArray of already applied migration filenames.

Implementation Reference

  • The tool handler function for 'apply_all_migrations'. It extracts appliedMigrations from args, calls the core applyAllMigrations function, and returns a formatted result.
    async function handleApplyAllMigrations(args: ApplyAllMigrationsArgs, pb: PocketBase): Promise<ToolResult> {
        try {
            const appliedMigrations = args.appliedMigrations || [];
            const result = await applyAllMigrations(pb, appliedMigrations);
            
            if (result.length === 0) {
                return {
                    content: [{ type: 'text', text: 'No new migrations to apply.' }],
                };
            }
            
            return {
                content: [{ type: 'text', text: `Applied migrations:\n${result.join('\n')}` }],
            };
        } catch (error: any) {
            throw new Error(`Failed to apply migrations: ${error.message}`);
        }
    }
  • The intermediate handler that resolves the migrations directory and delegates to the execution layer.
    export async function applyAllMigrations(
        pb: PocketBase,
        appliedMigrations: string[] = [],
        customPath?: string
    ): Promise<string[]> {
        // If customPath is provided, set the migrations directory
        const migrationsDir = customPath 
            ? helpers.setMigrationsDirectory(customPath)
            : helpers.setMigrationsDirectory(); // Use current directory
        return execution.applyAllMigrations(pb, migrationsDir, appliedMigrations);
    }
  • The core execution logic: lists all migration files, filters out already-applied ones, and applies each pending migration sequentially.
    export async function applyAllMigrations(
        pb: PocketBase, 
        migrationsDir: string,
        appliedMigrations: string[] = []
    ): Promise<string[]> {
        try {
            // Get all migration files
            const allMigrations = await listMigrationFiles();
            
            // Filter out already applied migrations
            const pendingMigrations = allMigrations.filter(
                migration => !appliedMigrations.includes(migration)
            );
            
            if (pendingMigrations.length === 0) {
                return [];
            }
            
            const newlyApplied: string[] = [];
            
            // Apply each pending migration
            for (const migration of pendingMigrations) {
                await applyMigration(migration, pb, migrationsDir);
                newlyApplied.push(migration);
            }
            
            return newlyApplied;
        } catch (error: any) {
            console.error('Error applying all migrations:', error);
            throw new Error(`Failed to apply all migrations: ${error.message}`);
        }
    }
  • TypeScript interface for the apply_all_migrations arguments, with an optional appliedMigrations array of strings.
    interface ApplyAllMigrationsArgs {
        appliedMigrations?: string[];
    }
  • Tool registration metadata: name 'apply_all_migrations', description 'Apply all pending migrations.', and input schema with optional appliedMigrations array.
    {
        name: 'apply_all_migrations',
        description: 'Apply all pending migrations.',
        inputSchema: {
            type: 'object',
            properties: {
                appliedMigrations: { 
                    type: 'array', 
                    items: { type: 'string' },
                    description: 'Array of already applied migration filenames.' 
                },
            },
        },
    },
Behavior2/5

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

Without annotations, the description must disclose behavioral traits, but it only states 'apply all pending migrations'. It does not mention if the tool is destructive (modifying database), reversible, or requires confirmation. The purpose of the 'appliedMigrations' parameter is unclear from the description alone.

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, short sentence with no fluff, appropriate for a simple tool. It is acceptably concise, though could benefit from slight expansion for clarity.

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 output schema and annotations, and the tool's potential impact on the database, the description is too minimal. It omits return values, side effects, safety warnings, and best practices for usage, making it insufficient for an AI agent to use safely.

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 input schema has 100% coverage for the single parameter, so the schema already describes it. The description adds no extra meaning beyond what the schema provides, hence baseline 3.

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 'Apply all pending migrations' clearly states the action (apply) and the resource (all pending migrations). The name itself distinguishes it from sibling 'apply_migration', which applies a single migration.

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

Usage Guidelines3/5

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

The description implies usage when there are pending migrations, but it provides no guidance on when not to use this tool, prerequisites, or alternatives such as listing pending migrations first with list_migrations or applying individually with apply_migration.

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/mabeldata/pocketbase-mcp'

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