guide
guide8 min read

MCP Server Read Only Snowflake BigQuery Cost Cap: A Step-by-Step Setup

Enforce read-only access and spend limits in the warehouse, not in the agent prompt

To make a warehouse MCP server read-only with a cost cap, enforce both limits in the warehouse itself: a role that holds only SELECT-level grants, plus a spend limit the warehouse applies on its own (a resource monitor and statement timeout on Snowflake, a maximum bytes billed setting and custom quotas on BigQuery). A read-only flag in the MCP server config is a convenience. It is not a control, because the credential behind it can still do whatever its grants allow.

Key Takeaways

  • •Read-only is a property of the database role and service account, not of the MCP server. If the credential can write, a misconfigured or compromised server can write.
  • •On Snowflake, create a dedicated role with USAGE and SELECT only, and attach a resource monitor and a statement timeout to the warehouse that role uses.
  • •On BigQuery, grant dataset-level read access plus job-creation rights, and set maximum bytes billed on every query job so a bad scan fails instead of billing.
  • •BigQuery on-demand pricing bills by bytes scanned and Snowflake bills by warehouse compute time, so the two platforms need different cost caps.
  • •Test the limits by trying to break them: run a write, run an unbounded scan, and confirm the warehouse rejects both.

Why an MCP server read only Snowflake BigQuery cost cap must live in the warehouse

An MCP server is a process that exposes tools to a model. The MCP specification defines how clients and servers exchange those tools, but it does not decide what your database credential is allowed to do. That decision sits with the warehouse. Practitioner guides on this topic make the same point: enforce read-only through grants, avoid hardcoded tokens, and remember that BigQuery bills by bytes scanned.

There are three failure modes we see teams plan for badly. First, a server with a "read-only" option that only filters SQL by string matching, which a creative statement can bypass. Second, a shared admin token pasted into an MCP config file that ends up in a repository. Third, a harmless-looking SELECT with no partition filter that scans a multi-terabyte table. A coding agent in Claude Code or Cursor will run exactly the query it is asked to run, so the guardrails have to exist before the first prompt.

The approach below is our opinion on a sane baseline, not a compliance standard. It takes about an hour per warehouse and works with any MCP server that connects with a normal database credential.

Step 1: Create a dedicated read-only identity for the MCP server

Never reuse a human or admin credential. Create one identity per MCP server so you can revoke it, audit it and size its limits independently.

On Snowflake, create a role such as MCP_READONLY and a service user assigned to it. Prefer key-pair or OAuth authentication over a password, and keep the secret in your secrets manager or environment rather than in the MCP client config. On BigQuery, create a dedicated service account. If you can avoid long-lived JSON keys, use service account impersonation or workload identity instead of downloading a key file.

Name the identity after its purpose. When it shows up in query history or audit logs, svc_mcp_readonly tells the reviewer who ran the query and why.

Step 2: Grant read access only, at the narrowest scope

On Snowflake, grant USAGE on the warehouse, database and schemas, then SELECT on the tables and views the agent needs. Add SELECT on future tables only for schemas you are happy to expose automatically. Do not grant OWNERSHIP, INSERT, UPDATE, DELETE, CREATE or MODIFY on anything. Snowflake's access control documentation explains how privileges and role hierarchy interact, and the important rule is that a role inherits everything granted to roles beneath it, so check the hierarchy before assigning.

On BigQuery, the usual pair is a data viewer role on the specific datasets (not the whole project) and the job user role on the project so the account can run query jobs. Data viewer lets the account read table data. Job user lets it create jobs and bill them to the project. Neither lets it modify tables. Avoid the project-level editor and owner roles for this account.

Also decide about sensitive columns now. If the agent should not see PII, use masking policies or authorized views rather than hoping the prompt stays on topic. Read-only does not mean safe to read.

Step 3: Cap Snowflake spend with a resource monitor and timeouts

Snowflake bills warehouse compute in credits, so the cap is a credit budget plus a runtime limit. Put the MCP server on its own warehouse, sized small, with a short auto-suspend. A dedicated warehouse lets you cap agent spend without throttling your scheduled pipelines.

Then create a resource monitor with a monthly or daily credit quota and triggers that notify at a lower threshold and suspend the warehouse at the limit. Assign it to the MCP warehouse. Two caveats from the Snowflake documentation model: monitors track credit usage with some lag, so a long-running query can overshoot, and a suspend action stops the warehouse for everyone using it, which is another reason to isolate the agent.

Close the overshoot gap with STATEMENT_TIMEOUT_IN_SECONDS on the warehouse or the role's user, for example a few minutes for exploratory queries. Snowflake documents this in its parameters reference. Together, the monitor limits total spend and the timeout limits any single runaway statement.

