Skip to main content
Glama
larik15

supabase-security-mcp

by larik15

supabase-security-mcp

test npm

An MCP server that lets Claude, Cursor, or any MCP client audit a Supabase project's security — the parts the dashboard's Security Advisor doesn't cover.

Ask your assistant "is my Supabase project safe to ship?" and it can actually check:

Tool

What it does

Needs

probe_anon

What a stranger can read with only the public anon key: tables, storage buckets, RPCs

anon key

audit_policies

Reads pg_policies / pg_class / pg_proc: RLS off on exposed tables, using (true) / with check (true), policies with no TO clause (they apply to PUBLIC), SECURITY DEFINER functions callable by anon/authenticated

database URL

two_account_test

Creates two throwaway users, inserts a row as A, tries to read / update / delete it as B and as anon through the real REST API, then cleans up. The cross-tenant check most people never run

service role key (setup/cleanup only)

security_report

All of the above as one Markdown report sorted by severity

any of the above

Everything is read-only except two_account_test, which inserts and deletes its own test rows and users. Nothing is stored. The service role key is used only to create and delete the two test users.

Why

In Lovable / Bolt + Supabase apps the pattern repeats: RLS "on", Advisor green, and a table still readable by anyone — because the policy is using (true), or has no TO clause and silently applies to anon, or a SECURITY DEFINER function bypasses RLS. Advisor reports whether RLS is enabled. It doesn't say whether a policy is effectively public, and it can't tell you that user B can delete user A's rows. These tools do.

Related MCP server: supabase-security-mcp

Setup

Claude Desktop — claude_desktop_config.json:

{
  "mcpServers": {
    "supabase-security": {
      "command": "npx",
      "args": ["-y", "supabase-security-mcp"],
      "env": {
        "SUPABASE_URL": "https://YOURREF.supabase.co",
        "SUPABASE_ANON_KEY": "eyJ...",
        "DATABASE_URL": "postgresql://postgres.YOURREF:PASSWORD@aws-0-eu-central-1.pooler.supabase.com:6543/postgres",
        "SUPABASE_SERVICE_ROLE_KEY": "eyJ..."
      }
    }
  }
}

Claude Code:

claude mcp add supabase-security -e SUPABASE_URL=... -e SUPABASE_ANON_KEY=... -- npx -y supabase-security-mcp

Cursor — .cursor/mcp.json with the same command / args / env shape.

All env vars are optional — every tool also accepts the same values as arguments, so the assistant can pass them per call. DATABASE_URL and SUPABASE_SERVICE_ROLE_KEY are only needed for audit_policies and two_account_test respectively.

Find the values in Supabase → Project Settings → API (URL, anon, service_role) and Project Settings → Database (connection string; use the pooler URL).

Example: a real run

Against a test project with two tables — leads_open written the way a rushed Lovable app usually is (using (true) reads, "Service role full access" policies with no TO clause), and leads_fixed with proper auth.uid() = user_id policies:

# Supabase security report
Project: `https://caalmxsprputqeqwotdx.supabase.co`

## Anonymous access (anon key only)
- **OPEN** `table` **leads_open** — returned rows; columns: id, user_id, name, email, deal_value, created_at
- closed `table` **leads_fixed** — 200 OK but no rows (empty table, or RLS returns nothing)

## Two-account test (user B vs user A's rows)
- **leads_open** — owner insert: 201 · other-user select: 200 (1 rows) · anon select: 200 (1 rows) · other-user update: 200 (1 rows) · other-user delete: 200 (1 rows) → **LEAK: other_user_can_read, anon_can_read, other_user_can_update, other_user_can_delete**
- **leads_fixed** — owner insert: 201 · other-user select: 200 (0 rows) · anon select: 200 (0 rows) · other-user update: 200 (0 rows) · other-user delete: 200 (0 rows) → ok

## Findings (5) — critical 2, high 3, medium 0, info 0
- **[critical]** On public.leads_open, another logged-in user can update a row owned by someone else.
  - fix: Update policy must use (user_id = auth.uid()) and with check (user_id = auth.uid()).
