Skill: vikrambalaaj/snowflake-mcp (version 2.0.2)

--- name: snowflake-mcp description: Connect to the Snowflake Managed MCP server with Clawdbot or other MCP clients. Use when wiring Snowflake MCP endpoints, validating connectivity, or configuring Cortex AI services. --- # Snowflake MCP Connection Use this skill to integrate the Snowflake Managed MCP server with Clawdbot. It covers endpoint creation, authentication, and tool validation so Snowflake data can be accessed through MCP. ## Quick Start ### Prerequisites - Snowflake account with ACCOUNTADMIN role - Programmatic Access Token (PAT) from Snowflake - Clawdbot or any MCP-compatible client ### Step 1: Create Programmatic Access Token (PAT) 1. In Snowsight, go to your user menu → **My Profile** 2. Select **Programmatic Access Tokens** 3. Click **Create Token** for your role 4. Copy and save the token securely ### Step 2: Create MCP Server in Snowflake Run this SQL in a Snowsight worksheet to create your MCP server: ```sql CREATE OR REPLACE MCP SERVER my_mcp_server FROM SPECIFICATION $$ tools: - name: "SQL Execution Tool" type: "SYSTEM_EXECUTE_SQL" description: "Execute SQL queries against the Snowflake database." title: "SQL Execution Tool" $$; ``` ### Step 3: Test the Connection Verify with curl (replace placeholders): ```bash curl -X POST "https://YOUR-ORG-YOUR-ACCOUNT.snowflakecomputing.com/api/v2/databases/YOUR_DB/schemas/YOUR_SCHEMA/mcp-servers/my_mcp_server" \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header "[REDACTED_SECRET]" \ --data '{ "jsonrpc": "2.0", "id": 12345, "method": "tools/list", "params": {} }' ``` ### Step 4: Configure Clawdbot Create `mcp.json` at your project root (this is the MCP configuration Clawdbot can load for a session): ```json { "mcpServers": { "Snowflake MCP Server": { "url": "https://YOUR-ORG-YOUR-ACCOUNT.snowflakecomputing.com/api/v2/databases/YOUR_DB/schemas/YOUR_SCHEMA/mcp-servers/my_mcp_server", "headers": { "Authorization": "Bearer YOUR-PAT-TOKEN" } } } } ``` Start a new Clawdbot session and load `mcp.json` so the MCP connection is active. The Snowflake tools should appear in your session. ### Step 5: Verify in Clawdbot 1. Start a new Clawdbot session 2. Load `mcp.json` for the session 3. Ask a question that triggers Snowflake tools (for example, a SQL query) ## MCP Server Examples ### Basic SQL Execution Only ```sql CREATE OR REPLACE MCP SERVER sql_mcp_server FROM SPECIFICATION $$ tools: - name: "SQL Execution Tool" type: "SYSTEM_EXECUTE_SQL" description: "Execute SQL queries against Snowflake." title: "SQL Execution" $$; ``` ### With Cortex Search (RAG) First create a Cortex Search service in Snowsight (AI & ML → Cortex Search), then: ```sql CREATE OR REPLACE MCP SERVER search_mcp_server FROM SPECIFICATION $$ tools: - name: "Document Search" identifier: "MY_DB.MY_SCHEMA.MY_SEARCH_SERVICE" type: "CORTEX_SEARCH_SERVICE_QUERY" description: "Search and retrieve information from documents using vector search." title: "Document Search" - name: "SQL Execution Tool" type: "SYSTEM_EXECUTE_SQL" description: "Execute SQL queries." title: "SQL Execution" $$; ``` ### With Cortex Analyst (Semantic Views) First upload a semantic YAML or create a Semantic View, then: ```sql CREATE OR REPLACE MCP SERVER analyst_mcp_server FROM SPECIFICATION $$ tools: - name: "Sales Analytics" identifier: "MY_DB.MY_SCHEMA.SALES_SEMANTIC_VIEW" type: "CORTEX_ANALYST_MESSAGE" description: "Query sales metrics and KPIs using natural language." title: "Sales Analytics" - name: "SQL Execution Tool" type: "SYSTEM_EXECUTE_SQL" description: "Execute SQL queries." title: "SQL Execution" $$; ``` ### With Cortex Agent ```sql CREATE OR REPLACE MCP SERVER agent_mcp_server FROM SPECIFICATION $$ tools: - name: "Documentation Agent" identifier: "MY_DB.MY_SCHEMA.MY_AGENT" type: "CORTEX_AGENT_RUN" description: "An agent that answers questions using documentation." title: "Documentation Agent" $$; ``` ### Full Featured Server ```sql CREATE OR REPLACE MCP SERVER full_mcp_server FROM SPECIFICATION $$ tools: - name: "Analytics Semantic View" identifier: "ANALYTICS_DB.DATA.FINANCIAL_ANALYTICS" type: "CORTEX_ANALYST_MESSAGE" description: "Query financial metrics, customer data, and business KPIs." title: "Financial Analytics" - name: "Support Tickets Search" identifier: "SUPPORT_DB.DATA.TICKETS_SEARCH" type: "CORTEX_SEARCH_SERVICE_QUERY" description: "Search support tickets and customer interactions." title: "Support Search" - name: "SQL Execution Tool" type: "SYSTEM_EXECUTE_SQL" description: "Execute SQL queries against Snowflake." title: "SQL Execution" - name: "Send_Email" identifier: "MY_DB.DATA.SEND_EMAIL" type: "GENERIC" description: "Send emails to verified addresses." title: "Send Email" config: type: "procedure" warehouse: "COMPUTE_WH" input_schema: type: "object" properties: body: description: "Email body in HTML format." type: "string" recipient_email: description: "Recipient email address." type: "string" subject: description: "Email subject line." type: "string" $$; ``` ## Tool Types Reference | Type | Purpose | |------|---------| | `SYSTEM_EXECUTE_SQL` | Execute arbitrary SQL queries | | `CORTEX_SEARCH_SERVICE_QUERY` | RAG over unstructured data | | `CORTEX_ANALYST_MESSAGE` | Natural language queries on semantic models | | `CORTEX_AGENT_RUN` | Invoke Cortex Agents | | `GENERIC` | Custom tools (procedures/functions) | ## Benefits - **Governed by Design**: Same RBAC policies apply as your data - **No Infrastructure**: No local server deployment needed - **Reduced Integration**: Connect any MCP-compatible client - **Extensible**: Add custom tools via procedures/functions ## Troubleshooting ### Connection Issues - **SSL Error**: Use hyphens instead of underscores in account name - **401 Unauthorized**: Verify PAT token is valid and not expired - **404 Not Found**: Check database, schema, and MCP server names ### Testing Tools List available tools: ```bash curl -X POST "https://YOUR-ACCOUNT.snowflakecomputing.com/api/v2/databases/DB/schemas/SCHEMA/mcp-servers/SERVER" \ -H "Authorization: Bearer PAT" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' ``` ### PAT Token Notes - PATs don't evaluate secondary roles - Select a single role with all required permissions when creating - Create new PAT to change role ## Alternative: Local MCP Server For local deployment using the `snowflake-labs-mcp` package, see [mcp-client-setup.md](mcp-client-setup.md). ## Resources - [Snowflake MCP Server Guide](https://www.snowflake.com/en/developers/guides/getting-started-with-snowflake-mcp-server/) - [Snowflake MCP Documentation](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-mcp) - [GitHub: sfguide-getting-started-with-snowflake-mcp-server](https://github.com/Snowflake-Labs/sfguide-getting-started-with-snowflake-mcp-server) - [MCP Protocol](https://modelcontextprotocol.io)

