Skip to main content
Glama
Perufitlife

supabase-security-mcp

by Perufitlife

apply_all_fixes

Apply all fixes from the last security audit in a single transaction, rolling back on any failure. Optionally filter by minimum severity and preview before confirming.

Instructions

Bulk-apply all SQL fixes from last audit, optionally filtered by severity. Wraps everything in a single transaction — if any statement fails, everything rolls back. Always preview the count and list before confirming.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_refYes
severity_minNoMinimum severity to apply (default 'high'). Use 'critical' for safest.high
confirmYesMust be true to actually apply.

Implementation Reference

  • src/server.js:169-178 (registration)
    Registration of the 'apply_all_fixes' tool as an MCP tool via server.registerTool(). The tool is called 'apply_all_fixes' and accepts three parameters: project_ref (string), severity_min (enum with default 'high'), and confirm (boolean).
    server.registerTool(
      "apply_all_fixes",
      {
        description: "Bulk-apply all SQL fixes from last audit, optionally filtered by severity. Wraps everything in a single transaction — if any statement fails, everything rolls back. Always preview the count and list before confirming.",
        inputSchema: {
          project_ref: z.string(),
          severity_min: z.enum(["critical", "high", "medium", "low", "info"]).default("high").describe("Minimum severity to apply (default 'high'). Use 'critical' for safest."),
          confirm: z.boolean().describe("Must be true to actually apply."),
        },
      },
  • Input schema (Zod) for apply_all_fixes: project_ref (string), severity_min (enum with default 'high'), confirm (boolean).
      description: "Bulk-apply all SQL fixes from last audit, optionally filtered by severity. Wraps everything in a single transaction — if any statement fails, everything rolls back. Always preview the count and list before confirming.",
      inputSchema: {
        project_ref: z.string(),
        severity_min: z.enum(["critical", "high", "medium", "low", "info"]).default("high").describe("Minimum severity to apply (default 'high'). Use 'critical' for safest."),
        confirm: z.boolean().describe("Must be true to actually apply."),
      },
    },
  • Handler function for apply_all_fixes. Retrieves cached audit results, filters findings by severity_min (excluding Dashboard-only fixes without SQL), and if confirm=true, runs all eligible fix SQLs in a single BEGIN/COMMIT transaction. On failure, the transaction is rolled back. After success, re-audits the project and updates the cache.
      async ({ project_ref, severity_min, confirm }) => {
        const c = cache.get(project_ref);
        if (!c) return { content: [{ type: "text", text: `No cached audit. Run audit_project first.` }], isError: true };
    
        const order = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
        const minLevel = order[severity_min];
        const eligible = c.result.findings.filter(
          (f) => order[f.severity] <= minLevel &&
            f.fix_sql.split("\n").some((l) => l.trim() && !l.trim().startsWith("--"))
        );
    
        if (eligible.length === 0) {
          return { content: [{ type: "text", text: `No SQL-applicable findings at severity ${severity_min} or higher.` }] };
        }
    
        if (!confirm) {
          return {
            content: [
              { type: "text", text: `${eligible.length} fix(es) eligible at severity >= ${severity_min}. Set confirm=true to apply.` },
              { type: "text", text: eligible.map((f, i) => `${i + 1}. [${f.severity.toUpperCase()}] ${f.title} — ${f.target}`).join("\n") },
            ],
          };
        }
    
        const allSql = eligible.map((f) => `-- ${f.title} (${f.target})\n${f.fix_sql}`).join("\n\n");
        try {
          await sql(c.token, project_ref, `BEGIN;\n${allSql}\nCOMMIT;`);
          const fresh = await audit(c.token, project_ref);
          cache.set(project_ref, { result: fresh, ts: Date.now(), token: c.token });
          return {
            content: [
              { type: "text", text: `Applied ${eligible.length} fix(es) in one transaction. New summary: ${shortSummary(fresh)}` },
            ],
          };
        } catch (e) {
          return { content: [{ type: "text", text: `Bulk apply FAILED: ${e.message}\n\nTransaction rolled back. Project state unchanged.` }], isError: true };
        }
      }
    );
Behavior4/5

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

The description discloses the transactional behavior (wraps in single transaction, rolls back on failure) beyond the absent annotations. This is key behavioral information, though permissions or side effects are not mentioned.

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?

Three sentences efficiently convey purpose, transaction behavior, and usage advice with no 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?

The description covers the core operation and advice but omits return value details (no output schema) and does not reference sibling tools like 'list_findings' or 'preview_fix' for previewing, which is part of the workflow.

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 67% with descriptions for severity_min and confirm. The description adds context for severity filtering ('optionally filtered by severity'), but the 'project_ref' param lacks explanation, and the description does not fully compensate for schema gaps.

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 uses a specific verb 'bulk-apply' and resource 'all SQL fixes', clearly distinguishing from sibling 'apply_fix' for individual fixes.

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

Usage Guidelines4/5

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

It advises to 'Always preview the count and list before confirming', providing a clear usage guideline. However, it does not explicitly state when to use this tool versus alternatives like 'apply_fix'.

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/Perufitlife/supabase-security-mcp'

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