MCP.so
Sign In
Back to blog

How to Add Supabase MCP to Claude Code: Setup Guide

Oct 15, 2026MCP.so TeamMCP.so Team

How to add Supabase MCP to Claude Code: one claude mcp add command, OAuth login via /mcp, then scope to one project, go read-only and pick features.

The Short Answer

To add Supabase MCP to Claude Code, run claude mcp add --scope project --transport http supabase "https://mcp.supabase.com/mcp", start claude in a regular terminal, type /mcp, select supabase, choose Authenticate and log in to Supabase in the browser. Pick the organization that holds your project, and Claude can list tables, run SQL, apply migrations and read logs.

That is Supabase's official hosted server from supabase-community/supabase-mcp, listed on mcp.so as Supabase MCP. Before you rely on it, spend two minutes on the safety options below: scoping it to one project and turning on read-only mode are both just URL parameters.

What You Need

  • Claude Code, installed and signed in.
  • A Supabase account with at least one project. A development project is the right place to start.
  • A browser for the OAuth login. No API key is needed for interactive use.

There is nothing to install locally. The server is a remote Streamable HTTP endpoint, so Claude Code connects directly to https://mcp.supabase.com/mcp.

Step 1: Add the Server

The command from the Supabase MCP docs:

claude mcp add --scope project --transport http supabase "https://mcp.supabase.com/mcp"

Supabase uses --scope project, which writes the server to .mcp.json in your repo root:

{
  "mcpServers": {
    "supabase": {
      "type": "http",
      "url": "https://mcp.supabase.com/mcp"
    }
  }
}

That file holds no secrets, because each developer signs in with their own Supabase account, so it is safe to commit. Other scopes work too:

ScopeFlagUse when
project--scope projectThe repo is tied to one Supabase project and the team should share the config
localno flagTrying it out, or you do not want to touch .mcp.json
user--scope userYou want Supabase available in every project (less common, since each app has its own database)

For how scopes, precedence and approvals work in general, see the Claude Code MCP guide.

Step 2: Log In With OAuth

  1. Start claude in a regular terminal. Supabase's docs specifically say to authenticate from a terminal, not the IDE extension.
  2. Type /mcp.
  3. Select supabase, then Authenticate.
  4. Log in to Supabase in the browser and choose the organization that contains the project you want Claude to work on.
  5. Back in Claude Code, /mcp shows supabase as connected.

Claude Code stores and refreshes the token. If you are curious how the flow works under the hood, read MCP authentication and OAuth.

Step 3: Scope It to One Project and Make It Read-Only

The plain URL gives Claude access to every project in the organization you chose, with write access. Supabase's own security guidance recommends narrowing that. All of it is done with query parameters on the URL:

ParameterEffect
project_ref=your-project-refLimits the server to one project and disables account-level tools
read_only=trueRuns every query as a read-only Postgres user
features=database,docsEnables only the listed feature groups

Your project ref is the ID in the dashboard URL, supabase.com/dashboard/project/your-project-ref. A scoped, read-only setup looks like this. Keep the quotes, because & means something to your shell:

claude mcp add --scope project --transport http supabase \
  "https://mcp.supabase.com/mcp?project_ref=your-project-ref&read_only=true"

If you already added the server, run claude mcp remove supabase first (add --scope project if that is where it lives), or edit the url in .mcp.json directly. You will be asked to authenticate again.

Feature groups

Every group except Storage is enabled by default. These are the values the features parameter accepts:

Groupfeatures valueExample tools
Databasedatabaselist_tables, list_extensions, list_migrations, apply_migration, execute_sql
Debuggingdebuggingquery_logs, get_advisors
Developmentdevelopmentget_project_url, get_publishable_keys, generate_typescript_types
Edge Functionsfunctionslist_edge_functions, get_edge_function, deploy_edge_function
Accountaccountlist_projects, create_project, pause_project, get_cost
Docsdocssearch_docs
Branchingbranchingcreate_branch, merge_branch, reset_branch (experimental, paid plan)
Storagestoragelist_storage_buckets, get_storage_config (off by default)

A sensible starting point for app development is features=database,docs,debugging,development. You lose the ability to deploy functions or create projects from chat, and Claude has fewer tool definitions to choose from. Note that account tools are skipped whenever you set project_ref.

The Supabase MCP page has an interactive URL builder if you would rather click than type.

Step 4: Verify

claude mcp list

Then in a session, /mcp should show supabase connected with its tool list. Ask something harmless first:

Use the supabase MCP to list the tables in my project and their row-level security status.