path: configuration-template.yaml
content: # Snowflake MCP Server Configuration Template (Local Server)
# For use with snowflake-labs-mcp package
# Copy this file to ~/.mcp/snowflake_config.yaml and customize

# =============================================================================
# CORTEX SERVICES (Optional)
# =============================================================================
# Add your Cortex Agent, Search, and Analyst services here.
# Leave sections empty if not using those services.

# Cortex Agent services - for agentic orchestration
agent_services: []
  # - service_name: my_agent
  #   description: >
  #     Describe what this agent does and when to use it.
  #     Be specific so the AI knows when to invoke it.
  #   database_name: MY_DATABASE
  #   schema_name: MY_SCHEMA

# Cortex Search services - for RAG over unstructured data
search_services: []
  # - service_name: docs_search
  #   description: >
  #     Search company documentation and knowledge base articles.
  #     Use for finding policies, procedures, and technical docs.
  #   database_name: DOCS_DB
  #   schema_name: PUBLIC

# Cortex Analyst services - for natural language queries over semantic models
analyst_services: []
  # - service_name: sales_analyst
  #   semantic_model: ANALYTICS_DB.MODELS.SALES_SEMANTIC_VIEW
  #   description: >
  #     Query sales data including revenue, orders, and customer metrics.
  #     Use for sales reporting and business intelligence.

