Supabase Read-Only MCP Server
You can perform read-only, allowlisted database inspection and bounded row queries through MCP.
Check server and database availability (
health_check).List configured and validated allowlisted tables/views (
list_allowed_tables).Describe safe column metadata for one allowlisted table/view (
describe_table).Select bounded rows from allowlisted objects with typed filters, ordering, limit, and offset (
select_rows).Cannot run arbitrary SQL, write data, or access objects outside
MCP_ALLOWED_TABLES; reads are bounded and read-only.
Provides read-only access to an allowlisted subset of Supabase PostgreSQL tables and views, with tools to check health, list allowed tables, describe table columns, and select rows using typed filters, ordering, limits, and offsets.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Supabase Read-Only MCP Servershow me the latest 10 rows from the transactions table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Supabase Read-Only MCP Server
A small FastMCP service that exposes an explicitly allowlisted subset of Supabase PostgreSQL through read-only tools. It supports stdio for local MCP clients and Streamable HTTP for separately managed clients. Selected results can also be presented as declarative A2UI interfaces.
This repository currently contains the MCP server only. It does not contain an LLM agent, chat UI, application API, migrations, or write tools.
What it protects
A dedicated PostgreSQL login owns the database connection; do not use the Supabase
postgresrole or a service-role API key.MCP_ALLOWED_TABLESis an exact allowlist of tables and views. An empty value is deny-all.Tables and columns are resolved from reflected metadata; clients cannot submit SQL.
Values are bound by SQLAlchemy, reads are bounded, and each database transaction is read-only with a local statement timeout.
TLS is enforced when
sslmodeis omitted and onlyrequire,verify-ca, orverify-fullare accepted when it is supplied.PostgreSQL grants do not bypass Row Level Security. Configure suitable RLS policies for the reader role.
Related MCP server: postgres-mcp
Prerequisites
Python 3.11 or newer
A Supabase direct or session-pooler PostgreSQL URL for a dedicated read-only role
Node.js only if you use MCP Inspector
Configure
Install the project and its locked dependencies, then create a local environment file:
uv sync
Copy-Item .env.example .envuv sync
cp .env.example .envSet the database URL and exact object allowlist in .env:
SUPABASE_DATABASE_URL=postgresql://mcp_reader:REPLACE_WITH_PASSWORD@db.PROJECT_REF.supabase.co:5432/postgres?sslmode=require
MCP_ALLOWED_SCHEMAS=public
MCP_ALLOWED_TABLES=public.customers,public.accounts,public.transactionsFor the Supabase session pooler, use its connection parameters. Both postgresql:// and postgresql+psycopg:// are accepted. Percent-encode special characters in usernames and passwords.
All supported settings and defaults are documented in .env.example. The service has no LLM_*, OPENAI_*, or AGENT_* settings.
Run
Stdio (the default):
uv run supabase-mcp
# equivalent:
uv run python -m supabase_mcp.serverMCP Inspector:
uv run fastmcp dev inspector src/supabase_mcp/server.py:mcp --project .Streamable HTTP:
$env:MCP_TRANSPORT = "http"
uv run supabase-mcpBy default the HTTP MCP endpoint is http://127.0.0.1:8000/mcp. The loopback endpoint has no application authentication; exposing it beyond a trusted local environment requires authentication, TLS termination, network controls, rate limiting, secret management, and monitoring.
On Windows, start the module as shown above. supabase_mcp.server selects the event-loop policy Psycopg async requires before importing the database stack.
Deploy to Prefect Horizon
Configure Horizon with these exact build settings:
Project root: the repository root containing this
pyproject.toml. If this directory is checked out asmcp/inside a larger monorepo, selectmcp/as the project root.Python:
3.12.Dependencies / requirements:
pyproject.toml.Entrypoint:
src/supabase_mcp/server.py:mcp.
The :mcp suffix is required: Horizon imports the module-level FastMCP object and does not execute main() or depend on the local stdio transport. The package uses a Hatchling src layout and is installed during the build, so no manual PYTHONPATH is needed.
Configure runtime values in Horizon's environment/secrets UI, never in a committed .env:
Required secret:
SUPABASE_DATABASE_URL, using a dedicated read-only PostgreSQL role and TLS.Required for data exposure:
MCP_ALLOWED_TABLES, containing the exact qualified tables/views. Empty or omitted remains deny-all.Recommended explicit setting:
MCP_ALLOWED_SCHEMAS(defaults topublic).Optional controls:
MCP_DEFAULT_LIMIT,MCP_MAX_LIMIT,MCP_STATEMENT_TIMEOUT_MS, andLOG_LEVEL.
MCP_TRANSPORT, MCP_HOST, and MCP_PORT are only used by direct execution through main(); Horizon owns its hosted transport when it imports mcp.
Before deploying, reproduce Horizon's build/import path from the repository root:
uv sync --locked
uv build
uv run python -c "from supabase_mcp.server import mcp; print(type(mcp))"
uv run fastmcp inspect src/supabase_mcp/server.py:mcpImporting or inspecting the object does not load Settings, start a transport, construct a database engine, or connect to Supabase. Runtime settings and database reflection begin only when FastMCP enters app_lifespan.
Tools
health_check: runs a sanitizedSELECT 1readiness check.list_allowed_tables: lists configured objects that were successfully reflected at startup.describe_table: returns cached column metadata for one allowlisted table or view.select_rows: reads selected columns with typed filters, ordering, limit, and offset.database_overview: returns a bounded database-object overview with A2UI v0.9.1 presentation metadata, a dynamic data-model update, structured domain data, and a text fallback.visualize_allowed_data: reads only selected columns from one reflected allowlisted object and maps them to a bounded area chart (up to 240 rows and four numeric series) or calendar heatmap (up to 500 rows).a2ui_action: dispatches the five A2UI action fields through an explicit read-only action allowlist. The initialrefresh_database_overviewaction refreshes the overview using a validated limit.a2ui_error: safely acknowledges client rendering and validation reports without echoing their potentially sensitive message.
select_rows supports eq, ne, gt, gte, lt, lte, in, like, ilike, and is_null. Filter values are JSON scalars; in accepts a non-empty list of at most 100 scalars. The response includes row_count, the effective limit, offset, and a truncated flag. If no ordering is supplied, tables with primary keys are ordered by those keys.
A2UI v0.9.1 over MCP
A2UI is a declarative presentation protocol. It does not replace MCP, FastMCP, the database service, or PostgreSQL permissions. This server implements the current production protocol version v0.9.1 with MIME type application/a2ui+json; it does not use the candidate v1.0 protocol and does not run client-provided code.
Both visual surfaces separate cacheable presentation from changing data. database_overview remains on the official Basic Catalog at a2ui://database/overview. visualize_allowed_data uses a2ui://finance/data-chart and the project-owned catalog https://fluidbank.app/a2ui/catalogs/finance/v1, which contains only Text, Button, Card, Column, and Chart.
The database overview flow is:
resources/listadvertisesa2ui://database/overview.resources/readreturns its staticcreateSurfaceandupdateComponentsmessages. The template contains data bindings but no Supabase results.tools/callfordatabase_overviewobtains a bounded domain result and returns:useful
TextContentfor clients without A2UI;the same domain result in
structuredContent;an
EmbeddedResourcecontaining onlyupdateDataModel;_meta.uilinking the result toa2ui://database/overview.
An A2UI-capable client fetches and caches the template, applies the dynamic update, and renders the component tree using its own widgets.
The chart resource follows the same flow. Its packaged data_chart.json contains only createSurface and updateComponents; the tool embeds only updateDataModel. The strict request selects a reflected source plus filters, ordering, limit, and either {kind: "area", x_column, y_columns} or {kind: "heatmap", date_column, value_column}. It cannot select a component, catalog, URI, style, JSX, or raw A2UI. Numeric columns are checked from reflected metadata, values must be finite, ordering is deterministic, and rows with null required values are omitted and counted. Duplicate mapped labels/dates and malformed dates fail safely.
Chart binds one whole discriminated value at /chart: {kind: "area", accessibleSummary?, props: AreaChartProps} or {kind: "heatmap", accessibleSummary?, props: HeatmapChartProps}. Area series require stable unique IDs; both variants reject unknown properties and bound all arrays and strings. Empty arrays are valid and delegate to the existing client empty states.
The embedded resource is annotated for the user audience so a supporting host can render it without putting presentation JSON into the model context. The separate fallback and structured domain data remain available for reasoning and for clients that ignore embedded resources.
Inspect the protocol
Start Inspector from this directory:
uv run fastmcp dev inspector src/supabase_mcp/server.py:mcp --project .In Inspector:
List resources and read
a2ui://database/overview.List tools and inspect
database_overview; its definition includes_meta.ui.Call it with
{"limit": 25}and inspect its text,structuredContent, embeddedupdateDataModel, and runtime_meta.ui.Optionally call
a2ui_actionwithname,surfaceId,sourceComponentId,timestamp, andcontextas emitted by the refresh button.
Inspector exposes the real MCP JSON but does not render A2UI. A rendering client must recognize application/a2ui+json, resolve _meta.ui.resourceUri, validate/process v0.9.1 messages, implement the declared allowlisted catalog, maintain per-surface data state, and forward component actions to a2ui_action.
Extend A2UI safely
To add a surface:
Add a static JSON template under
src/supabase_mcp/a2ui_support/templates/usingv0.9.1, one registered catalog, stable component IDs, aroot, and data bindings.Add a
SurfaceSpecand register it ina2ui_support/surfaces.py; registration loads it throughimportlib.resources, rejects duplicate IDs/URIs or missing templates, and validates it with the official SDK.Publish the cached template with
mcp.resource(...)and its stablea2ui://URI.Write a pure mapper from the domain result to the template data model, then use
A2UIResponseFactoryin only the tool that needs that surface.
To add a custom component, first extend the versioned catalog, validate it with the installed SDK, synchronize the checked-in agent copy, implement an explicit client adapter, and add shared accept/reject fixtures plus package-content tests. Do not expose renderers, error boundaries, low-level drawing primitives, callbacks, styles, or generic objects. To add an action, include it on a template component, define a strict Pydantic context model, and add one fixed RegisteredAction to the central registry. Do not create a tool per button or derive handlers with eval, dynamic imports, or input-driven getattr.
Catalog negotiation limitation
A2UI recommends negotiating supported catalogs during MCP initialize. FastMCP 4.0.3 does not expose a documented public server hook for reading arbitrary client initialization capabilities and persisting a selected custom catalog per session. This implementation therefore does not claim initialize-time negotiation, does not use FastMCP internals or monkeypatching, and emits only its fixed allowlist: the official Basic Catalog and Finance Catalog v1. A controlled client must recognize the catalog declared by each surface; unsupported clients continue to use the text and structured-data fallback. Per-call capability metadata is not consumed because FastMCP does not expose it to these typed handlers as a stable catalog-negotiation API.
Validate changes
These checks do not require a live database:
uv run pytest
uv run ruff format --check src/supabase_mcp
uv run ruff check .
uv run mypy
uv run python -c "from supabase_mcp.config import Settings; print('import ok')"Server configuration always requires a syntactically valid database URL. Startup connects to Supabase when MCP_ALLOWED_TABLES is non-empty so every allowlisted object can be validated and reflected; health_check also performs a live database round trip.
Troubleshooting
Configuration fails: confirm the URL is PostgreSQL, identifiers contain only supported PostgreSQL identifier characters, every qualified table uses an allowed schema, and the default limit does not exceed the maximum.
Startup fails: verify connectivity, TLS, the allowlisted object names, schema
USAGE, and objectSELECTprivileges.Pooler login fails: copy the session-pooler host, port, database, and username exactly from Supabase; the username commonly includes the project reference.
An object is rejected: add it explicitly to
MCP_ALLOWED_TABLES. Adding a schema alone does not expose its objects.HTTP is unreachable: confirm
MCP_TRANSPORT=http, then checkMCP_HOST,MCP_PORT, and the/mcppath.
See ARCHITECTURE.md for implementation details and AGENTS.md for repository contribution rules.
Available Tools
4 toolsdescribe_tableDescribe TableB
Describe safe column metadata for one allowlisted schema/table; rejects all others.
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| schema | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| error | No | |
| table | Yes | |
| schema | Yes | |
| columns | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must carry full behavioral disclosure. It only notes that non-allowlisted inputs are rejected, but omits details on permissions, safety guarantees, return format, or error behavior beyond rejection. 'Safe' is vague and adds little concrete behavioral context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, front-loaded sentence with zero waste. The key constraint is stated directly and no unnecessary words are included.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple two-parameter tool with an output schema already covering return values, the description covers purpose and allowlist restriction adequately. However, it lacks routing to list_allowed_tables and provides no parameter format details, leaving clear gaps for an agent to infer.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It names 'schema/table' but adds no format, case-sensitivity, or distinction details beyond the allowlist constraint. This is minimal added meaning over the bare parameter names.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (Describe) and resource (safe column metadata) with a clear scope (one allowlisted schema/table). Distinguishes from sibling tools by focusing on column metadata rather than listing tables or selecting rows, though it does not name alternatives explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The allowlist requirement ('one allowlisted schema/table; rejects all others') provides a clear usage condition, but there is no mention of how to discover allowed tables (e.g., via list_allowed_tables) or when to prefer this over other tools. Usage is implied rather than fully guided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
health_checkHealth CheckA
Check server and database availability with SELECT 1; returns no sensitive details.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| error | No | |
| status | Yes | |
| database_available | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It adds genuine behavioral value by disclosing the underlying query ('SELECT 1') and that no sensitive details are returned, which signals a safe, non-destructive probe. However, it says nothing about side effects, rate limits, or permission requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single compact sentence with the core purpose front-loaded, followed by the mechanism and the safety note. Every clause earns its place; there is no filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so the description needn't enumerate return values, and it correctly avoids this. Combined with the zero-parameter schema, the coverage is nearly complete; only the absence of any when-to-call guidance keeps it from a 5.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, which is the baseline case where no parameter documentation is required. The description correctly does not burden itself with param details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb ('Check') and resources ('server and database availability'), plus the mechanism ('SELECT 1'). This is clearly a connectivity probe, readily distinguishable from the table/row-oriented siblings list_allowed_tables, describe_table, and select_rows.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is implied rather than stated — an agent can infer this is the pre-flight connectivity probe, but the description never says when to call it versus the sibling query tools, nor whether it should precede other operations. No explicit exclusions or alternatives are given.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_allowed_tablesList Allowed TablesA
List only configured and validated tables/views; use before describing or selecting.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| error | No | |
| objects | No | |
| object_count | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must carry the behavioral burden. It usefully discloses that only tables passing configuration/validation checks are returned (a permission-scoping trait), but says nothing about whether access is required, error behavior, or whether results are cached. The output schema covers the return shape, offsetting some of the gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single compact sentence with the scope constraint front-loaded and the usage rule trailing as a clear directive. No filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter listing tool with a fully specified output schema, the description covers the essential purpose and sequencing. It stops just short of larger context such as required connection/auth state, but nothing critical to correct invocation is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, so there is no parameter semantics to document; the baseline of 4 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Names a specific verb (List) and resource (configured/validated tables and views), and the scope qualifier 'only configured and validated' separates it from describe_table and select_rows at a glance.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
'use before describing or selecting' explicitly states when to call it and implicitly routes the agent to describe_table/select_rows afterward. It gives a clear sequencing rule but no when-not condition or explicit naming of the sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
select_rowsSelect RowsB
Select bounded rows from an allowlisted object using typed filters, never arbitrary SQL.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| table | Yes | ||
| offset | No | ||
| schema | Yes | ||
| columns | No | ||
| filters | No | ||
| order_by | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| rows | No | |
| error | No | |
| limit | Yes | |
| offset | Yes | |
| row_count | No | |
| truncated | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It does disclose meaningful behavioral traits: results are bounded, only allowlisted objects are reachable, filters are typed, and arbitrary SQL is rejected. However it omits what happens to defaults, permission/authorization errors, or how bounding interacts with limit/offset, leaving notable gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no filler; the core action and the key safety constraint appear immediately. It is on the terse side for a 7-parameter tool, but every clause earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need not be explained, and the description correctly covers the read-only, bounded, allowlist-constrained nature of the call. But for a tool with seven parameters and no schema descriptions, the definition is thin on how filters, ordering, and pagination compose, leaving an agent to infer behavior.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% for seven parameters. The description only gestures at 'typed filters' and 'bounded rows', which maps loosely to the filters/limit parameters, but leaves schema, table, columns, offset, and order_by semantics to the raw schema. It does not compensate for the coverage gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a specific verb (Select) and resource (bounded rows from an allowlisted object), making the core operation unambiguous. It implicitly separates itself from siblings by emphasizing that it reads row data rather than metadata (list_allowed_tables, describe_table), though it never names those siblings explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It states the tool is for reading rows but offers no guidance on when to choose it over the sibling tools (e.g. against describe_table for schema inspection), nor any prerequisites like needing to call list_allowed_tables first. The usage context is implied at best.
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.
4 tool updates
v0.1.0- First observed
describe_table - First observed
health_check - First observed
list_allowed_tables - First observed
select_rows
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: health_check for server/database status, list_allowed_tables for table enumeration, describe_table for schema metadata, and select_rows for data retrieval. There is no overlap or confusion between these roles.
All tools use snake_case, which is consistent. However, health_check breaks the verb_noun pattern followed by list_allowed_tables, describe_table, and select_rows, creating a minor deviation.
Four tools are well-scoped for a focused read-only server. Each tool earns its place, covering health, table listing, schema description, and row selection without redundancy.
The surface covers health checks, table discovery, schema metadata, and data selection, which is nearly complete for read-only access. Minor gaps like explicit schema listing or relationship introspection exist but are not critical.
Maintenance
Related MCP Connectors
- dataOAuthco.thinair
Read-only PostgreSQL, MySQL, SQL Server access via MCP — 24 dialect-aware hosted tools.
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
Read-only MCP server for turva.dev's published service catalog, pricing and contact details. Five tools return JSON, including dated agent-readiness and security evidence with verification links. Connect over Streamable HTTP without an API key. The server answers questions about turva.dev and does not scan other websites or run audits.
Related MCP Servers
- AlicenseAqualityCmaintenanceLocal MCP server for safe querying and inspecting PostgreSQL databases, with write and maintenance operations disabled by default.8171ISC
- AlicenseAqualityCmaintenanceA self-hostable PostgreSQL MCP server for exploring database schemas and running guarded read/write queries with selectable access modes (readonly, readwrite, admin), plus a dry-run confirm workflow for safety.141MIT
- AlicenseAqualityDmaintenanceA secure, read-only PostgreSQL MCP server that provides safe database introspection and querying capabilities.1410MIT
- AlicenseNot gradedqualityCmaintenanceProvides a read-only PostgreSQL MCP server with schema introspection. Enforces least-privilege database roles to prevent any writes, even from malicious SQL.MIT