MCP Lakehouse Read-Only SQL Least Privilege: Tool Allowlists, Query Budgets, and RLS Propagation

Secure MCP lakehouse SQL using least privilege, tool allowlists, query budgets and identity-aware RLS. Test enforcement before production access.

MCP Lakehouse Read-Only SQL Least Privilege: Tool Allowlists, Query Budgets, and RLS Propagation

Author: jackey.ye · Updated: 2026-11-25

A read-only SQL role prevents writes, not disclosure. Least privilege for an MCP lakehouse path rests on three controls: tool allowlists that shrink the callable surface, server-side query budgets that bound each query and session, and identity propagation that makes row-level security evaluate the real end user. This guide covers those three controls and how to validate them; it does not cover generic agent-to-warehouse connection setup. Every configuration shown is an example to validate in your target environment, and no Singdata-specific MCP capability is asserted beyond what official documentation confirms.

Why Does a Read-Only SQL Role Still Allow Data Leakage?

Read-only blocks INSERT, UPDATE, DELETE and DDL. It does not block reading anything the role can see, and it does not block that data leaving the warehouse. Four leakage paths survive a read-only grant:

  • Over-broad SELECT reach. A role granted SELECT across whole schemas lets the agent read tables no question required. The agent does not need to be malicious; a plausible-sounding prompt can pull a customer table into a result set.

  • Result sets returned to the model and its logs. Rows travel from the warehouse into the MCP server, into the model context, and often into client-side transcripts and server logs. Each hop is a copy outside the warehouse boundary.

  • Metadata enumeration. Schema and table descriptions reveal structure, naming conventions and business meaning even when no rows are returned.

  • Identity mismatch. If the MCP server opens one shared service-account session, every end user inherits that account's visibility. Row-level security and masking only bind to the principal the query actually executes as; a shared account means the policy evaluates the service account, not the person asking.

The last point is the one reviewers miss. A read-only role plus a shared connection is read-only and over-permissive at the same time. The three controls that follow address reach, volume and principal in that order.

Which MCP Tools Should Be Allowlisted for a Lakehouse Read Path?

Allowlist only the tools the read path needs — a bounded query-execution tool and a schema-description tool — and remove everything else. The MCP tools specification treats tool definitions as server-advertised capabilities that clients discover and invoke, so the advertised list is the real attack surface: a tool the server never exposes cannot be called, however the model is prompted. The MCP authorization specification requires clients to implement Resource Indicators for OAuth 2.0 (RFC 8707), and the security considerations state that servers MUST validate access tokens before processing a request, ensuring the token was issued specifically for that MCP server, and forbid passing the client's token through to upstream APIs. Audience binding keeps a token minted for one server from being replayed against your lakehouse endpoint.

Tool category

Posture

Risk if left enabled

Parameterized read query (single statement, bound parameters)

Allow

Baseline capability; risk is bounded by role scope and query budgets

Schema and table description (metadata only)

Allow, scoped to approved schemas

Reveals structure and naming; scope it to the schemas the agent needs

General-purpose "run any SQL" tool

Remove

Effectively allowlists every statement, including DDL and multi-statement scripts

Write, insert, update, delete, DDL tools

Remove

Converts a read path into a mutation path if the role is ever misconfigured

Export, unload, download, stage-write tools

Remove

Moves bulk data out of the warehouse boundary in one call

Session and connection management tools

Remove

Lets the agent change session context, role or warehouse settings

Arbitrary HTTP or shell tools co-located on the server

Remove

Bypasses the warehouse entirely; nothing in the SQL policy applies

{
    "mcpServers": {
      "lakehouse-readonly": {
        "type": "http",
        "url": "https://mcp.example.internal/lakehouse",
        "allowedTools": ["query_readonly", "describe_schema"],
        "deniedTools": ["run_sql", "execute_script", "export_table", "manage_session", "write_rows"],
        "requireToolAllowlist": true
      }
    }
  }
  

Example configuration — validate in your target environment.

The failure mode is subtle: an allowlist that keeps a general-purpose "run any SQL" tool has allowlisted everything, because the model composes the statement. Review the advertised tool list, not the allowlist file, and confirm removed tools are absent rather than merely hidden.

How Should SQL Query Budgets Be Dimensioned and Enforced?