- **[critical]** On public.leads_open, another logged-in user can delete a row owned by someone else.
  - fix: Delete policy must use (user_id = auth.uid()).
- **[high]** table leads_open returns data to an anonymous request.
  - fix: Fix the select policy to check ownership.
- **[high]** On public.leads_open, another logged-in user can read a row owned by someone else.
  - fix: Select policy must use (user_id = auth.uid()).
- **[high]** On public.leads_open, an anonymous visitor can read a row owned by someone else.
  - fix: Select policy must use (user_id = auth.uid()).

Both tables show 200 on the cross-user calls — PostgREST answers 200 either way. The difference is the row count: RLS that works returns zero rows, not an error. That's exactly why "the request succeeded" tells you nothing and this test exists.

Run it from a terminal without an MCP client:

SUPABASE_URL=... SUPABASE_ANON_KEY=... SUPABASE_SERVICE_ROLE_KEY=... \
node scripts/demo.mjs --tables leads_open,leads_fixed \
  --two leads_open:user_id,leads_fixed:user_id \
  --sample '{"name":"probe","email":"probe@example.test","deal_value":1}'

Two-account test notes

  • Give sampleRow with values for any NOT NULL columns without defaults.

  • ownerColumn defaults to user_id, idColumn to id.

  • If the owner's own insert is blocked (403), the tool reports that and skips the table — that can be intended (server-only writes) or a policy bug; you decide.

  • Test users are rlscheck-a-*@example.com / rlscheck-b-*@example.com and are deleted at the end.

Development

npm install
npm test        # node:test, no network: fake fetch + fake Postgres rows

Related: supabase-anon-probe — the anon-key probe as a standalone CLI (same core).

License

MIT

Available Tools

4 tools
audit_policiesAudit RLS policies in PostgresA

Connects to the database (read-only queries on pg_class, pg_policies, pg_proc, information_schema) and flags: tables with RLS off but granted to anon/authenticated, policies with using(true) / with check(true), policies without a TO clause (apply to PUBLIC), and SECURITY DEFINER functions executable by anon/authenticated. Needs a Postgres connection string.

ParametersJSON Schema
NameRequiredDescriptionDefault
databaseUrlNopostgres://... connection string (Supabase → Project Settings → Database). Or env DATABASE_URL

TDQS

A3.8/5.0
Behavior4/5

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

The description discloses that the tool performs read-only queries on system catalogs, which is a significant behavioral trait. It also lists the exact security checks it performs. However, it does not describe the output format or any error handling, and since there are no annotations, it carries the full transparency burden. It is mostly transparent but lacks output details.

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 two sentences long, with the first sentence front-loading the core functionality and the list of checks. The second sentence states the prerequisite. Every word is purposeful, and there is no redundancy or fluff.

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?

The description covers the tool's purpose, the specific checks, and the connection requirement. However, it does not specify the format of the audit results (e.g., list, report, JSON) or any potential limitations (e.g., requires table-level permissions). Since there is no output schema, the description should address the return value, but it is still fairly complete for a read-only audit tool.

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 already fully documents the databaseUrl parameter, including how to obtain it and the environment variable fallback. The description adds only a redundant statement about needing a connection string, providing no additional semantic value beyond the schema. Given 100% schema coverage, the baseline of 3 is appropriate.

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 explicitly states the tool's purpose: auditing RLS policies in Postgres. It details the specific checks performed (RLS off but granted, using(true)/with check(true), missing TO clause, SECURITY DEFINER functions) and the read-only nature. This is a specific verb+resource and clearly distinguishes it from generic database tools.

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?

The description provides no guidance on when to use this tool versus siblings like probe_anon or security_report. It does not mention alternative tools or conditions under which this audit is appropriate. The only hint is the prerequisite of a Postgres connection string, which is a requirement, not a usage guideline.

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

probe_anonProbe with anon keyA

Read-only. Uses ONLY the public anon key to check what a stranger can read: tables via REST (select * limit 1), storage buckets (list), and RPC functions (call with {}). Returns OPEN/closed per target. Never writes.