Step 4: Cap BigQuery spend with maximum bytes billed and quotas

BigQuery on-demand billing is driven by bytes processed, so the most direct cap is the maximum bytes billed setting on the query job. If a query would exceed it, BigQuery fails the job and does not bill for it. Google documents this under controlling query costs. Set it in the MCP server's query call, or in whatever client library the server wraps, to a value that fits your largest legitimate question. A limit in the low hundreds of gigabytes is a common starting point for exploration, though the right number depends on your tables.

A per-job cap does not stop an agent from running many medium queries. Add a project or user level daily quota for query bytes through BigQuery's custom quotas, and put the agent in its own project if you want a hard budget boundary. Partition and cluster large tables, and require a partition filter where it makes sense, so the cheap query is also the natural one.

Have the server run a dry run first when it can. A dry run reports the bytes a query would process without executing it, which lets the agent (and you) see the cost before committing.

Step 5: Verify the limits by trying to break them

Configure the MCP server with the new credentials and run a short adversarial checklist from your terminal or editor. Each test should fail in the warehouse, with a warehouse error message, not in the MCP layer.

  • •Ask the agent to create a table, insert a row and drop a view. All three should return a permission error.
  • •Ask it to select from a table outside the granted schemas. It should fail with an authorization error.
  • •Run a deliberately wide scan on BigQuery. The job should fail with a bytes-billed-exceeded error.
  • •Run a long cross join on Snowflake. The statement should be cancelled at the timeout.
  • •Check query history and audit logs. Every statement should be attributed to the dedicated service identity.

Keep this checklist in the repository next to the grants script, and rerun it whenever grants change. Drift is common: someone adds a role to a role, and the read-only account quietly becomes more than read-only.

Where the controls differ between Snowflake and BigQuery

ControlSnowflakeBigQuery
Read-only enforcementRole with USAGE and SELECT grants onlyDataset-level data viewer plus project job user
What drives costWarehouse compute time (credits)Bytes processed per query (on-demand)
Per-query limitStatement timeoutMaximum bytes billed on the job
Aggregate limitResource monitor on the warehouseCustom quota on a project or user
Isolation boundaryDedicated warehouse for the agentDedicated project for the agent

The table is why one generic cost setting in an MCP server falls short. A seconds-based timeout does nothing for a BigQuery scan that finishes quickly but reads a lot of data, and a bytes cap does nothing for a Snowflake query that burns credits on a slow join.

How Data Workers handles this

Every Data Workers agent is an MCP server, and the open-source edition runs locally and is read-only by default. That default is a second layer, not a replacement for the grants above. Our Connectors Agent talks to Snowflake, BigQuery, Databricks and other systems with whatever credential you give it, so we recommend giving it the read-only identity from Step 2.

Writes, additional enterprise connectors, approval workflows and audit trails arrive in Pro. When you do need an agent to change something, we think the right model is explicit approval per action with an audit record, not a broader standing grant. Our Cost Agent is the part of the swarm that watches for the waste these caps are meant to prevent, such as idle warehouses and oversized scans, and it can answer questions like "How much are we spending on Snowflake this month?" from the same read-only access.

We covered how agents share context across governance, quality and pipelines in other posts on this site. The short version: a cost cap that knows nothing about governance will happily let an agent read a PII column cheaply, so we treat access policy and spend policy as one problem.

Frequently Asked Questions

Is a read-only flag in an MCP server enough? No. A flag that blocks write statements inside the server only protects against the cases its authors anticipated, and it does nothing if the server is replaced, misconfigured or bypassed. Enforce read-only with warehouse grants so the database itself refuses writes, and treat the server flag as an extra layer.

How do I stop an AI agent from running up a BigQuery bill? Set maximum bytes billed on every query job so oversized scans fail without charge, add a daily custom quota on the project, partition and cluster large tables, and run the agent in its own project so its spend has a clear boundary. A dry run before execution lets the agent see the estimated bytes first.

Do Snowflake resource monitors stop a query immediately? Not necessarily. Monitors track credit consumption with some delay, so a long-running statement can exceed the quota before the suspend takes effect. Pair the monitor with a statement timeout so a single query cannot run indefinitely.

Should the MCP server use my personal credentials? No. Use a dedicated service identity with its own role or service account, short-lived credentials where the platform supports them, and secrets stored outside the MCP client config file. A dedicated identity makes revocation, auditing and cost attribution straightforward.

Does read-only mean the agent cannot see sensitive data? No. A read-only role can still select PII columns it has been granted. Use masking policies, row-level policies or authorized views to restrict what the identity can read, and review who has access to PII columns before connecting any agent.