Connect Claude Code or Cursor Safely to an Enterprise Data Warehouse

A governed path for connecting Claude Code or Cursor to your warehouse: read-only identities, OAuth over stored secrets, SQL gates, cost caps and audit evidence.

Connect Claude Code or Cursor Safely to an Enterprise Data Warehouse

Connecting Claude Code or Cursor to an enterprise data warehouse is not hard; connecting it so a security reviewer will approve is. The goal is a governed path: a read-only warehouse identity, credentials that never live in a committed file, SQL that is validated before it runs, cost caps enforced by the warehouse, and logs that attribute every query to the agent. That replaces the common shortcut — an admin password pasted into a config file — with controls that survive a compromised laptop. This guide works through the sequence in order: pick a connection pattern, scope the identity, wire the client, gate the SQL, contain the runtime, then assemble audit evidence.

Choose the Connection Pattern Before You Choose the Tool

Start with the pattern, because it determines what you can enforce. There are three: the client holds warehouse credentials directly, a self-hosted MCP gateway sits between client and warehouse, or a vendor-managed MCP server does. The client is not a security boundary — Claude Code and Cursor are developer tools, not policy engines. The boundary is the warehouse identity plus whatever sits between the agent and the warehouse.

Pattern

What it can enforce

What it cannot enforce

Fits

Direct credentials from client

Warehouse grants, network policy, statement timeouts

Per-server isolation, central tool allowlisting, credential-free laptops

Small teams, single warehouse, strong warehouse-side controls

Self-hosted MCP gateway

Server isolation policy, tool allowlists, request logging, token brokering

Anything the warehouse identity itself permits

Regulated environments, multiple servers, audit requirements

Vendor-managed MCP server

Vendor's auth model and tool surface

Your own isolation rules between servers; you inherit the vendor's scope

Fast pilots where the vendor's controls match your policy

Both clients support stdio, SSE, and Streamable HTTP transports, but with different execution environments and auth models: Cursor documents stdio as local and single-user with manual auth, while SSE and Streamable HTTP can be deployed as servers for multiple users with OAuth (Cursor MCP docs). Claude Code likewise distinguishes local stdio servers from HTTP, SSE, and connector-based servers, with different timeout and approval behavior per type (Claude Code MCP docs).

A gateway is the pattern that lets you enforce isolation policy between servers, which OWASP lists as a specific MCP control (OWASP MCP Security Cheat Sheet). If your reviewer asks "what stops server A from reaching server B's data," only the gateway pattern answers it without relying on the warehouse alone.

Create a Read-Only, Narrowly Scoped Warehouse Identity

Give the agent its own identity with read access to approved schemas and nothing else — never a personal login and never an admin role. The verification is the same on every platform: attempt an INSERT, UPDATE, or CREATE from the agent's connection and confirm the warehouse rejects it. If the client blocks the statement, you have not tested the identity.

Snowflake. Create a custom role and grant USAGE on the warehouse, database, and schema, plus SELECT on the approved tables. Snowflake's access-control documentation notes that a role limited this way cannot update table data, create objects, or drop tables (Snowflake access control). Grant SELECT on future tables in the schema so new tables do not silently fall outside the agent's reach.

BigQuery. Grant the predefined roles/bigquery.dataViewer at the dataset level rather than the project level, and add roles/bigquery.jobUser so the identity can run jobs. dataViewer can be granted at the dataset level, and at that level it grants query, export, and snapshot permissions on the dataset's tables and views (BigQuery access control). Note that jobUser can only be granted at the project, folder, or organization level, so scope it to a dedicated project if you need tighter separation.

Databricks. Use a Unity Catalog service principal with a storage credential. The storage credential encapsulates the principal's authentication details, so you reference it by name and Unity Catalog generates temporary tokens behind the scenes instead of embedding credentials in code (Microsoft Learn). Grant USE CATALOG, USE SCHEMA, and SELECT on the approved objects only.