ParametersJSON Schema
NameRequiredDescriptionDefault
rpcNonames, e.g. ["profiles","orders"]
urlNoProject URL, e.g. https://ref.supabase.co (or env SUPABASE_URL)
tablesNonames, e.g. ["profiles","orders"]
anonKeyNoanon/public key (or env SUPABASE_ANON_KEY)
bucketsNonames, e.g. ["profiles","orders"]

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries full responsibility. It clearly discloses that the tool is read-only, uses only the anon key, never writes, and returns OPEN/closed per target. It also explains the specific methods (select * limit 1, list, call with {}) which is transparent about behavior. Missing details like error handling or rate limits are minor for a read-only probe.

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 two sentences with zero waste. It front-loads the most important facts: read-only and uses only the anon key. The second sentence details the targets and return format. Every word earns its place, and it is well-structured for quick agent comprehension.

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?

The description covers the essential information an agent needs: what the tool does, how it operates, and what it returns (OPEN/closed per target). It does not have an output schema, but the return format is described. The parameters are covered by schema and description, including env fallbacks. It is complete for a read-only probe, though it could mention how to handle missing credentials or errors, which is a minor gap.

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 schema descriptions are minimal (names and examples), but the description adds semantic value by explaining how each target type is probed: tables via REST select, buckets via list, RPC via call with {}. This goes beyond the schema. The description does not explicitly map parameters to these behaviors, but the connection is clear from the context. Since schema coverage is 100%, the baseline is 3, and this earns a 4 for added meaning.

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 tool's purpose: probe what a stranger can read using the anon key, covering tables, storage buckets, and RPC functions. It uses specific verbs (probe, check, read) and names the resource (anonymous access). It distinguishes from siblings by focusing on anonymous read access, which is distinct from audit_policies, two_account_test, and security_report.

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 when to use it (to check anonymous access) and explicitly notes it is read-only and never writes. However, it does not name alternative tools or provide explicit when-not-to-use guidance. Given the sibling tools are security-related, there is an implicit context, but no direct comparison or exclusion.

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

security_reportFull report (all checks)B

Runs probe_anon, audit_policies (if a database URL is available) and two_account_test (if a service role key and tables are given), then returns one Markdown report sorted by severity.

ParametersJSON Schema
NameRequiredDescriptionDefault
rpcNonames, e.g. ["profiles","orders"]
urlNo
tablesNotables to probe with anon key
anonKeyNo
bucketsNonames, e.g. ["profiles","orders"]
databaseUrlNo
serviceRoleKeyNo
twoAccountTablesNo

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations provided, the description carries the full behavioral burden. It transparently reveals the tool is a composite that conditionally runs other checks and returns a single Markdown report. However, it does not disclose whether these probes have side effects, require network access, or how failures of individual sub-checks are handled.

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?

One dense sentence conveys the composition, conditions, and output format without filler. The phrase about the Markdown report is useful and front-loaded enough, though the multiple conditionals make it slightly heavy.

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?

This is a high-complexity tool with 8 parameters, 0 required parameters, and no output schema. The description explains the overall flow but leaves major input fields undocumented, does not say what happens when no arguments are supplied, and only vaguely describes the report contents.

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

Parameters2/5

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

Schema description coverage is only 38%, so the description must compensate, but it only loosely maps databaseUrl, serviceRoleKey, and tables/twoAccountTables. Parameters such as rpc, url, anonKey, and buckets are never explained, and the description's 'tables' wording is ambiguous against the schema's separate 'tables' and 'twoAccountTables' fields.

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?

States a specific verb and resource: it runs probe_anon, audit_policies, and two_account_test, then returns one Markdown report sorted by severity. This clearly distinguishes it from the sibling tools, which are the individual checks it aggregates.

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 gives conditional guidance for when sub-checks run (audit_policies only if a database URL is available; two_account_test only if a service role key and tables are given). However, it does not explicitly say when to choose this aggregate tool over running the individual sibling tools, leaving the main usage decision implied rather than stated.

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

two_account_testTwo-account cross-tenant testA