Set budgets on five dimensions and enforce them server-side and engine-side, never in the prompt alone. A read-only role still permits a SELECT * over a large table, a fan-out of exploratory queries, and a long-running session that keeps spending while the model reasons. Budgets bound that blast radius per query and per session.

Dimension

What it bounds

Where to enforce

Bytes scanned per query

Cost and exposure of one statement

Engine quota plus MCP server pre-check

Bytes or rows returned per query

How much data reaches the model and logs

MCP server result cap

Query count per session

Exploratory fan-out and retry loops

MCP server session counter

Concurrent queries per session

Parallel runaway

MCP server and engine concurrency limit

Wall-clock timeout

Stuck or expensive queries

Engine statement timeout and server deadline

Engine limits that bound a single read path, with the scope each figure carries. BigQuery's 6-hour figure is a per-attempt execution limit; internal retries can extend total job runtime to 18 hours. The 10 GB response cap applies to compressed response size and is lifted when results are written to a destination table. Row size is approximate and enforced during certain execution stages.

Engine documentation gives useful reference points, each with its own scope. BigQuery's quotas and limits state that a query or multi-statement query can execute for up to 6 hours before it fails, but that BigQuery may internally retry a job up to three times, so total runtime can reach 18 hours; the 6-hour figure is a per-attempt execution limit, not a guaranteed wall-clock ceiling for the job. The same page notes that by default there is no daily query size limit, and that you can set custom quotas controlling query usage per day or per day per user — those are configurable quotas, not defaults. Snowflake exposes STATEMENT_TIMEOUT_IN_SECONDS and STATEMENT_QUEUED_TIMEOUT_IN_SECONDS at warehouse and session level, and its documentation notes that STATEMENT_TIMEOUT_IN_SECONDS controls query cancellation only and does not close the server-side session (Snowflake parameters). That distinction matters: a cancelled query can leave a session open, so pair the timeout with a session-level budget.

query_budget:
    per_query:
      max_bytes_scanned: 2000000000
      max_rows_returned: 5000
      timeout_seconds: 120
    per_session:
      max_queries: 25
      max_concurrent_queries: 2
      max_total_bytes_scanned: 10000000000
      idle_timeout_seconds: 900
    on_exceed: reject_and_log
  

Example configuration — validate in your target environment. The numbers are illustrative starting points; dimension them against your own table sizes and query patterns.

The failure mode is a budget written into the system prompt ("never scan more than 2 GB"). The model can ignore it, misjudge table size, or be steered past it. Enforcement belongs where the statement is executed and where the result is returned.

How Is End-User Identity Propagated So RLS Evaluates the Right Principal?

Propagate the end user's identity into the query session so the engine evaluates row-level security against that user, not the MCP server's service principal. AWS documents this mechanism for Lake Formation trusted identity propagation: two tokens travel through the system — an access_token that authenticates the request at each trust boundary, and an id_token that carries the user's identity and is exchanged server-side for the identity context Lake Formation evaluates — and Lake Formation evaluates only the propagated user identity, not the TIP role (AWS Security Blog). The exchange happens inside the compute that holds the token, which keeps the identity context from crossing a process boundary.

Row-level security binds to the querying principal in engine documentation too. Databricks states that when a table is queried through a view, access to the underlying tables is checked against the view owner's identity while policies are evaluated against the querying user's identity, so a user without direct table access still sees only the rows their own policies allow (Unity Catalog policy evaluation). The practical consequence: if your MCP server opens the session as itself, every policy evaluates the server's entitlements and every user sees the union of them.

identity_propagation:
    mode: trusted_identity_propagation
    token_source: user_id_token
    exchange: server_side
    session_principal: propagated_user
    fallback: deny
  

Example configuration — validate in your target environment. Field names vary by lakehouse; confirm the exact mechanism in your engine's documentation before relying on it.

The failure mode is propagation configured but unused: the identity provider issues the right token, the exchange endpoint is wired up, and the MCP server still calls the warehouse with its own service credential. Verify by running the same query as two different users and comparing row counts, not by reading the configuration.

Deployment and Validation Checklist

Deploy the three controls in order and capture an artifact at each step, because a reviewer needs evidence rather than assurances.

Prerequisites

  • A read-only warehouse role scoped to the specific schemas and tables the agent needs, with no SELECT on unrelated schemas.

  • An MCP server deployed centrally (not on developer laptops) with its tool list under version control.

  • An identity provider that can issue tokens with an audience scoped to the MCP server, and the lakehouse's trusted identity propagation configured where the engine supports it.

  • Query logging and audit logging enabled, with a retention window long enough for review.