Redshift. Create a per-agent database user or federated identity and grant SELECT on the approved schemas. AWS's guidance for agentic workloads stresses per-agent identity because it answers both what the agent did and what it cost (AWS Big Data blog).

Fine-grained controls layer on top of the base grants. BigQuery row-level security filters which rows a principal can see, and column-level access control restricts individual columns (BigQuery row-level security). Authorized views let you expose a query result to a principal without granting access to the underlying source dataset (BigQuery authorized views). Use these when the agent should see aggregates or masked values rather than raw rows.

Wire the Client Without Embedding Long-Lived Secrets

Point the client at the governed connection using OAuth or short-lived tokens, and keep the credential out of any file that reaches version control. A pasted password in .mcp.json is readable by anyone with repository access and survives every rotation you forget.

Claude Code. Add an HTTP server with claude mcp add --transport http <name> <url>, then authenticate with claude mcp login <name> in your shell. Claude Code's documentation is explicit that you should keep Authorization out of the configured headers and sign in via OAuth; if you do configure an Authorization header, Claude Code uses it as the server's credential and does not fall back to OAuth for that server (Claude Code MCP). Scope matters: local scope writes to ~/.claude.json for the current project only, project scope writes to .mcp.json in the project root and is shared with the team via version control, and user scope applies across all your projects. Project-scoped .mcp.json servers require interactive approval before they run — which is the control that stops a teammate's commit from silently adding a server.

Cursor. Configure servers in mcp.json. Cursor resolves ${env:...} variables in command, args, env, url, and headers, so a token can come from the environment rather than the file (Cursor MCP). For OAuth servers, Cursor supports static OAuth client credentials in mcp.json instead of dynamic client registration. Enterprise admins can allowlist which MCP servers a team may run from the dashboard; allowlisting approves a configuration but does not distribute or install the server.

Snowflake auth. Prefer OAuth. Snowflake's authentication overview describes External OAuth as offering a secretless form of authentication when the IdP supports it, and Snowflake OAuth as a strong option that local applications can use without administrative setup (Snowflake auth overview). Programmatic access tokens are the fallback: Snowflake states that it requires you to implement additional security measures for long-lived secrets, that the secret must be sent in the request to Snowflake, and that a compromised token lets anyone impersonate the application. If you must use a PAT, scope it to the read-only role, set the shortest workable expiration, and rotate on a schedule.

Checkpoint. Before merging, grep the repository for the token, confirm no secret appears in .mcp.json or any committed file, and confirm the token lifetime is bounded and documented. Then verify the agent's session shows up in the warehouse under the service identity, not your personal login.

Validate AI-Generated SQL Before It Executes

Put a gate between the model's SQL and the warehouse: parse and lint it, restrict it to SELECT, estimate cost with a dry run, and require human approval above a threshold. The gate must block, not just log — a control that only records an expensive query has already paid for it.

BigQuery gives you the worked example. A dry run returns the bytes the query will process without running it, and the maximum-bytes-billed setting caps what a query can consume (BigQuery cost best practices). Google's own guidance for backends that run untrusted or AI-generated SQL recommends a dry run or parsing the SQL abstract syntax tree before execution (BigQuery authorized views). One caveat worth knowing: BigQuery bills a minimum of 10 MiB per query and per referenced table regardless of actual size, so a flood of tiny agent queries can cost more than the byte estimates suggest.

On Snowflake, the warehouse-side backstop is STATEMENT_TIMEOUT_IN_SECONDS, which can be set at the warehouse and session level, alongside STATEMENT_QUEUED_TIMEOUT_IN_SECONDS for queued statements (Snowflake parameters). Resource monitors add a credit threshold on top. These do not replace the pre-execution gate; they catch what the gate misses.

OWASP's MCP guidance supports this shape: choose controls according to risk, including explicit user confirmation, narrowly scoped authorization, or policy checks enforced at execution time (OWASP MCP). It also warns against auto-approving tool calls without showing the full parameters to the user — which is exactly what a warehouse tool call exposes.