Creates two temporary users (needs the service role key ONLY for that and for cleanup), inserts a row as user A into each table, then tries to read/update/delete it as user B and as anon through the normal REST API. Reports which tables leak across users. Deletes the test rows and users afterwards. Give sampleRow for tables with required columns.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlNo
tablesYes
anonKeyNo
serviceRoleKeyNoservice_role key (or env SUPABASE_SERVICE_ROLE_KEY). Used only to create/delete the two test users and clean up rows.

TDQS

A3.6/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does exceptionally well: it discloses that the tool creates temporary users, inserts rows, attempts operations as different roles, reports leaks, and cleans up after itself. This transparency about side effects and cleanup is exemplary.

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 compact and front-loaded with the main action, followed by cleanup and an instructional note. It is slightly repetitive about the service role key, but each sentence earns its place.

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 thoroughly explains the process and cleanup, but with no output schema it leaves the report format vague ('Reports which tables leak'). It also omits failure behavior, so an agent has to guess the return structure.

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

Parameters2/5

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

Schema description coverage is only 25%, and the description adds little beyond it. It mentions sampleRow and the serviceRoleKey usage, but both are already described in the schema; url, anonKey, and the tables structure remain unexplained at the top level, leaving the low coverage uncompensated.

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 a specific verb chain (create users, insert row, test read/update/delete, report leaks) and a specific resource (tables). It does not explicitly compare with sibling tools like probe_anon or security_report, so it stops short of full differentiation.

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 when to use the tool (to test cross-tenant leaks) and gives practical tips (sampleRow for required columns, service role key only for setup/cleanup). However, it does not explicitly mention alternatives or when not to use this tool, leaving some inference required.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedaudit_policies
    • First observedprobe_anon
    • First observedsecurity_report
    • First observedtwo_account_test

TDQS

A3.7/5.0

Scored across 4 tools

Disambiguation4/5

The probes are differentiated: `probe_anon` is black-box REST exposure, `audit_policies` inspects database catalogs, `two_account_test` verifies cross-user isolation, and `security_report` orchestrates. There is some conceptual overlap between `probe_anon` and `audit_policies` around anon/RLS exposure, so an agent might briefly hesitate, but no tool duplicates another.

Naming Consistency3/5

`probe_anon` and `audit_policies` follow a verb_noun command style, while `two_account_test` and `security_report` are noun-style names. They are all readable snake_case, but the action-first convention is not applied consistently across the set.

Tool Count5/5

Four tools is appropriate for a focused Supabase security-audit server: three distinct probes plus one report aggregator. Each tool has a clear job, and none feels redundant or missing.

Completeness4/5

The set covers anon REST exposure, RLS policy misconfigurations, SECURITY DEFINER functions, and cross-user table isolation, which are the core Supabase data-security risks. Minor gaps remain, such as no dynamic storage-object cross-account test and no anonymous INSERT probe, but static policy checks partially compensate.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    Enables security auditing, penetration testing, and compliance validation with tools like Semgrep, Trivy, Gitleaks, and OWASP ZAP. Features strict project boundary enforcement and supports OWASP, CIS, and NIST compliance frameworks.
    7
    -
  • A
    license
    A
    quality
    C
    maintenance
    MCP server that lets AI coding agents (Claude Code, Cursor, Cline) audit Supabase projects for security misconfigurations AND apply the fixes — without leaving the agent. Tools: audit_project, list_findings, preview_fix (BEGIN/ROLLBACK safety), apply_fix (with confirmation), apply_all_fixes (transactional bulk). Closes the audit-fix loop entirely in the agent — other Supabase scanners only report.
    5
    2 npm
    1
    MIT
  • F
    license
    A
    quality
    C
    maintenance
    Audits PostgreSQL/Supabase schemas for security issues like missing RLS, permissive policies, and sensitive data exposure during AI conversations.
    3
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables authorized security auditing of AI-agent supply chains and agent-facing surfaces: deterministic local skill-bundle audits against eight attack patterns, secrets scanning, and scope-gated read-only recon of agent endpoints and MCP surfaces.
    MIT