New: one score for how consistent your answers are. See more

How to give Claude or ChatGPT read-only access to production data

July 17, 2026•Updated November 21, 2026•9 min read•Vivek Sah
Jump to a section

"Clean up the test rows in orders." It's a normal thing to ask an assistant that's connected to your database, and if the database user behind it can write, it's one DELETE away from production data. We asked it on our demo warehouse.

Demo on Contextflo, which connects Claude and ChatGPT to your company data with per-person table access. Here Claude is connected to a demo BigQuery warehouse through Contextflo's read-only connection.

Short answer: yes, you can let Claude or ChatGPT query your production database, if you set up two gates. One is a database user that can only read. The other is a connection layer that only lets read queries through. In the video, Claude turned down the vague cleanup and the explicit DELETE because the connection only runs reads.

Here Claude didn't even try, because the connection tells it it's read-only. The point of the two gates is what happens if it does.

Check your setup against these seven:

Is your Claude database connection actually safe?
0 of 7
Even for a solo setup
For a team
Give Claude database access without managing the security layer yourself.
See the full setup for a team: read the Data Lead Guide

Why isn't a prompt enough?

"Clean up the test rows" doesn't say which rows count as test, or whether cleanup means delete, archive or flag. A model trying to be helpful can resolve that to a DELETE. Putting "never modify data" in the system prompt steers it, but the permission is still sitting there, and one confused turn or one pasted query can use it. Protection means the write can't run, whatever the model decides.

Gate one: a database user that can only read

Give the AI its own identity. Never reuse your app's credentials just because they're already in a config file; those almost always have write access. On Postgres it's three lines:

CREATE ROLE claude_readonly LOGIN PASSWORD 'a-long-random-password';
GRANT USAGE ON SCHEMA public TO claude_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO claude_readonly;

Tables created later need ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO claude_readonly; as well.

Calling a user readonly doesn't make it read-only, so verify it. Connect as that user and try CREATE TABLE ai_write_test (id int); and an UPDATE on a real table. Both should fail with a permission error. If either works, the user is picking up rights from somewhere else, like a role it inherits or default grants on the schema.

If you use a coding agent with shell access, this gate matters most. An agent that can run psql can use whatever credentials it finds in a .env file or your shell history, and that path never touches an MCP server, so no MCP guard sees it. The database user is the one gate it can't route around.

Gate two: what does your MCP server do by default?

Your MCP server is the connection layer, so its default decides whether gate two exists. Claude and ChatGPT both connect through an MCP server, so this applies to either. The database user is your decision. The MCP server's default is the vendor's, and vendors don't agree. We checked the current docs and source for five official servers on November 19, 2026.

MCP serverWrites by default?Keep it read-only
Google BigQueryYesUse execute_sql_readonly
Databricks SQLYesSet disallow_writes: true
AWS Redshift (awslabs)NoLeave ACCESS_MODE unset
mcp-clickhouseNoLeave the write and drop flags unset
server-postgres (archived)BypassableDon't use it

Google BigQuery MCP server

Google lists execute_sql as the one tool that isn't read-only (Source: Google Cloud: Use the BigQuery MCP server, https://docs.cloud.google.com/bigquery/docs/use-bigquery-mcp). Use execute_sql_readonly, which rejects DML, DDL and Python UDFs, or block execute_sql with an IAM deny policy. Connect as an identity with MCP Tool User, BigQuery Data Viewer and BigQuery Job User only.

Databricks SQL MCP server

