# Snowflake MCP

> Snowflake MCP Server connects your AI agent directly to Snowflake for data cloud operations. It lets you run complex SQL queries, browse full database schemas, and manage resources—all through conversation. You can execute `execute_sql` statements, check metadata with `describe_table`, and monitor query status without leaving the chat window.

## Overview
- **Category:** industry-titans
- **Price:** Free
- **Tags:** sql-query, data-warehousing, cloud-data, database-schema, data-analysis

## Description

Yo, listen up. This Snowflake MCP Server hooks your AI agent right into your data cloud for serious operations. You're not just running queries; you're managing the whole damn stack—all through conversation. 

When you connect your agent to this server, it gives you direct access to run complex SQL and handle everything from mapping out your databases to monitoring compute costs.

To start figuring things out, your agent can first check what’s running in your environment with `get_session_context`, which hands you the current database and schema details. If you gotta scope out the whole system, it'll list every accessible data repository using `list_databases`. From there, if you want to see all the organizational containers inside a specific database, use `list_schemas`.

Need to know what tables are sitting in that schema? Run `list_tables`, which shows you exactly which tables reside there. If you need to dig deeper into one of those tables—say, checking out column names and data types—you'll call `describe_table`. This gives you the precise schema breakdown before you write a single line of SQL.

For writing queries, you use `execute_sql` to run any valid statement against Snowflake; it’ll spit back results or give you a job handle if the query is big. If that query starts hogging resources or just runs too long, you've got ways to manage it: first, check its progress with `get_statement_status`, and if it won't quit, hit the brakes with `cancel_sql`.

Beyond data querying, this thing lets you handle system oversight. It can list all user accounts in your environment using `list_users` or review who has permissions by calling `list_roles`. To keep an eye on costs and performance, it lists every compute warehouse available via `list_warehouses`, letting you control what’s running.

It's basically a full operational interface. You can map the entire data hierarchy by listing databases (`list_databases`), schemas (`list_schemas`), and tables (`list_tables`); then, check column types with `describe_table`; run any SQL statement using `execute_sql` while tracking its status with `get_statement_status`, or stopping runaway jobs instantly with `cancel_sql`. You can also view your current setup with `get_session_context`, and see the full roster of system users (`list_users`), roles (`list_roles`), and compute resources (`list_warehouses`).

## Tools

### cancel_sql
Stops an active SQL query that is running too long or consuming excessive resources.

### describe_table
Retrieves the column names and data types (schema) for a specified table.

### execute_sql
Runs a complete SQL statement against Snowflake, returning results or a job handle.

### get_session_context
Provides the current working environment details, including database and schema context.

### get_statement_status
Checks if a specific SQL statement is currently running or has completed successfully.

### list_databases
Lists every database accessible within your Snowflake account.

### list_roles
Returns a list of security roles defined in the system.

### list_schemas
Shows all schemas contained within a given database.

### list_tables
Lists tables that reside within a specific schema or database.

### list_users
Retrieves a list of user accounts in the Snowflake environment.

### list_warehouses
Lists and summarizes all available compute warehouses used for query execution.

## Prompt Examples

**Prompt:** 
```
List all tables in the 'SALES' schema of the 'PROD' database.
```

**Response:** 
```
I've retrieved the tables for you. The 'SALES' schema contains 5 tables: 'ORDERS', 'CUSTOMERS', 'INVOICES', 'PRODUCTS', and 'TRANSACTIONS'. Which one would you like to describe?
```

**Prompt:** 
```
Show me the warehouse usage and query performance metrics for all active Snowflake warehouses.
```

**Response:** 
```
4 active warehouses. "ANALYTICS_WH" (X-Large): 78% utilization, 234 queries today, avg execution 4.2s, $89 credit usage. "ETL_WH" (Large): 45% utilization, 56 queries, avg 12.3s, $34 credits. "REPORTING_WH" (Medium): 23% utilization, 890 queries, avg 1.8s, $12 credits. "DEV_WH" (Small): 12% utilization, 45 queries, avg 3.4s, $4 credits. Total credits today: $139. Auto-suspend: all enabled (5 min idle). Queued queries: 0. Failed queries: 3 (timeout on ANALYTICS_WH). Storage: 12.4 TB used.
```

**Prompt:** 
```
Run a SQL query to get the top 10 customers by revenue from the sales table this quarter.
```

**Response:** 
```
Query executed on ANALYTICS_WH (1.2s). Top 10 customers by Q2 2025 revenue: 1) Meridian Corp: $234,000 (45 orders). 2) TechVentures: $189,000 (23 orders). 3) DataFlow: $156,000 (67 orders). 4) ScaleUp: $123,000 (34 orders). 5) CloudBridge: $98,000 (12 orders). 6-10: combined $345,000. Total Q2 revenue: $1.45M. Top 10 = 78% of total revenue. Rows scanned: 45,678. Credits used: 0.02. Query ID: 01abc-def-234.
```