# =============================================================================
# OTHER SERVICES
# =============================================================================
# Enable or disable tool groups

other_services:
  # Object management - create, drop, alter Snowflake objects
  object_manager: True
  
  # Query execution - run SQL statements
  query_manager: True
  
  # Semantic view discovery and querying
  semantic_manager: True

# =============================================================================
# SQL STATEMENT PERMISSIONS
# =============================================================================
# Control which SQL statement types are allowed.
# Set to True to allow, False to block.

sql_statement_permissions:
  # Uncomment to allow all statements (not recommended for production)
  # - All: True

  # Data Query Language (DQL)
  - Select: True
  - Describe: True
  
  # Session/Context
  - Use: True
  
  # Transaction Control
  - Commit: False
  - Rollback: False
  - Transaction: False
  
  # Data Definition Language (DDL) - CAUTION
  - Alter: False
  - Create: False
  - Drop: False
  - Comment: False
  
  # Data Manipulation Language (DML) - CAUTION
  - Delete: False
  - Insert: False
  - Update: False
  - Merge: False
  - TruncateTable: False
  
  # Other
  - Command: False      # Includes CALL, GRANT, SHOW, etc.
  - Unknown: False      # Block unrecognized statement types


path: mcp-client-setup.md
content: # MCP Client Setup Reference

Use this guide to connect Clawdbot to the Snowflake MCP server.

## Method 1: Managed Snowflake MCP Server (Recommended)

Uses Snowflake's cloud-hosted MCP server. No local installation required.

### Clawdbot Configuration

Create `mcp.json` at your project root:

```json
{
  "mcpServers": {
    "Snowflake MCP Server": {
      "url": "https://YOUR-ORG-YOUR-ACCOUNT.snowflakecomputing.com/api/v2/databases/YOUR_DB/schemas/YOUR_SCHEMA/mcp-servers/YOUR_MCP_SERVER",
      "headers": {
        "Authorization": "Bearer YOUR-PAT-TOKEN"
      }
    }
  }
}
```

Start a new Clawdbot session and add `mcp.json` as context (or configure MCP servers in Clawdbot settings if available).

### URL Format

```
https://{org}-{account}.snowflakecomputing.com/api/v2/databases/{database}/schemas/{schema}/mcp-servers/{mcp_server_name}
```

### Getting Your Values

| Value | Where to Find |
|-------|---------------|
| `org-account` | Snowsight URL or `SELECT CURRENT_ACCOUNT()` |
| `database` | Database containing MCP server |
| `schema` | Schema containing MCP server |
| `mcp_server_name` | Name from `CREATE MCP SERVER` |
| `PAT` | Snowsight → Profile → Programmatic Access Tokens |

---

## Method 2: Local MCP Server (snowflake-labs-mcp)

Uses the Snowflake-Labs MCP package running locally.

### Prerequisites

```bash
# Install uv package manager
brew install uv
# or
pip install uv
```

### Clawdbot Configuration

```json
{
  "mcpServers": {
    "snowflake": {
      "command": "uvx",
      "args": [
        "snowflake-labs-mcp",
        "--service-config-file",
        "~/.mcp/snowflake_config.yaml",
        "--account", "your-account.region",
        "--user", "your_username",
        "--password", "your_password"
      ]
    }
  }
}
```

### Using Connection File

Create `~/.snowflake/connections.toml`:

