Is a Managed Warehouse MCP Server Safe to Give an AI Agent? Least Privilege and Cost Limits
Read-only access stops writes, not expensive queries or data leaks, so the limits belong in the warehouse
A managed MCP server for Snowflake, BigQuery or Databricks is safer than handing an agent a shared login, but it is not safe by default. A guide to warehouse MCP servers sums it up as "Safer, not safe": read-only access blocks writes, yet an agent can still run expensive queries and read data it should never forward. The fix is a dedicated identity with minimal grants plus spend limits enforced inside the warehouse, never in the prompt.
Key Takeaways
- •Read-only is not harmless: an agent that cannot write can still scan huge tables, run many queries per question, and read data that an injected instruction asks it to forward.
- •Give the agent its own service identity with no permissions at first, then add access one object at a time. Never reuse a personal or shared account.
- •Cost caps must live in the warehouse: Snowflake resource monitors, a BigQuery maximum bytes billed setting, and statement timeouts all hold even if the agent misbehaves.
- •The MCP specification's own security guidance says to start with a minimal scope set and elevate only when a privileged operation is first attempted.
- •Log every agent query under the agent's identity so a cost spike or a data read can be traced to a specific question.
Why read-only access is not the same as safe
Teams often treat a read-only role as the finish line. It removes one failure mode, accidental writes, and leaves the other two untouched. The first is cost: an agent does not know what a terabyte scan costs, and it will happily issue a wide query to answer a narrow question. The second is exposure: an agent that can read a table can be steered to read it, summarize it and pass it along. The guide above notes that injected instructions in tool descriptions or returned rows can drive exactly that behavior.
The same guide makes a cost point that is easy to miss. An agent might issue about six queries where an analyst would write one, and that multiplier hits warehouse compute far harder than it hits token spend. Your model bill is the small number. The credits or bytes scanned by those six queries are the large one, and they land on the warehouse invoice with no label saying an agent caused them.
So the question to ask before connecting is not whether the server is read-only. Ask three things instead: whose identity does it run as, which objects can that identity see, and what stops a single question from becoming an expensive one. Each has a warehouse-side answer, and each is covered in the steps below.
Step 1: give the agent its own identity with no permissions
Create a dedicated service identity for the agent. Do not reuse an engineer's login, and do not reuse a shared analytics role that grew over years. A personal account carries every grant its owner ever received, so the agent inherits access nobody consciously chose for it. A dedicated identity also makes the audit trail legible: every query in the warehouse history is attributable to the agent, not blended into human activity.
Start that identity with nothing. Add access one object at a time: one schema, one view, one table, as each question the agent needs to answer demands it. This feels slow for the first week and then pays for itself, because the grant list becomes a written record of what the agent is allowed to know. The guide we cited recommends the same approach and puts it bluntly: enforce it at the identity, never in the prompt.
Prefer views over base tables where you can. A view that already drops PII columns, or masks them, means the agent never holds the raw data, and no prompt injection can extract what the identity cannot select. The three managed servers differ in how they scope access: Snowflake lets you define exactly which tools a server exposes, BigQuery uses one endpoint controlled by IAM, and Databricks hosts several servers with their own OAuth scopes and Unity Catalog grants.
Step 2: apply least privilege at the MCP layer too
Warehouse grants are the floor, but the MCP layer has its own scope design. The MCP security best practices page has a section on scope minimization, and it names the failure plainly: a token carrying broad scopes such as db:* or admin:* expands the blast radius if it leaks, makes revocation painful and muddies the audit trail.
The recommended pattern is progressive: a minimal initial scope set containing only low-risk discovery and read operations, then incremental elevation when a privileged operation is first attempted. The page also lists common mistakes worth checking your server against, including publishing every possible scope, using wildcard or omnibus scopes, and bundling unrelated privileges to avoid future prompts.
Connect fewer servers, too. The warehouse guide suggests limiting a client to two or three connected servers. Each server adds tool descriptions the model reads, and tool descriptions are an injection surface. If your Snowflake server exposes both a semantic tool and raw SQL, keep them on separate servers so a client cannot bypass the semantic layer by choosing the raw tool.
Step 3: cap spend inside the warehouse
On Snowflake, put the agent on its own warehouse and attach a resource monitor. According to the Snowflake resource monitor docs, a monitor can hold one Suspend action, one Suspend Immediate action and up to five Notify actions, each a percentage of a credit quota, and it can be assigned up to 500 warehouses. Set a notify at a low percentage, a suspend near the quota, and a suspend-immediate above it, so a runaway question is cancelled instead of finishing.
Two caveats from the same docs matter for agents. Resource monitors work for warehouses only, so serverless and AI services need a budget instead. And quotas reset on a schedule, at 12:00 AM UTC, so choose a daily frequency for an agent warehouse rather than monthly. A monthly quota lets an agent burn the whole allowance in one afternoon before anyone notices.
Add a statement timeout on the agent's warehouse or role as well. The Snowflake parameters reference says the statement timeout parameter has a default of two days, which is far too generous for an interactive agent. Set it to minutes. A question that cannot be answered in a few minutes is a question a human should look at before more compute is spent on it.
Step 4: cap bytes scanned on BigQuery and Databricks
BigQuery bills on-demand queries by bytes processed, so the control is a ceiling on bytes. The BigQuery cost best practices explain that when you set maximum bytes billed, the bytes a query reads are estimated before it runs, and if the estimate exceeds the limit the query fails without incurring a charge. The docs also note that the minimum billed per referenced table is 10 MiB, so set the cap well above that.
That same page describes custom quotas, which set a daily limit on data processed per project or per user. Use both: a per-query ceiling stops one bad query, and a daily quota on the agent's project stops a thousand mildly bad ones. One caution from the docs is that the estimate for clustered tables is an upper bound, so a query can fail even when its real cost would have fit under the limit. Treat that as the safe direction to be wrong.
On Databricks, the equivalent levers are Unity Catalog grants for what the agent can read and a compute choice for what it can spend: give it a small, auto-terminating SQL warehouse with its own budget tag. We have not found a single per-query byte ceiling there that matches BigQuery's, so rely on warehouse size, auto-stop and tags, and check the current documentation for your workspace.
Step 5: log, attribute and review what the agent ran
Caps limit damage; logs tell you whether the caps are set correctly. Because the agent has its own identity, you can query the warehouse's query history filtered to that identity and answer simple questions weekly. Which queries scanned the most data? Which tables were touched that nobody expected? How many queries did each user question trigger? Those numbers tell you whether the agent is drifting toward waste or toward objects outside its intended scope.
Treat the first month as calibration. Start with tight caps and a short statement timeout, watch what the agent legitimately needs, and loosen one limit at a time with a written reason. A cap that is never hit may be too loose, and a cap that fires daily is either too tight or pointing at a question that needs a better view or a semantic definition behind it.
This is where the swarm approach helps. Our Connectors Agent handles warehouse access through MCP and chains with governance, so grants and masking policies are checked as part of the connection. Our Cost Agent watches spend per identity and flags a query pattern that is drifting before the invoice does. Both read first by default, and the OSS edition stays read-only.
A pre-connection checklist
- •A dedicated service identity exists, with no inherited grants and a named owner.
- •Access is granted object by object, preferably through views that already mask PII.
- •The MCP server exposes the smallest tool set that answers the target questions, with raw SQL on a separate server if it is needed at all.
- •The agent runs on its own warehouse or project with a resource monitor, byte ceiling or daily quota, and a statement timeout measured in minutes.
- •Query history for the agent identity is reviewed on a schedule, and every loosening of a limit has a written reason.
Frequently Asked Questions
Is a read-only MCP server safe for an AI agent?
It is safer, not safe. Read-only blocks writes, but the agent can still run costly scans and read sensitive data that an injected instruction asks it to forward. Pair read-only with a dedicated identity, minimal grants, views that mask PII, and warehouse-side cost caps so that neither money nor data can leave in bulk through a single question.
Where should cost limits be enforced for an AI agent?
Enforce them in the warehouse, not in the prompt. A prompt can be ignored, overridden by injected text or simply misread, while a Snowflake resource monitor, a BigQuery maximum bytes billed setting or a statement timeout applies to every query regardless of what the agent intended. Use the agent's own warehouse or project so the limits apply only to it.
Should an agent reuse an engineer's credentials?
No. A personal account carries every grant its owner has accumulated, and its queries are indistinguishable from human work in the audit trail. A dedicated service identity starts with zero permissions, accumulates only what you approve and makes every query attributable to the agent, which is what makes both cost review and incident investigation possible.