## Capabilities

### Execute arbitrary SQL queries
Run any valid SQL statement against your Snowflake environment using `execute_sql`.

### Map database structures
Browse the data hierarchy by listing databases (`list_databases`), schemas (`list_schemas`), and tables (`list_tables`).

### Inspect table details
Get a precise breakdown of column names and types for any given table using `describe_table`.

### Manage compute resources
View, list, and monitor your available data warehouses (`list_warehouses`) to control cost and performance.

### Monitor query health
Track the real-time status of running queries using `get_statement_status`, or halt runaway jobs with `cancel_sql`.

## Use Cases

### The Schema Discovery Problem
A data scientist needs to join customer records but doesn't know if 'address' lives in the `CUSTOMERS` schema or the `SALES` schema. Instead of running multiple guesses, they ask their agent: 'List all schemas in the PROD database.' The agent uses `list_schemas`, and once the correct area is identified, they use `describe_table` to confirm the required columns before running the join via `execute_sql`.

### Debugging a Slow Report
A BI engineer runs a massive report that hangs. They don't know if it's stuck or just processing. First, they use `get_statement_status` to check the progress. If it's clearly stalled, they hit 'cancel' using `cancel_sql`. This saves them from waiting hours for nothing.

### Auditing Data Access
A compliance officer needs to know which groups can see sensitive user data. They use the agent to list roles (`list_roles`) and then check who belongs to those roles using `list_users`. This provides an immediate audit trail of access permissions.

### Resource Allocation Check
A development team needs to run a complex ETL process. Before running the job, they ask: 'What warehouses are active?' The agent uses `list_warehouses`, allowing them to ensure the correct compute resource is available and properly configured for the workload.

## Benefits

- Stop guessing column names. Use `describe_table` to get the exact schema details before you write a single line of code, preventing runtime errors and wasted computation.
- Manage query execution risk. If a report hits a bottleneck, check status with `get_statement_status`, or kill it instantly using `cancel_sql` instead of waiting minutes for a timeout.
- See your entire data map at a glance. Tools like `list_databases`, `list_schemas`, and `list_tables` let you navigate the whole structure right inside the chat, eliminating manual console navigation.
- Control cost and performance by knowing what's running. Use `list_warehouses` to check active compute resources before kicking off a large job, ensuring your query runs on the correct size warehouse.
- Work with context awareness. `get_session_context` tells you exactly which database and schema the agent is operating under, making multi-step queries reliable.

## How It Works

The bottom line is that you get full data cloud control—from resource listing to executing complex queries—without leaving your chat interface.

1. Subscribe to the server and provide your Snowflake Account Identifier and necessary access token (JWT or OAuth2).
2. Tell your agent what you want. Example: 'List all tables in the PROD database.' The agent uses `list_tables`.
3. After identifying a target table, ask the agent to use `describe_table`. Once the schema is confirmed, ask it to run the final query using `execute_sql`.

## Frequently Asked Questions

**How do I check if a long-running SQL statement is still active using get_statement_status?**
You pass the Query ID (or Job ID) to the agent. The tool checks Snowflake and returns the current status, telling you if it's 'RUNNING,' 'SUCCEEDED,' or 'FAILED.' This prevents you from waiting on a dead query.

**Is there a way to browse all available tables without listing everything?**
Not directly. You must use `list_databases` first, then select the correct database, followed by `list_schemas`, and finally `list_tables`. It's a hierarchical drill-down process.

**Can I see what columns are in a table before querying it using describe_table?**
Yes. Running `describe_table` immediately gives you the full schema—all column names and their data types—so you can write your query accurately without guessing.

**What if my query is running too long and I need to stop it?**
Use the `cancel_sql` tool. The agent sends a cancellation request for the specific job ID, stopping compute usage immediately and freeing up resources.

**How do I check which databases are available using list_databases?**
It immediately returns a list of all accessible databases. This is your starting point for data exploration, letting you see the highest level of structure in your Snowflake account without needing to guess names.

**What information does get_session_context provide about my current connection?**
get_session_context gives you metadata about your current session. This includes details like the active user, assigned warehouse, and time zone settings—essential for confirming that your agent is running in the right environment.

**How do I see all available compute warehouses using list_warehouses?**
list_warehouses lists every compute resource you can use. You check this to manage costs and performance, letting you route different types of queries (like ETL vs. reporting) to dedicated, isolated environments.

**What does list_roles show me regarding security permissions?**
list_roles provides a clear inventory of all defined security roles in your account. This is critical for data governance because it shows exactly what permission sets exist before you try to access restricted data.

**How do I find my Snowflake Account Identifier?**
Your Account Identifier is the part of your Snowflake URL before '.snowflakecomputing.com'. It typically looks like `xy12345.us-east-2.aws`.