What Read-Only Permissions Does a Snowflake MCP Text-to-SQL Server Need?
A role, grant and limit walkthrough for giving an agent SELECT access and nothing else
A Snowflake MCP text-to-SQL server needs one dedicated role with USAGE on a single warehouse, USAGE on the database and schemas it reads, and SELECT on the tables and views in those schemas. Nothing more. Snowflake's access control privileges reference documents each of these as a separate grant, which means read-only is something you build explicitly rather than a mode you switch on. The rest of this post gives the exact statements, the limits that keep a read-only agent from running up credits, and what the role cannot protect.
Key Takeaways
- •Read-only for an agent means a role that holds only USAGE and SELECT privileges. Do not rely on a prompt, or on an SQL filter inside the MCP server, to enforce it.
- •Grant SELECT on specific schemas, not on every schema in the account. Add FUTURE grants so new tables are readable without widening the role by hand.
- •A read-only role can still run expensive queries. Snowflake's default statement timeout is 172,800 seconds (two days), so set a short timeout and a resource monitor on the agent's warehouse.
- •SELECT on a table exposes every column in it. Use masking policies on PII columns before the agent's role can see them.
- •Give the agent its own service user and query tag so every query it runs can be found in the audit views.
Why read-only is a grant question, not a prompt question
The usual first attempt at making a text-to-SQL agent safe is an instruction: only write SELECT statements. That instruction lives in the model's context, and anything that lives in context can be overridden by a bad retrieval, a confused plan or a prompt injection hidden in a table comment. The MCP specification's tools section says clients should treat tool annotations as untrusted unless they come from a trusted server, and it expects a human in the loop for sensitive calls. The warehouse is the only place a boundary cannot be talked around.
A recent Show HN for a Snowflake MCP server with a text-to-SQL agent drew exactly this question in its discussion thread, where the author addressed SELECT grants on all schemas. We read that as the right instinct. The question people ask is which grants the agent should hold, and a grant list is something you can review, diff and revoke, which a prompt is not.
An SQL allowlist inside the MCP server, such as rejecting anything that does not start with SELECT, is still worth having as a second layer. It catches mistakes early and gives the model a clean error message. Treat it as a convenience, though. If the role behind the connection can drop a table, then a parsing bug in the server is the only thing standing between the agent and that table.
Step 1: Create a dedicated role and service user
Start with an identity that nothing else uses. Create the role with CREATE ROLE mcp_readonly; and a service user with CREATE USER mcp_agent TYPE = SERVICE DEFAULT_ROLE = mcp_readonly;, then GRANT ROLE mcp_readonly TO USER mcp_agent;. Authenticate it with a key pair rather than a password, and keep the private key in the secret store your MCP host already uses. Do not point the server at a human's login, because that user's role set decides what the agent can do.
Set the default role explicitly and give the user no other roles. Snowflake sessions run under the active role, and a user who holds several roles can switch between them with USE ROLE. If the service user also held a broader role, a single injected statement could use it. The cleanest check is SHOW GRANTS TO USER mcp_agent;, which should return exactly one row.
Never run the server as ACCOUNTADMIN, SYSADMIN or any role that owns objects. Ownership implies the right to drop and alter, and no later REVOKE on a SELECT grant takes it away. Keep the role out of the PUBLIC role's inheritance chain too, and do not grant it to other roles. Its permissions should be readable in one short query.
Step 2: Grant USAGE and SELECT on only what the agent should read
Snowflake requires USAGE on every container above a table before SELECT does anything. The minimal set for one schema is GRANT USAGE ON DATABASE analytics TO ROLE mcp_readonly;, GRANT USAGE ON SCHEMA analytics.gold TO ROLE mcp_readonly; and GRANT SELECT ON ALL TABLES IN SCHEMA analytics.gold TO ROLE mcp_readonly;. Repeat the last line for ALL VIEWS if the schema exposes views. The full syntax is in the GRANT privilege reference.
Existing-object grants do not cover tables created tomorrow. Add GRANT SELECT ON FUTURE TABLES IN SCHEMA analytics.gold TO ROLE mcp_readonly; and the matching FUTURE VIEWS grant so new gold tables become readable without a ticket. This is where scope creep starts, so be careful with the level you pick. A future grant at the database level covers every schema in it, including staging schemas that hold raw PII. Granting at the schema level keeps the decision with the people who curate that schema.
Prefer a short list of curated schemas, usually the gold or marts layer, over SELECT on everything. Agents that see raw landing tables write plausible but wrong joins against them, and they surface columns nobody meant to expose. A smaller surface also makes the answers better. Our Insights Agent grounds text-to-SQL in the semantic layer for the same reason: fewer, better-described tables produce fewer wrong queries.
Step 3: Bound the warehouse with size, timeout and a credit cap
Read-only access stops writes. It does not stop cost. A model can write a cross join over two large fact tables and keep a warehouse busy for hours. The Snowflake parameters reference lists a default STATEMENT_TIMEOUT_IN_SECONDS of 172,800 seconds, which is two days. For an interactive agent that default is far too generous, so override it on the agent's own warehouse.
Create a warehouse used only by the agent: CREATE WAREHOUSE mcp_wh WAREHOUSE_SIZE = 'XSMALL' AUTO_SUSPEND = 60 AUTO_RESUME = TRUE STATEMENT_TIMEOUT_IN_SECONDS = 60;. Then grant only USAGE on it, never OPERATE or MODIFY, so the agent cannot resize or resume it at will. Set a matching STATEMENT_QUEUED_TIMEOUT_IN_SECONDS so a backed-up queue does not stack up agent queries. Sixty seconds is an example. Choose a value from the slowest legitimate question your analysts ask.
Add a hard stop with a resource monitor. The CREATE RESOURCE MONITOR reference covers credit quotas and triggers: set a monthly quota, notify at a lower threshold and suspend at 100 percent, then attach it with ALTER WAREHOUSE mcp_wh SET RESOURCE_MONITOR = mcp_cap;. Creating a monitor needs account-level rights, so an administrator does this once. Size the quota to what you would be comfortable losing in a bad week.
Step 4: Mask sensitive columns before the agent can see them
SELECT on a table is SELECT on every column in it. If analytics.gold.customers carries email and phone number, the agent can return both in an answer that lands in a chat window or a log. Column-level grants are not available for tables in the way people expect, so the control is a masking policy attached to the column. The policy decides, per role, whether the value is clear, partially hidden or fully redacted.
Write the policy so that the default branch is redaction and only named roles see clear text. For the agent's role, return a hash or a fixed string. A hash keeps the column useful for joins and counts of distinct customers, which covers most analytical questions. This is also the point where the question 'Who has access to PII columns in analytics?' should have a one-query answer, because the policy is attached to the column and listed in Snowflake's policy views.
If different tenants or regions share a table, add a row access policy as well. Masking hides values, while row access removes rows. Both are enforced by the warehouse, so they hold even when the agent writes a query the server's author never expected. Apply them to the base tables, not just to a view the agent happens to use today.
Step 5: Make every agent query attributable
A least-privilege role limits damage. Attribution lets you see what happened. Set a query tag on the service user with ALTER USER mcp_agent SET QUERY_TAG = 'mcp-text-to-sql'; and have the server append the originating request identifier to it per session. Every statement then carries a label you can filter on, and a spike in warehouse queue time can be traced to a specific tool call rather than to 'the agent'.
Snowflake keeps this history for a long time. The ACCESS_HISTORY view reference states that the view covers the last 365 days, and it records which columns each query read. That makes a review practical: once a month, list the columns the agent's user read and compare them to what you intended. Anything unexpected becomes either a revoke or a documented exception.
Log on the MCP side too. Store the user's question, the SQL the model produced and the row count returned, next to the Snowflake query ID. When the two logs line up, an auditor can follow a number in a report back to the grant that allowed it. When they do not, you have found a path that bypasses the server.
What a read-only role does not protect
Three gaps remain after the grants above. First, data exfiltration through answers: an agent with legitimate SELECT can still summarize sensitive rows into a response, which is why masking matters more than the role name. Second, prompt injection through data: a text column can contain instructions that the model reads as part of a result. The role limits what those instructions can do, but it does not stop the model from following them within that scope.
Third, the MCP server itself. If it exposes more than a query tool, such as a tool that creates objects or calls external functions, the grants are the only barrier. The open-source Snowflake-Labs MCP repository is a reasonable place to see how one server structures its tool set and configuration. Whatever server you run, read its tool list before you connect it and remove tools the role should never use.
Review the role whenever someone asks to widen it. Requests like 'just give it SELECT on the raw schema' are usually a sign that the curated schema is missing a table. Fixing the model of the data is cheaper than widening the blast radius, and it improves the answers.
Where Data Workers fits
Data Workers is an open-source set of MCP-native agents. The OSS edition (dw-claw) is Apache 2.0, runs locally and is read-only by default. Our Connectors Agent reads Snowflake through a connection you configure, so the walkthrough above applies directly: create the role, grant what the agents should see and point the connector at the agent warehouse. The agents run inside your infrastructure, and data does not leave it.
Writes are a separate decision. In Pro, write actions sit behind approval workflows and tamper-evident audit trails, and the autonomy setting is per domain, so you can keep access read-only for one area while letting an agent act in another. Even then, we recommend a second Snowflake role for write paths, with its own warehouse and its own resource monitor, instead of adding privileges to the read role.
If you are starting from nothing, begin with the five steps here, ask a few real questions such as 'Show freshness scores for all gold tables.' and read the resulting query history. That history will tell you quickly whether the role is too narrow, too wide or about right.
Frequently Asked Questions
Is it safe to give an MCP server access to Snowflake?
It is safe to the extent that the role behind the connection is safe. With a dedicated role holding only USAGE and SELECT on curated schemas, a short statement timeout, a resource monitor and masking on PII columns, the worst realistic outcomes are an expensive query that times out and a wrong answer. With a broad role, the worst outcome is whatever that role can do. Decide on the role first, then pick the server.
Do I need SELECT on all schemas for text-to-SQL to work?
No. The agent only needs the schemas that answer your questions. Start with one curated schema and add others when a real question fails for lack of data. Granting SELECT on every schema increases the chance of wrong joins against raw tables and exposes columns that were never meant for analysis, without making typical answers better.
Can the agent run INSERT, UPDATE or DROP with this role?
Not unless a grant allows it. A role that holds only USAGE and SELECT cannot modify or drop tables it does not own, and it cannot create objects without CREATE privileges on the schema. Verify with SHOW GRANTS TO ROLE mcp_readonly; and check that no ownership, MODIFY, OPERATE or CREATE privileges appear.
How do I stop the agent from running up Snowflake credits?
Give it its own XSMALL warehouse with a 60-second auto-suspend, a statement timeout well below the two-day default and a resource monitor that suspends the warehouse at a credit quota. Grant USAGE on the warehouse only, so the agent cannot resize it. Then review the monthly credit use of that warehouse alone, which is easy because nothing else runs on it.