```toml
[default]
account = "your-account.region"
user = "your_username"
[REDACTED_SECRET]"
warehouse = "COMPUTE_WH"
role = "ANALYST_ROLE"
```

Then in `mcp.json`:

```json
{
  "mcpServers": {
    "snowflake": {
      "command": "uvx",
      "args": [
        "snowflake-labs-mcp",
        "--service-config-file",
        "~/.mcp/snowflake_config.yaml",
        "--connection-name",
        "default"
      ]
    }
  }
}
```

### Key Pair Authentication

```json
{
  "mcpServers": {
    "snowflake": {
      "command": "uvx",
      "args": [
        "snowflake-labs-mcp",
        "--service-config-file",
        "~/.mcp/snowflake_config.yaml",
        "--account", "your-account",
        "--user", "your_user",
        "--private-key-file", "~/.snowflake/rsa_key.p8",
        "--private-key-file-pwd", "key_password"
      ]
    }
  }
}
```

---

## Comparison

| Feature | Managed MCP Server | Local MCP Server |
|---------|-------------------|------------------|
| Infrastructure | None (cloud-hosted) | Local process |
| Authentication | PAT token | Multiple options |
| Setup Complexity | Lower | Higher |
| Custom Tools | Via SQL | Via config file |
| Governance | Full RBAC | Role-based |
| Offline Access | No | Yes |

---

## Verification

1. In Clawdbot, add `mcp.json` to the session context
2. Ask a question that triggers Snowflake tools (for example, a SQL query)


path: mcp-server-examples.sql
content: -- =============================================================================
-- Snowflake MCP Server SQL Examples
-- Run these in Snowsight SQL Worksheet
-- =============================================================================

-- -----------------------------------------------------------------------------
-- BASIC: SQL Execution Only
-- -----------------------------------------------------------------------------
CREATE OR REPLACE MCP SERVER basic_mcp_server FROM SPECIFICATION
$$
tools:
  - name: "SQL Execution Tool"
    type: "SYSTEM_EXECUTE_SQL"
    description: "Execute SQL queries against the Snowflake database."
    title: "SQL Execution"
$$;

-- -----------------------------------------------------------------------------
-- WITH CORTEX SEARCH (RAG over unstructured data)
-- Requires: Cortex Search Service created via Snowsight UI
-- -----------------------------------------------------------------------------
CREATE OR REPLACE MCP SERVER search_mcp_server FROM SPECIFICATION
$$
tools:
  - name: "Document Search"
    identifier: "MY_DB.MY_SCHEMA.MY_SEARCH_SERVICE"
    type: "CORTEX_SEARCH_SERVICE_QUERY"
    description: "Search and retrieve information from documents and knowledge base."
    title: "Document Search"
  - name: "SQL Execution Tool"
    type: "SYSTEM_EXECUTE_SQL"
    description: "Execute SQL queries."
    title: "SQL Execution"
$$;

-- -----------------------------------------------------------------------------
-- WITH CORTEX ANALYST (Natural language to SQL)
-- Requires: Semantic View or YAML file in a stage
-- -----------------------------------------------------------------------------
CREATE OR REPLACE MCP SERVER analyst_mcp_server FROM SPECIFICATION
$$
tools:
  - name: "Sales Analytics"
    identifier: "ANALYTICS_DB.MODELS.SALES_SEMANTIC_VIEW"
    type: "CORTEX_ANALYST_MESSAGE"
    description: "Query sales data, revenue metrics, and business KPIs using natural language."
    title: "Sales Analytics"
  - name: "SQL Execution Tool"
    type: "SYSTEM_EXECUTE_SQL"
    description: "Execute SQL queries."
    title: "SQL Execution"
$$;

-- For YAML file in stage:
-- identifier: "@ANALYTICS_DB.MODELS.SEMANTIC_STAGE/sales_model.yaml"

-- -----------------------------------------------------------------------------
-- WITH CORTEX AGENT
-- Requires: Cortex Agent created in Snowflake
-- -----------------------------------------------------------------------------
CREATE OR REPLACE MCP SERVER agent_mcp_server FROM SPECIFICATION
$$
tools:
  - name: "Documentation Agent"
    identifier: "AGENTS_DB.PUBLIC.DOCS_AGENT"
    type: "CORTEX_AGENT_RUN"
    description: "An intelligent agent that answers questions about documentation."
    title: "Documentation Agent"
  - name: "SQL Execution Tool"
    type: "SYSTEM_EXECUTE_SQL"
    description: "Execute SQL queries."
    title: "SQL Execution"