It "permits reads and writes by default" (Source: Databricks: Databricks SQL MCP server, https://docs.databricks.com/aws/en/agents/mcp-tools/databricks-sql). Set disallow_writes to true in the built-in system.ai.dbsql_policy policy.

AWS Redshift MCP server (awslabs)

Each query runs inside BEGIN READ ONLY and is rolled back, and a deny-list blocks statements such as UNLOAD, GRANT and TRUNCATE. Writes need ACCESS_MODE=read-write, so leave it unset (Source: AWS Labs: Redshift MCP server README, https://github.com/awslabs/mcp/tree/main/src/redshift-mcp-server).

mcp-clickhouse

Queries run with readonly=1 unless you set CLICKHOUSE_ALLOW_WRITE_ACCESS=true, and drops need CLICKHOUSE_ALLOW_DROP=true as well. The README calls the server's destructive-operation check "not a security boundary" and says the boundary is the ClickHouse user's grants (Source: ClickHouse: mcp-clickhouse README, https://github.com/ClickHouse/mcp-clickhouse).

@modelcontextprotocol/server-postgres (archived)

Its read-only guard can be bypassed. A stacked query like COMMIT; DROP SCHEMA public CASCADE; ends the read-only transaction and runs the rest with the role's full privileges (Source: Datadog Security Labs: SQL injection in the Postgres MCP server, https://securitylabs.datadoghq.com/articles/mcp-vulnerability-case-study-SQL-injection-in-the-postgresql-mcp-server/). It was archived and deprecated in 2025 (Source: Model Context Protocol: archived reference servers, https://github.com/modelcontextprotocol/servers-archived), yet still pulled about 154,000 npm downloads in the week of November 12-18, 2026 (Source: npm: @modelcontextprotocol/server-postgres, https://www.npmjs.com/package/@modelcontextprotocol/server-postgres). Use a maintained server from our Postgres MCP comparison instead.

Whatever the server does, the database user is the real boundary. Connect every one of these as a read-only identity, like the user from gate one.

Setting one up? Each guide creates the read-only user and connects it, step by step: BigQuery, Snowflake, Databricks, Postgres, ClickHouse, Redshift.

Why keep both gates?

What goes wrongWhat still stops the write
The MCP server's guard is bypassed, like the archived Postgres serverThe database user has no write grant
Someone points the connection at a credential with write accessThe connection layer only passes reads
A coding agent runs psql directly and skips MCPThe database user, and nothing else
The model misreads an ambiguous askBoth

How do you make a rejected write visible?

A write that fails silently teaches nobody anything. The person asking should see plainly that nothing changed, the way Claude said "I can't delete rows from the orders table. I can find the test rows for you" in the video. The admin should see the attempt: who asked, what they asked for and what actually ran. If rejected queries just disappear, you never find out the AI tried.

Contextflo activity log entry: the user prompt asks Claude to run DELETE FROM contextflo-demo.rungear.orders WHERE customer_id = 'test', and the LLM reasoning reads 'User asked to run a DELETE; execute-query is SELECT-only, so preview which rows the DELETE would affect instead', next to a 1-row BigQuery query
What the admin sees in Contextflo's activity log: the DELETE someone asked for, why Claude didn't run it, and the count query it ran instead.

Can read-only queries still hurt production?

Yes. A read can be a full scan over a billion rows or an accidental cross join, and against your primary that slows real traffic. Four things for even a personal setup:

  1. Point the AI at a read replica if you have one.
  2. Set a statement timeout on its user, so a runaway query gets killed. On Postgres: ALTER ROLE claude_readonly SET statement_timeout = '30s';
  3. On warehouses that bill per query, cap the spend, with maximum bytes billed on BigQuery or a resource monitor on Snowflake.
  4. Grant only the schemas it needs, not the whole database.

What changes before you invite colleagues?

Once a second person uses the connection, read-only stops being the whole question. Picture a teammate asking "What are the salaries of everyone on the sales team?" Nothing gets written. Every step is a read. If the connection can reach the HR schema, Claude answers it.

ControlJust youA team
Table scopeYou can see everything anywayEach person sees only the tables they should
Sign-inOne credential on your machineEach person signs in as themselves, so offboarding revokes one account instead of rotating a shared password
Query logNice to haveNeeded to trace a wrong number back to the SQL and the person who asked
What reaches the modelCommercial plans don't train on your dataOnly the schema and rows the asking person is allowed to see
Your team wants answers from Claude. You shouldn't have to give everyone database credentials.
Give your team access without sharing the password

How can I build both gates?

Doing this by hand works for one person and one database. Once your team needs answers from BigQuery, Postgres and a few SaaS tools, it turns into a role per person per source and a log in every system. We built Contextflo so a team can manage it in one place: one read-only connection per source, central access control across all of them, and one audit log.

ControlWhat Contextflo does
Table access per personAdmins put people in groups and give each group the tables it can query. A query touching any other table is denied before it runs, and the user is told who can grant access.
Individual sign-inEach person connects Claude or ChatGPT to Contextflo and signs in as themselves. The database password stays in Contextflo, never on anyone's laptop. Removing someone from the workspace removes their access.
Activity logEvery question, the SQL it ran and who asked it is kept in the activity log, including after the person leaves.

You still create the read-only user for each source, pointed at a replica if you have one. Contextflo adds the second gate: it rejects anything that isn't a read before it reaches your database.

The full end-to-end setup, from the read-only user to rolling it out to a team, is in the Data Lead Guide.

Table access in the app, on demo data: a Support group gets nine tables and one uploaded file, then a support agent is added.

Connect your database to Claude

Have the read-only user from gate one and your database host ready, and give it about 10 minutes. After you click, you create a workspace, enter the connection details, pick the tables Claude can see, and add Contextflo as a connector in Claude or ChatGPT.

Creating the read-only user: BigQuery · Postgres · Snowflake · all databases

Free for one user and one data source.
Connect your database to Claude with controlled access

Setting this up for a team? Book 20 minutes and we'll go through your database, who needs access and the controls.

FAQ

Is it safe to give Claude read-only access to your production database?

Yes, with two gates: a database user that only has SELECT, and a connection layer that only passes read queries. Point it at a read replica with a statement timeout and it can't slow production either. For a team you also want scoped table access, individual sign-in and a query log.

Can Claude delete or change my data with read-only access?

Not if the database user has no write grants. The model can ask for a DELETE, but the database refuses it. A second read-only check in the connection layer catches the case where someone swaps in a credential with more access.

Can ChatGPT access my database read-only?

Yes. ChatGPT connects to a database through an MCP server, the same way Claude does, so the same two gates apply: a read-only database user underneath and a connection layer that only runs reads.

Does read-only access make the connection fully secure?

It's necessary but not sufficient. Read-only stops writes, but it doesn't scope who sees which tables, handle credentials or log queries. For a team you need those too.

Can Claude delete data in BigQuery or Databricks?

It can if the MCP server and the identity behind it allow writes. Google's BigQuery MCP server exposes execute_sql, which isn't read-only, and the Databricks SQL MCP server permits writes by default until you set disallow_writes in system.ai.dbsql_policy. Connect with a read-only identity and use the read-only tool or policy.

Do Claude or ChatGPT train on data they query?

Not under the commercial terms of Anthropic or OpenAI on API, Team and Enterprise plans. On consumer plans, review the data settings. A governed layer also limits what reaches the model to what the asking user is allowed to see.