Postgres MCP Servers Compared

Five ways to connect an AI agent to Postgres over MCP, and what each one actually lets the agent do.

Checked against each project’s documentation on . These servers change often: confirm a detail in the sources before you rely on it.

A Postgres MCP server is the piece that lets Claude, Cursor, Codex or your own agent list tables and run SQL against a Postgres database through the Model Context Protocol. Several are maintained today, and they differ less in how they connect than in what they let the agent do once it is connected.

This guide compares the five you are most likely to meet: the servers Supabase and Neon run for their own platforms, two open-source servers that work with any Postgres, and the original reference server. For each: where it runs, how its read-only mode works, what it can change, and who it suits.

At a glance

ServerMade byWhere it runsDatabasesRead-onlyCan it write?
Supabase MCP serverSupabaseHosted at mcp.supabase.com/mcp with OAuth sign-in; locally through the Supabase CLISupabase projects (hosted, local CLI or self-hosted Supabase)read_only=true runs every query as a read-only Postgres userYes unless read-only: migrations, SQL, Edge Functions, projects and branches
Neon MCP serverNeonHosted at mcp.neon.tech/mcp with OAuth or a Neon API keyNeon projectsreadonly=true hides write tools and runs run_sql in a READ ONLY transaction; roleName pins a Postgres roleYes unless read-only: projects, branches, roles, migrations through a temporary branch
Postgres MCP ProCrystal DBA (open source, MIT)Your machine or server, via Docker or Python; stdio or SSE transportAny Postgres you can reach with a connection URI--access-mode=restricted: read-only transactions plus an execution-time limitIn unrestricted mode, full read and write access to data and schema
MCP Toolbox for DatabasesGoogle (open source, Apache 2.0)Your machine or server: binary, container, Homebrew or npxPostgreSQL, AlloyDB, Cloud SQL and many non-Postgres databasesNo single switch: in production you define each tool as a fixed SQL statementThe prebuilt tools include execute_sql; custom tools do only what their statement does
Reference PostgreSQL serverThe MCP project (archived)Locally via npx @modelcontextprotocol/server-postgres or DockerAny Postgres connection URLAlways read-only: every query runs in a READ ONLY transactionNo

The servers

1. Supabase MCP server

Supabase's own server, run by Supabase. It covers far more than SQL: tool groups for the database (list_tables, execute_sql, apply_migration), debugging (query_logs, get_advisors), Edge Functions, account management, docs search, branching and storage.

Most clients sign in through the browser, so there is no access token to paste. CI setups can pass a personal access token in an Authorization header instead.

How it keeps an agent in bounds. Three URL parameters do the scoping: project_ref limits it to one project (and turns off account tools), read_only=true executes queries as a read-only Postgres user, and features enables only the tool groups you name, such as features=database,docs.

When your client supports MCP elicitation forms, it asks for confirmation before destructive SQL and before creating projects or branches that cost money. Supabase calls this a guardrail, not a guarantee: it depends on the client, and skip_elicitations turns it off.

Watch for.

  • It runs with your developer permissions. Supabase's own advice is not to give it to customers or end users, and to connect a production project only when the task needs production data.
  • It wraps SQL results in instructions that discourage the model from obeying text found in the data. Supabase says this is not foolproof against prompt injection.

Pick it if your app is on Supabase and you want an assistant in your editor that can read the schema, run queries and help with migrations. Docs

2. Neon MCP server

Neon's remote server translates requests into Neon API calls and SQL. Alongside run_sql and schema tools it manages projects, branches, compute endpoints, snapshots, Neon Auth and more.

Schema changes go through two steps: prepare_database_migration applies the migration on a temporary branch to test it, and complete_database_migration applies it to the main branch. Query tuning works the same way.

How it keeps an agent in bounds. readonly=true removes write tools; run_sql stays and runs each query in a READ ONLY transaction. projectId scopes everything to one project, and category limits the tool groups.

roleName makes every SQL statement log in as a Postgres role you choose. Without it, SQL runs as the database owner. With a role that only has SELECT on the tables the agent should see, Postgres itself enforces the limit, even for SQL that escapes the transaction.

Watch for.

  • Neon says the server is meant for local development and IDE integrations, and does not recommend it in production environments.
  • It collects product analytics on tool calls (not their arguments or results); its README describes what is sent.

Pick it if your database is on Neon and you want branch-based migrations from your editor, ideally with a SELECT-only role pinned. Docs

3. Postgres MCP Pro

A general-purpose server built around database performance work. Besides schema tools and execute_sql, it offers explain_query (including plans with hypothetical indexes), get_top_queries, index recommendations for a workload or for specific queries, and analyze_db_health, whose checks are adapted from PgHero.

Index tuning and workload analysis need the pg_stat_statements and hypopg extensions. Its maintainers say testing focuses on Postgres 15, 16 and 17.

How it keeps an agent in bounds. Restricted mode runs SQL in read-only transactions and limits execution time. Because a read-only transaction sits on a read-write connection, it also parses each statement and rejects COMMIT and ROLLBACK, which could otherwise end the transaction and start a writable one.