Checkpoint. Submit a deliberately expensive query through the agent and confirm it is blocked or capped, not merely logged. If the dry run estimate exceeds your threshold, the gate should stop the query and surface the estimate for approval.

Cap Cost and Blast Radius at the Warehouse

Client-side limits are advisory; warehouse-side limits are enforcement. A compromised or misconfigured client can ignore its own guardrails, so every cap that must survive that scenario belongs in the warehouse.

Set, at minimum:

  • Statement timeouts. Snowflake's STATEMENT_TIMEOUT_IN_SECONDS at the warehouse level bounds how long any agent query can run (Snowflake parameters).

  • Credit or byte quotas. Snowflake resource monitors suspend or notify at credit thresholds; BigQuery custom query quotas enforce a hard cap that prevents users from running queries beyond the limit (BigQuery cost best practices).

  • Result-size limits. Bound how much data a single agent call can return, so a SELECT * on a large table does not stream gigabytes to a laptop.

  • Network policy. Snowflake's NETWORK_POLICY parameter restricts which addresses can connect, at account and user level (Snowflake parameters). If the agent runs from a known egress range, allowlist it and nothing else.

OWASP recommends applying rate limits, quotas, and timeouts per session or tenant to resist denial-of-service and limit the impact of abuse (OWASP MCP). Treat the warehouse settings as the authoritative version of each limit and the client settings as convenience.

Treat Agent-Runtime Sandboxing as Part of the Access Decision

The machine or container the agent runs in is part of the warehouse-access threat model. A stdio MCP server runs as a local process with the user's privileges, so a compromised or malicious server can reach anything that user can — including files, environment variables, and any credential the user holds. That is why sandboxing belongs in the access decision, not in a separate "developer experience" conversation.

Claude Code's controls help. It prompts for permission on tool calls, requires interactive approval for project-scoped .mcp.json servers, and supports managed MCP configuration with allowlists and denylists that reach cloud sessions (Claude Code MCP). Cursor lets enterprise admins allowlist which MCP servers a team may run from the dashboard (Cursor MCP). Neither replaces a sandbox.

OWASP's guidance is to combine resource controls with sandboxing to contain local escape impact (OWASP MCP). In practice: run the agent in a container or VM with no ambient cloud credentials, mount only the project directory, and route warehouse access through the governed connection rather than a locally cached token. Treat every tool response as untrusted data, including responses from approved servers — a warehouse comment field or a table name can carry injected instructions.

Frame sandboxing as a compensating control, not a substitute for the read-only identity. If the sandbox fails, the identity still cannot write. If the identity is over-scoped, the sandbox is the only thing left.

Assemble the Audit Evidence a Reviewer Will Demand

A security reviewer will not accept "the agent is read-only" as an assertion. Collect artifacts that prove it. Map them to SOC 2's five criteria — Security, Availability, Processing Integrity, Confidentiality, and Privacy — each of which the cited source describes as a cornerstone for a precise evidence chain and streamlined control logging (SOC 2 monitoring).

  • Identity grant list. The exact grants on the agent's role or service principal, exported from the warehouse, with the approver named.

  • Rejected-write test result. A captured error from an attempted INSERT, UPDATE, or CREATE, showing the warehouse — not the client — refused it.

  • Client configuration, secrets redacted. The .mcp.json or mcp.json entry with tokens removed, plus the scope it was installed at.

  • Query logs showing agent-attributed sessions. Warehouse query history filtered to the service identity, with timestamps and the SQL text.

  • Cost-cap settings. Screenshots or exports of the timeout, quota, and resource-monitor configuration.

  • Approval trail for any write path. If any write capability exists, the ticket, approver, and scope.

  • Sandbox configuration. The container or VM image, its network egress rules, and the absence of ambient credentials.