Steps

  1. Apply the tool allowlist. Publish the server with only the query and schema-description tools enabled. Expected output: the server's advertised tool list contains exactly the approved tools, and a call to a removed tool returns a "tool not found" error rather than executing.

  2. Confirm removed tools are unreachable. Attempt each removed tool by name from a test client. Expected output: every attempt fails at the server, and the failure is logged with the attempted tool name.

  3. Set per-query budgets. Configure byte, row and timeout limits at the server and matching engine quotas. Expected output: a normal query succeeds within limits; a deliberately oversized query is rejected with a budget error naming the exceeded dimension.

  4. Set per-session budgets. Configure query count, concurrency and idle timeout. Expected output: a scripted loop past the query cap is rejected, and the session is closed at the idle timeout.

  5. Verify identity propagation. Run the same query as two end users with different entitlements. Expected output: the two runs return different row counts, and each log entry names the corresponding end-user principal.

  6. Confirm RLS and masking filter results. Query a table with a row filter and a masked column as a restricted user. Expected output: only permitted rows return, and the masked column shows the masked value rather than the raw one.

  7. Collect evidence artifacts. Export the allowlist diff, budget rejection logs, paired-identity query results and audit entries. Expected output: a single evidence bundle that maps each control to its proof.

Steps 1–6 involve configuration; treat the values as examples to validate in your target environment. For the surrounding connection pattern — managed configuration, credential-free clients and warehouse-side least privilege — see connecting AI coding agents to a warehouse, and for how enforcement differs across direct credentials, a self-hosted gateway and a vendor-managed server, see Claude Code and Cursor warehouse MCP patterns.

What Evidence Proves Identity Propagation and RLS Actually Took Effect?

Four artifacts, taken together, constitute proof: query logs that name the evaluated principal per query, paired test results from two identities returning different rows, rejection logs for over-budget queries, and an allowlist diff showing which tools were removed. No single one is sufficient. A log showing a query ran proves nothing about who it ran as; a paired-identity test proves behavior at one moment but not that the control stays on.

Structure the sign-off record around the three controls rather than around a certification claim. For each control, record the configuration as deployed, the test performed, the artifact produced and the date. Keep the paired-identity results verbatim, including the query text and both row counts, because a reviewer will want to see that the difference came from the policy and not from a different filter. Note explicitly that compliance mapping — SOC 2, ISO 27001 or an internal standard — is your own validation step against your own control framework; this guide asserts no certification and reports no benchmark.

One logging trade-off deserves a decision on the record. Query text is the most useful debugging artifact and a likely place for sensitive values to appear. Snowflake's ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR parameter controls whether query text is redacted when a query fails on a syntax or parsing error; setting it to FALSE redacts the content (Snowflake parameters). Default to redaction for agent sessions and grant unredacted access only for a time-boxed investigation, with that exception documented in the sign-off record.

Frequently Asked Questions

Is a read-only SQL role enough to secure an MCP lakehouse path?

No. A read-only role blocks writes but still permits broad reads, result sets returned to the model and its logs, metadata enumeration, and over-permission when a shared service account is used. Pair it with tool allowlists, server-side query budgets and end-user identity propagation.

Should SQL query budgets be enforced in the agent or the MCP server?

In the MCP server and the engine, not the agent. A prompt-level limit is an instruction the model can ignore or misjudge. Enforce byte, row, count, concurrency and timeout limits where the statement executes and where the result is returned.

How do I confirm RLS evaluated the end user's identity, not the service account?

Run the same query as two end users with different entitlements and compare row counts; they should differ. Then check the query log for the evaluated principal on each run. A log naming the service account instead of the user means propagation is not taking effect.

What if my lakehouse does not support trusted identity propagation?

Fall back to per-user scoped roles or restrict the agent's data surface to tables that are safe for every user of the shared principal. The trade-off is coarser granularity: row-level policies cannot distinguish users behind one service account, so the blast radius is the account's visibility.

Does tool allowlisting alone close the data-leakage paths?

No. Allowlisting shrinks the callable surface but does not bound how much a permitted query returns or which principal it runs as. Allowlists, query budgets and identity propagation address reach, volume and principal respectively; all three are needed.

For a related implementation check, see the agent experiment record and evidence checklist.

Related Articles