A Postgres MCP server for your coding agent.

To give Claude Code, Cursor, Codex, or Copilot access to PostgreSQL over MCP, add the database to Valv Desktop and point your client at http://127.0.0.1:4319/mcp. The agent can list, describe, and query the tables you allow. It can't write, run raw SQL, or see columns you hide, and it never receives your Postgres password.

Book a demo

Comparing servers? Jump to the comparison.

Setup

From a connection string to your first answer.

Valv holds the Postgres connection. Your MCP client only knows a local URL.

  1. 1

    Add PostgreSQL in Valv.

    Paste a connection string to fill host, port, user, password, database, and SSL, or type them in. An sslmode in the string sets the SSL field. Test the connection, then save. The password goes to your OS keychain, not the workspace folder.

    postgres://valv_agent:password@host:5432/app?sslmode=require
  2. 2

    Pick the active schemas.

    Valv starts with public, or every schema if there is no public. Open the datasource's Active schemas menu in the sidebar to add others, such as analytics. Only active schemas reach the agent.

  3. 3

    Hide what the agent shouldn't see.

    Open the datasource settings and switch to AI access. Hide columns like users.email or payments.card_last4. Hide every column to remove a table. You can still open that data yourself.

  4. 4

    Add Valv to your MCP client.

    Open Settings, MCP Server, and copy the guide for your client. Port 4319 is the default. If it's taken, Valv uses another port, so copy the URL the app shows. Keep Valv open while you work.

Claude Code

CLI
claude mcp add --transport http valv-desktop http://127.0.0.1:4319/mcp

Codex

CLI
codex mcp add valv-desktop --url http://127.0.0.1:4319/mcp

GitHub Copilot

CLI
copilot mcp add --transport http valv-desktop http://127.0.0.1:4319/mcp

Cursor, VS Code, and other clients

JSON
{
  "mcpServers": {
    "valv-desktop": {
      "type": "http",
      "url": "http://127.0.0.1:4319/mcp"
    }
  }
}

What the agent can do in your Postgres database.

The agent doesn't send SQL. It sends a structured query that Valv validates, compiles to Postgres SQL, and runs with bound parameters.

It can

  • Find and describe tables, views, and materialized views in the active schemas.
  • Filter, group, aggregate, sort, and follow relations between tables in one query.
  • Chain several read queries in one step with run_code, for example to combine two schemas.
  • See real Postgres errors, such as permission denied, so it can tell you what's missing.

It can't

  • Run raw SQL, so no EXPLAIN, COPY, or DDL.
  • Insert, update, or delete rows. There are no write tools.
  • See hidden columns, or schemas you didn't activate.
  • Run a query for longer than 30 seconds. Valv sets a statement timeout on every agent query.

One tool set per schema.

With one active schema, the agent gets plain tool names. With several, Valv prefixes each tool with the schema name, so a users table in public and one in auth never collide. With more than one datasource in the workspace, the datasource name comes first.

Tools with public and analytics active

public__list_resources
public__describe_resource
public__query
analytics__describe_resource
analytics__query

Postgres role

Connect with a read-only role.

Valv's agent tools are already read-only. A dedicated role adds a limit that Postgres itself enforces, whatever runs on top of it.

  • Repeat the USAGE and SELECT grants for each schema you activate in Valv.
  • ALTER DEFAULT PRIVILEGES covers tables created later by the role that runs it. Add FOR ROLE app_owner if migrations run as another role.
  • On Postgres 14 or later, GRANT pg_read_all_data TO valv_agent is a shortcut that reads every table in every schema. Use it only if that's what you want.
  • Valv's table viewer is read-only anyway, so a read-only role changes nothing for you in the app.
psql
-- Run as a superuser or the database owner.
CREATE ROLE valv_agent WITH LOGIN PASSWORD 'choose-a-strong-password';

GRANT CONNECT ON DATABASE app TO valv_agent;
GRANT USAGE ON SCHEMA public TO valv_agent;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO valv_agent;

-- Tables created later by this role are readable too.
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT ON TABLES TO valv_agent;

-- Every session starts read-only at the database level.
ALTER ROLE valv_agent SET default_transaction_read_only = on;

SSL and hosted Postgres.

Valv connects straight from your machine to the database, so the database has to be reachable from where you sit. There is no SSH tunnel option in the connection form. For a private network, use your VPN or open a tunnel yourself and point Valv at the local port.