If you scoped it with project_ref, Claude should not need to ask which project you mean.

Example Prompts

  • "List my tables and tell me which ones have RLS disabled."
  • "Write a migration that adds a profiles table linked to auth.users, with RLS policies so users can only read and update their own row. Show it to me before applying it."
  • "Generate TypeScript types for my database and save them to src/types/supabase.ts."
  • "Check the security and performance advisors and fix the top issue."
  • "Look at the last hour of API logs and explain the 500 errors."
  • "Search the Supabase docs for how to set up realtime on a table, then implement it here."

The type-generation prompt is a good example of why this belongs in Claude Code rather than a chat app: Claude reads the live schema through MCP and writes the result straight into your repo.

Using a Token Instead (CI and Headless Runs)

OAuth needs a browser, so non-interactive runs such as claude -p in CI cannot complete it. Supabase's docs describe using a personal access token instead:

  1. Create a token at supabase.com/dashboard/account/tokens. Scope it to the project the server connects to and grant only what your enabled tools need.
  2. Set SUPABASE_ACCESS_TOKEN and SUPABASE_PROJECT_REF in the CI environment.
  3. Commit a config that references them. Claude Code expands environment variables in .mcp.json URLs and headers:
{
  "mcpServers": {
    "supabase": {
      "type": "http",
      "url": "https://mcp.supabase.com/mcp?project_ref=${SUPABASE_PROJECT_REF}&read_only=true",
      "headers": {
        "Authorization": "Bearer ${SUPABASE_ACCESS_TOKEN}"
      }
    }
  }
}

Never put a real token in the file. Supabase recommends read-only mode for unattended monitoring and diagnostics routines like this.

Local and Self-Hosted Supabase

If you run Supabase locally with the Supabase CLI, the MCP server is at http://localhost:54321/mcp:

claude mcp add --transport http supabase-local http://localhost:54321/mcp

Per the README, the local and self-hosted servers offer a limited subset of tools and no OAuth 2.1. For self-hosted instances, follow Supabase's "Enabling MCP server" guide.

Security Checklist

Supabase's docs are unusually direct about the risks. The short version:

  • Do not connect production unless the task needs production data. Use a development project or a branch.
  • Use read-only mode whenever Claude only needs to look.
  • Scope to one project with project_ref.
  • Keep manual tool approval on in Claude Code, especially for execute_sql and apply_migration.
  • Watch for prompt injection. Rows in your database can contain text written by users. If Claude reads a row that says "ignore previous instructions", that text reaches the model. Review what it proposes before you approve.
  • Do not give the server to end users. It is a developer tool that acts with your permissions.

More on this in our MCP security best practices.

Troubleshooting

SymptomLikely causeFix
! Needs authenticationOAuth not completed/mcp → supabase → Authenticate
Connected, but Claude cannot find your projectWrong organization chosen at loginRemove and re-add the server, authenticate again and pick the organization that owns the project
Login does not work from the IDEAuth started in the IDE extensionRun claude in a regular terminal and authenticate there
zsh: no matches found or the URL gets cut at &URL not quotedWrap the whole URL in double quotes
Writes fail with permission errorsread_only=true is setExpected; remove it only for tasks that must write
Account tools like list_projects missingproject_ref is setExpected; account tools are disabled when scoped
Branching tools failBranching needs a paid planUpgrade, or use a separate development project
CI run hangs or fails on authOAuth cannot run headlessUse the access token config above

To see the raw tool list and responses, connect the server to the MCP Inspector.

Next Steps

Supabase MCP covers the database side. Add the GitHub MCP server so Claude can open a PR with the migration it wrote, and Playwright MCP to check the feature in a browser. For more databases and backend tools, browse the MCP server directory.

Frequently asked questions

How do I connect Supabase MCP to Claude Code?

Run 'claude mcp add --scope project --transport http supabase https://mcp.supabase.com/mcp', start Claude Code in a terminal, type /mcp, select supabase and choose Authenticate. Log in to Supabase in the browser and pick the organization that owns your project.

Does Supabase MCP need an API key?

Not for interactive use, because Claude Code logs in with OAuth through your browser. For CI or other headless runs, create a personal access token in the Supabase dashboard and send it in an Authorization Bearer header.

How do I make Supabase MCP read-only?

Add read_only=true to the server URL, for example https://mcp.supabase.com/mcp?read_only=true. Every query then runs as a read-only Postgres user.

Is it safe to connect Supabase MCP to a production database?

Supabase recommends connecting to production only when a task really needs production data. Prefer a development project or branch, scope the server with project_ref, use read-only mode and keep manual tool approval on.