Watch for.

  • Its README notes that unsafe stored procedure languages enabled on the database could get around the read-only protections.
  • The connection URI is set at startup, usually in the MCP client's config file, and the README points out that few clients store that config securely.

Pick it if you run Postgres on RDS, Cloud SQL, your own servers or anywhere else, and want an agent to find slow queries and missing indexes. Docs

4. MCP Toolbox for Databases

Formerly Gen AI Toolbox for Databases. It works two ways. Run with --prebuilt=postgres and you get generic tools such as list_tables and execute_sql for exploring a database from your editor.

Or write a tools.yaml: each tool names a source, a description, typed parameters and one SQL statement, for example a search that runs SELECT … WHERE name ILIKE '%' || $1 || '%'. Toolsets group tools per agent, and SDKs load them into LangChain, LlamaIndex, Genkit, ADK and others.

How it keeps an agent in bounds. With custom tools the agent never writes SQL. It picks a tool and fills in its parameters, so the queries it can run are the ones you wrote down. The server also handles connection pooling and exports OpenTelemetry traces and metrics.

Watch for.

  • The prebuilt Postgres tools hand the agent open SQL, so they belong in development. Production safety comes from writing the tools, which is work you have to do and keep up to date.

Pick it if you are putting an agent in production and it should answer a known set of questions, not write its own queries. Docs

5. Reference PostgreSQL server

The original example server from the MCP project: one query tool that runs SQL in a READ ONLY transaction, and each table's columns and types exposed as MCP resources.

How it keeps an agent in bounds. Read-only is not optional, and there is nothing else to call: no schema changes, no admin tools.

Watch for.

  • It now lives in the servers-archived repository, so it is no longer maintained. Many tutorials still point to it. Treat it as a reference for how a server is built, not something to connect to a database that matters.
  • Schema comes through resources, which fewer MCP clients support than tools.

Pick it if you want to read a minimal Postgres MCP server to understand how one works. Docs

“Read-only” means three different things

Every server above has some kind of read-only mode, but they are not the same guarantee:

  • A read-only database role. Supabase's read_only=true runs queries as a read-only Postgres user, and Neon's roleName runs them as whatever role you create. Postgres refuses the write whatever SQL arrives, so this is the strongest of the three, as long as the role's grants are narrow.
  • A READ ONLY transaction on a read-write connection. Neon's run_sql in read-only mode, Postgres MCP Pro's restricted mode and the reference server wrap each query this way. It works, but the server has to stop SQL that ends the transaction, which is why Postgres MCP Pro parses statements and rejects COMMIT and ROLLBACK.
  • Fixed statements. With MCP Toolbox custom tools the agent can only call queries you wrote. Nothing is checked at run time because nothing new can be sent.

What read-only does not cover

Read-only stops writes. It does not stop a query from returning rows the agent should never see: if the role can read a customers table, the agent can put that table's email addresses into its context. It does not stop prompt injection either, since a row can carry text the model reads as instructions. And it does not protect your app's performance: an agent's analytical query runs on the same database your users are hitting, and of the servers here only Postgres MCP Pro documents a time limit for it.

Those gaps are why many teams point agents at a governed layer instead of the database: pre-modeled metrics and datasets the agent reads, with production Postgres out of reach. Dreambase, which builds this for Supabase teams, pre-models data into governed datasets and exposes them through a single MCP server, so agents never query the production database. The posts linked below cover the pattern in depth.

Which one to choose

  • Building on Supabase: the Supabase MCP server, with project_ref, read_only=true and features=database,docs, against a development branch or the local CLI stack rather than production.
  • Building on Neon: the Neon MCP server with readonly=true, projectId and roleName set to a role that only has SELECT.
  • Tuning any Postgres: Postgres MCP Pro, restricted mode on production, unrestricted only on databases you can rebuild.
  • An agent in production with a known job: MCP Toolbox custom tools, one per question it needs to answer.
  • Agents answering business questions (revenue, churn, usage): a governed metrics layer rather than a database server, so every agent and person gets the same numbers.

Questions

Is there an official Postgres MCP server?

Not one that is maintained for every Postgres. The MCP project's own reference server is archived. Supabase and Neon maintain servers for their platforms, and Postgres MCP Pro and Google's MCP Toolbox are maintained open-source options that connect to any Postgres.

Can I use the Supabase MCP server with a Postgres database that isn't on Supabase?

No. It connects to Supabase projects: hosted, through the Supabase CLI, or self-hosted Supabase (the last two with a smaller set of tools). For other Postgres, use a general-purpose server such as Postgres MCP Pro or MCP Toolbox.

Is it safe to connect a Postgres MCP server to production?

Neon does not recommend its server in production, and Supabase advises connecting a production project only when the task needs it, scoped to one project, read-only and with as few tool groups as possible. If you must, combine a narrow read-only role, the server's read-only mode and the smallest tool set, and keep manual approval of tool calls on.

How do I add a Postgres MCP server to Claude Code?

With claude mcp add. For Supabase's hosted server, its docs give claude mcp add --scope project --transport http supabase "https://mcp.supabase.com/mcp", then /mcp to sign in. For servers that run locally, add the command each project's README gives to your client's MCP config.

Further reading on Product Metrics Report

Sources