$$;

-- -----------------------------------------------------------------------------
-- WITH CUSTOM TOOL (Stored Procedure)
-- Requires: Stored procedure with proper signature
-- -----------------------------------------------------------------------------

-- First, create the stored procedure
CREATE OR REPLACE PROCEDURE MY_DB.DATA.SEND_EMAIL(
    body STRING,
    recipient_email STRING,
    subject STRING
)
RETURNS STRING
LANGUAGE PYTHON
RUNTIME_VERSION = '3.11'
PACKAGES = ('snowflake-snowpark-python')
HANDLER = 'send_email'
AS
$$
def send_email(session, body, recipient_email, subject):
    # Implementation here
    return f"Email sent to {recipient_email}"
$$;

-- Then create MCP server with custom tool
CREATE OR REPLACE MCP SERVER custom_mcp_server FROM SPECIFICATION
$$
tools:
  - name: "Send_Email"
    identifier: "MY_DB.DATA.SEND_EMAIL"
    type: "GENERIC"
    description: "Send emails to verified email addresses."
    title: "Send Email"
    config:
      type: "procedure"
      warehouse: "COMPUTE_WH"
      input_schema:
        type: "object"
        properties:
          body:
            description: "Email body content. Use HTML syntax."
            type: "string"
          recipient_email:
            description: "Recipient email address."
            type: "string"
          subject:
            description: "Email subject line."
            type: "string"
  - name: "SQL Execution Tool"
    type: "SYSTEM_EXECUTE_SQL"
    description: "Execute SQL queries."
    title: "SQL Execution"
$$;

-- -----------------------------------------------------------------------------
-- FULL FEATURED SERVER (All tool types)
-- -----------------------------------------------------------------------------
CREATE OR REPLACE MCP SERVER full_mcp_server FROM SPECIFICATION
$$
tools:
  - name: "Financial Analytics"
    identifier: "ANALYTICS_DB.DATA.FINANCIAL_SEMANTIC_VIEW"
    type: "CORTEX_ANALYST_MESSAGE"
    description: "Query financial metrics, customer data, transactions, and risk assessments using natural language."
    title: "Financial Analytics"
  - name: "Support Tickets Search"
    identifier: "SUPPORT_DB.DATA.TICKETS_SEARCH"
    type: "CORTEX_SEARCH_SERVICE_QUERY"
    description: "Search support tickets, customer interactions, and knowledge base articles."
    title: "Support Search"
  - name: "Documentation Agent"
    identifier: "AGENTS_DB.PUBLIC.DOCS_AGENT"
    type: "CORTEX_AGENT_RUN"
    description: "An agent that answers questions about company documentation."
    title: "Documentation Agent"
  - name: "SQL Execution Tool"
    type: "SYSTEM_EXECUTE_SQL"
    description: "Execute SQL queries against Snowflake database."
    title: "SQL Execution"
  - name: "Send_Email"
    identifier: "UTILS_DB.DATA.SEND_EMAIL"
    type: "GENERIC"
    description: "Send emails to verified addresses."
    title: "Send Email"
    config:
      type: "procedure"
      warehouse: "COMPUTE_WH"
      input_schema:
        type: "object"
        properties:
          body:
            description: "Email body in HTML format."
            type: "string"
          recipient_email:
            description: "Recipient email address."
            type: "string"
          subject:
            description: "Email subject line."
            type: "string"
$$;

-- -----------------------------------------------------------------------------
-- UTILITY QUERIES
-- -----------------------------------------------------------------------------

-- List all MCP servers in current schema
SHOW MCP SERVERS;

-- Describe an MCP server
DESCRIBE MCP SERVER my_mcp_server;

-- Drop an MCP server
DROP MCP SERVER my_mcp_server;

-- Get your account identifier (for connection URL)
SELECT CURRENT_ACCOUNT();
SELECT CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME();


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)