Skip to content
portward

Guide · checked

Ways to give Claude access to your database, compared

Whichever way you choose, give Claude a database login that can only read, and only the tables it needs. The options differ in where that login's password lives, what stops a write, what the AI sees, and whether anything records it.

Portward wrote this page and makes one of the options. Each claim about another product links to the page it came from. Found an error? Write to admin@portward.ai and we'll correct it and update the date.

The options side by side

Ways to give Claude access to a database, compared on seven questions. Checked 2026-11-17.
OptionWhere it runsDatabasesWhere the password livesHow read-only is enforcedKeep columns from the AIRecord of what the AI ranStatus
Reference Postgres serverReference server (archived)On your computer, started by your AI app[1]PostgreSQL[1]In the connection string in your AI app's config file[1]Queries run in a READ ONLY transaction; Datadog showed a multi-statement string could end it and run a write[1][3]Not offered; use database grants[1]Not offered[1]Archived 2025-05-29; npm marks it "Archived and unmaintained; no security guarantees"[3][2]
Postgres MCP ProCommunity serverOn your computer (Docker, uvx or pipx), or self-hosted over SSE[4]PostgreSQL[4]DATABASE_URI environment variable in your AI app's config[4]Restricted mode (--access-mode): read-only transactions, SQL parsed to refuse COMMIT and ROLLBACK, a time limit. Unrestricted mode reads and writes[4]Not offered; use database grants[4]Not offered[4]Latest release v0.3.0 (2025-05-16); repository updated in 2026[4]
DBHubCommunity serverOn your computer or self-hosted (npx, Docker)[5]PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite[5]A DSN flag or a TOML config file[5]readonly = true: a keyword check plus the database's own read-only transaction; its docs call it "a guardrail… not a permission boundary"[6]Not offered; use database grants[5]A list of recent requests in memory (latest 100 per source, lost on restart); no lasting log[5]Maintained[5]
MCP Toolbox for DatabasesGoogle open-source serverSelf-run server[7]Many, including PostgreSQL, MySQL, SQL Server, Cloud SQL and AlloyDB[7]A source entry in tools.yaml, or environment variables for prebuilt tools[7]Custom tools are fixed SQL statements you write; the prebuilt set includes an execute_sql tool, and we found no read-only switch for it in the README[7]By writing tools that select only the columns you allow[7]OpenTelemetry traces and metrics[7]Maintained[7]
Supabase MCPVendor-hosted, Supabase projectsHosted by Supabase (mcp.supabase.com), or local with the Supabase CLI[8]Supabase Postgres[8]No database password: you sign in with OAuth, or a personal access token for CI[8]read_only=true runs queries as a read-only Postgres user; project_ref scopes it to one project[8]Not offered; use database grants[8]Not described for users[8]Maintained. Supabase warns about prompt injection and advises connecting to production only when a task needs it[8]
Neon MCPVendor-hosted, Neon projectsHosted by Neon (mcp.neon.tech)[11]Neon Postgres[11]No database password: OAuth or a Neon API key[11]Read-only mode removes write tools, and run_sql then runs each query in a READ ONLY transaction[12]Not offered[11]Not offered to users; its analytics record tool names, not arguments or results[12]Maintained. Neon recommends it for development and testing, not production[11]
PlanetScale MCPVendor-hosted, PlanetScale databasesHosted by PlanetScale[13]PlanetScale Vitess (MySQL) and Postgres[13]No database password: OAuth, or service tokens for CI[13]Each query runs with short-lived credentials made for it and deleted afterwards (Postgres reads use a pg_read_all_data role); admins choose no access, read-only or full access[13]Not offered[13]Queries are tagged so they appear in PlanetScale Insights[13]Maintained[13]
A CSV export uploaded to ClaudeNo connectorclaude.ai: up to 500MB per file, 20 files per chat[14]Any you can export fromStays with whoever made the exportClaude gets a copy, not the databaseLeave the columns out of the exportThe chat itselfStale as soon as it's exported
Claude Code running psqlNo connectorYour computerAny with a command-line clientWherever you keep it for psqlOnly what the login allows; Claude Code asks before running commands, and its docs call argument-matching rules fragile[15]Database grants onlyYour terminal history—
PortwardHosted Claude connector (ours)Hosted by Portward: one engine per accountPostgreSQL and MySQL on the internetTyped on a Portward page, sealed on your engine, which Portward runs; never in the chatSQL parsed to exactly one SELECT, run in a read-only transaction with a 30-second limit; administrator logins refusedYes: columns you keep from Claude never reach itYes: a history of each query (no time limit), and what Claude was sent, sealed and kept 30 daysLive; Free has limits

“Not offered” means the source describes no such feature. Every option can still be narrowed with database grants, below. Scroll sideways on a small screen.

01Before any of them

A login that can only read

The one control every option shares is the database login. OWASP's guidance for AI tools is the same: give the extension only the permissions it needs, and don't let a read-only extension connect with an identity that can also write.[17] In PostgreSQL:[18][19][20]