Per-agent identity is what makes this list tractable: security asks what the agent did and FinOps asks what it cost, and per-agent identity answers both (AWS Big Data blog). If the agent shares a human's identity, neither question has a clean answer.

How Compliance Obligations Shape Masking and Logging

Compliance obligations such as GDPR, CCPA, HIPAA, and SOC 2 do not dictate a specific configuration, but they push on two concrete choices: what the agent is allowed to see, and what gets logged. Decide both deliberately rather than inheriting defaults.

What the agent sees. Use masking, row-level security, and authorized views to narrow the data surface before the agent ever queries it. BigQuery authorized views let you share a subset of data with specific users without giving them access to the underlying source dataset (BigQuery authorized views). Row-level security and column-level access control restrict rows and columns respectively (BigQuery row-level security). If the agent only needs aggregates, expose an authorized view of aggregates and grant nothing else.

What gets logged. Query text is the most useful debugging artifact and the most likely place for sensitive values to leak. Snowflake's ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR parameter controls whether query text is redacted when a SQL query fails due to a syntax or parsing error; setting it to FALSE redacts the content (Snowflake parameters). That is the trade-off in one parameter: unredacted errors are easier to debug and expose more. Default to redaction for agent sessions, and grant unredacted access only for a time-boxed investigation.

These are engineering choices that support compliance; they are not legal conclusions. Confirm retention periods and data-residency requirements with your compliance team before go-live.

Pre-Go-Live Acceptance Checklist

Sign off only when every item below passes. Each is verifiable from an artifact, not from a description of intent.

#

Gate

Pass criteria

1

Read-only identity

Attempted INSERT/UPDATE/CREATE rejected by the warehouse; error captured

2

Scope

Grant list matches the approved schema list; no admin or owner role attached

3

No long-lived secret in committed files

Repository scan clean; .mcp.json and mcp.json contain no token

4

Token lifetime bounded

OAuth session or PAT expiration documented and enforced

5

Client scope approved

Project-scoped servers require interactive approval; team allowlist configured where available

6

Dry-run gate active

Expensive test query blocked or capped before execution

7

Warehouse-side timeout and quota set

STATEMENT_TIMEOUT_IN_SECONDS, resource monitor or quota, and network policy confirmed

8

Sandbox in place

Agent runs in a container or VM with no ambient warehouse credentials

9

Audit artifacts collected

Grant list, rejected-write result, redacted config, query logs, cost settings, approval trail

10

Masking and logging decided

Authorized views or masking in place; query-text redaction default confirmed

Any failed row blocks go-live. Rows 1, 3, and 7 are the ones most often skipped, and each one is the difference between a governed connection and a credential with a policy document attached.

FAQ

Can I use a personal Snowflake login instead of a service identity?

You can, but it ties warehouse access to a human account whose grants, MFA state and departure date you do not control at the agent level. A dedicated identity is what makes the rejected-write test and the per-agent query logs in the audit section meaningful.

What if my warehouse does not support OAuth?

Fall back to a scoped credential rather than an admin one. Snowflake's own authentication guidance notes that programmatic access tokens can be scoped to a specific access control role to limit damage if compromised, but states that Snowflake requires additional security measures to mitigate the risks of long-lived secrets, including a robust storage and rotation strategy (Snowflake authentication overview). Treat that as a compensating-control project, not a shortcut.

Does an MCP gateway replace the read-only role?

No. A gateway controls which servers and tools the agent can reach; it does not change what the warehouse identity is permitted to read or write. Keep both, and keep the grant list narrow.

How do I rotate credentials without breaking the agent?

Issue the new credential first, confirm the agent connects with it, then revoke the old one — and keep the lifetime bounded so rotation is routine rather than an incident. Snowflake documents use, modify, list, rotate, revoke and re-enable operations for programmatic access tokens, and allows an expiration of up to 365 days by default, which you can shorten (Snowflake PATs).

Related Articles