The SSL field

Disable Local Postgres in Docker or on localhost.
Allow Try without TLS first, fall back to TLS.
Prefer The default. Use TLS when the server offers it.
Require Hosted Postgres. Always encrypt, don't verify the certificate.
Verify full Encrypt and check the certificate and hostname.
ssh -N -L 5433:db.internal:5432 you@bastion

Then connect Valv to localhost, port 5433.

Supabase

Copy a connection string from the Connect dialog. The direct connection is IPv6 by default, so on an IPv4-only network use the session pooler string. Prefer the session pooler over the transaction pooler on port 6543, since Valv's Postgres driver uses prepared statements.

Neon

Neon's connection string already includes sslmode=require, which Valv picks up when you paste it. If the pooled host gives you prepared statement errors, use the direct connection string instead.

Amazon RDS and Aurora

The instance must be reachable from your machine: publicly accessible with your IP in the security group, or through your VPN. Choose Require for SSL. Valv's form has no field for a custom CA certificate.

Valv or a standalone Postgres MCP server?

Standalone servers don't need a desktop app and can run on a server or in CI. Most pass SQL straight to Postgres, which gives the agent more power and relies on read-only transactions for safety. Valv trades raw SQL for validated queries and column-level hiding.

Valv Desktop

Desktop app, local HTTP endpoint

Read-only structured queries, per-column hiding

You want your agent and yourself looking at the same database, with a GUI, credentials in the OS keychain, and no raw SQL in the agent's hands.

Postgres MCP Pro (crystaldba)

Python or Docker, stdio or SSE

Raw SQL, restricted (read-only) or unrestricted mode

You want index tuning, EXPLAIN plans, hypothetical indexes, and database health checks. Valv has none of these.

Supabase MCP

Hosted at mcp.supabase.com

SQL, migrations, branches, with an optional read-only flag

Your database is on Supabase and you want the agent to manage the project too, not only read data.

AWS Labs Postgres MCP server

Python, RDS Data API or direct connection

Read-only by default, writes with a flag

You run Aurora or RDS and want IAM authentication or credentials from AWS Secrets Manager.

pgEdge Postgres MCP server

Self-hosted binary or Docker, stdio or HTTP

SQL in read-only transactions

You need a server that several people or a remote agent can reach over HTTP, with its own auth and web UI.

@valv/mcp

npx, stdio or HTTP

Read-only structured queries, table filters, policy file

You want Valv's structured queries without the desktop app, for example in a project's .mcp.json.

On Supabase, see the Supabase MCP guide. On MySQL, see the MySQL MCP server guide. For other databases, see the database MCP guide.

Postgres MCP, answered

What is a Postgres MCP server?

A Postgres MCP server is a program that gives an AI agent tools for your PostgreSQL database over the Model Context Protocol, usually schema discovery and queries. Claude Code, Cursor, Codex, Copilot, and other MCP clients can then answer questions from your data without you copying results into the chat.

How do I connect Claude Code to PostgreSQL with MCP?

Add the database to Valv Desktop, then run: claude mcp add --transport http valv-desktop http://127.0.0.1:4319/mcp. Keep Valv open. Claude Code can then list, describe, and query the tables in the active workspace. Copy the exact URL from Settings, MCP Server, in case Valv picked a different port.

Can the agent write to my Postgres database through Valv?

No. Valv gives MCP clients discovery tools and a structured, read-only query tool. There are no tools for raw SQL, INSERT, UPDATE, DELETE, or DDL. For a second line of defense, connect Valv with a Postgres role that only has SELECT grants.

Does it work with Supabase, Neon, or Amazon RDS?

Valv connects to Postgres with a host, port, user, password, database, and SSL mode, or a pasted postgres:// connection string. Any hosted Postgres your machine can reach works the same way. Use SSL Require for hosted databases.

Can I limit which schemas and columns the agent sees?

Yes. Choose the active schemas from the datasource's menu in the sidebar. By default Valv uses public. Then hide columns in the AI access tab. Hiding every column of a table removes the table from the agent's view. Hidden data is filtered from discovery and query results.

Is Valv's Postgres MCP server free?

Valv Desktop is free for personal, non-commercial use, with every feature included. Commercial use needs a seat license, a one-time $99 per user.

Connect your agent to Postgres.

Free for personal use, every feature included. Commercial use needs a seat at beta pricing. See pricing.

All downloads Other platforms and builds