-- Run as an administrator. Replace the names in angle brackets.
CREATE ROLE claude_ro WITH LOGIN PASSWORD '<a new password>';
GRANT CONNECT ON DATABASE <your_db> TO claude_ro;
GRANT USAGE ON SCHEMA <your_schema> TO claude_ro;

-- Every table and view in the schema, or list only the ones Claude needs:
GRANT SELECT ON ALL TABLES IN SCHEMA <your_schema> TO claude_ro;
-- Or columns only:  GRANT SELECT (id, region, total) ON <table> TO claude_ro;

-- Tables the owner creates later:
ALTER DEFAULT PRIVILEGES FOR ROLE <table_owner> IN SCHEMA <your_schema>
  GRANT SELECT ON TABLES TO claude_ro;

-- A backstop, not the control: sessions start read-only, but a session can change it.
ALTER ROLE claude_ro SET default_transaction_read_only = on;

ALTER DEFAULT PRIVILEGES covers only tables created later by the role you name.[19] A read-only transaction stops INSERT, UPDATE, DELETE, DDL and similar commands, but PostgreSQL calls it “a high-level notion of read-only that does not prevent all writes to disk”.[21] PostgreSQL also warns that a password set in SQL may be written to logs; psql's \password avoids that.[20] In MySQL:[22]

CREATE USER 'claude_ro'@'%' IDENTIFIED BY '<a new password>';
GRANT SELECT ON <your_db>.* TO 'claude_ro'@'%';
-- Or columns only:  GRANT SELECT (id, region, total) ON <your_db>.<table> TO 'claude_ro'@'%';

02Four questions

What to ask of any option

Where does the password live?

Local servers keep it in your AI app's config file or an environment variable.[1][4][5]Vendor-hosted servers replace it with a sign-in to the vendor.[8][11][13]Tailscale's guide advises keeping passwords out of shared config files.[23]

What actually stops a write?

A check in the server can be bypassed: the archived reference server wrapped queries in a read-only transaction, and a string with a second statement ended it.[3] DBHub's own docs call its read-only mode a guardrail, not a permission boundary.[6] The login's grants are the boundary.

What does the AI see, and who can steer it?

Whatever a query returns goes into the chat. In 2025 a crafted support ticket led an agent using the Supabase server to read a secrets table and write it back into the ticket.[9] Simon Willison calls the mix of private data, untrusted content and a way to send data out the “lethal trifecta”.[10] Claude's own help pages warn that custom connectors reach servers Anthropic hasn't verified.[16]

Will you know what it ran?

Few keep a lasting record a user can read. Toolbox emits traces, PlanetScale tags queries for its Insights view, and DBHub lists recent requests in memory until it restarts.[7][13][5]

03Where Portward fits

What Portward does, and what it doesn't

Portward is a hosted Claude connector for PostgreSQL and MySQL databases on the internet. The password is typed on a Portward page, not in the chat or a config file. Each query is parsed to exactly one SELECT and run in a read-only transaction; administrator logins are refused. Columns you keep from Claude never reach it, and the panel shows a receipt of what Claude got. Its AI log keeps what Claude was sent, sealed, for 30 days.

The trade-off: Portward runs the engine that reads your database, so Portward can technically see what passes through it, and anything Claude receives goes to Anthropic like the rest of the chat. Use the read-only login above with Portward too. Portward holds your account email, your database login (sealed to your engine's key), your rules and notes, the questions and SQL your AI ran, receipts and usage counts, and the AI log of what the AI was sent. Rows pass through your engine to the AI and are not stored by Portward, except in that AI log, which deletes them after 30 days, and in the results panel, which deletes them after 24 hours. Your engine is separate from every other account's. How Portward works.

Sources

Each read on . First published .

  1. [1]modelcontextprotocol/servers-archived: Postgres
  2. [2]npm registry: @modelcontextprotocol/server-postgres, latest version (its deprecated notice)
  3. [3]Datadog Security Labs: SQL injection in the PostgreSQL MCP server
  4. [4]crystaldba/postgres-mcp (Postgres MCP Pro)
  5. [5]bytebase/dbhub
  6. [6]DBHub: read-only mode
  7. [7]googleapis/mcp-toolbox (MCP Toolbox for Databases)
  8. [8]Supabase: Model context protocol (MCP)
  9. [9]General Analysis: Supabase MCP can leak your entire SQL database
  10. [10]Simon Willison: Supabase MCP and the lethal trifecta
  11. [11]Neon: Neon MCP Server
  12. [12]neondatabase/mcp-server-neon
  13. [13]PlanetScale: MCP server
  14. [14]Claude Help Center: upload files to Claude
  15. [15]Claude Code docs: permissions
  16. [16]Claude Help Center: get started with custom connectors using remote MCP
  17. [17]OWASP LLM06:2025 Excessive Agency
  18. [18]PostgreSQL docs: GRANT
  19. [19]PostgreSQL docs: ALTER DEFAULT PRIVILEGES
  20. [20]PostgreSQL docs: ALTER ROLE
  21. [21]PostgreSQL docs: SET TRANSACTION
  22. [22]MySQL 8.4 Reference Manual: GRANT
  23. [23]Tailscale: Postgres MCP