Snowflake MCP server

Provides secure access to Snowflake databases with robust connection management, supporting both password and key pair authentication for SQL query execution and data analysis workflows.
Back to servers
Provider
David Amom
Release date
Mar 20, 2025
Language
Python
Stats
2 stars

The Snowflake MCP server implements the Model Context Protocol to connect any MCP-compatible client with Snowflake databases. It allows you to execute SQL queries, automatically manages database connections, and supports both password and key pair authentication methods.

Installation

  1. Clone the repository
git clone https://github.com/davidamom/snowflake-mcp.git
  1. Install dependencies
pip install -r requirements.txt

Configuration

Setting Up Your MCP Client

Configure your MCP client to use the Snowflake MCP server. Below is an example for Claude Desktop:

{
  "mcpServers": {
    "snowflake": {
      "command": "C:\\Users\\YourUsername\\path\\to\\python.exe",
      "args": ["C:\\path\\to\\snowflake-mcp\\server.py"]
    }
  }
}

Example configurations for different operating systems:

Windows:

{
  "mcpServers": {
    "snowflake": {
      "command": "C:\\Users\\YourUsername\\anaconda3\\python.exe",
      "args": ["C:\\Path\\To\\snowflake-mcp\\server.py"]
    }
  }
}

MacOS/Linux:

{
  "mcpServers": {
    "snowflake": {
      "command": "/usr/bin/python3",
      "args": ["/path/to/snowflake-mcp/server.py"]
    }
  }
}

Snowflake Configuration

Create a .env file in the project root directory with your Snowflake settings:

# Snowflake Configuration - Basic Info
SNOWFLAKE_USER=your_username          # Your Snowflake username
SNOWFLAKE_ACCOUNT=YourAccount.Region  # Example: MyOrg.US-WEST-2
SNOWFLAKE_DATABASE=your_database      # Your database
SNOWFLAKE_WAREHOUSE=your_warehouse    # Your warehouse

# Authentication - Choose one method

Authentication Options

The server supports two authentication methods:

  1. Password Authentication

    SNOWFLAKE_PASSWORD=your_password      # Your Snowflake password
    
  2. Key Pair Authentication

    SNOWFLAKE_PRIVATE_KEY_FILE=/path/to/rsa_key.p8     # Path to private key file 
    SNOWFLAKE_PRIVATE_KEY_PASSPHRASE=your_passphrase   # Optional: passphrase if key is encrypted
    

    For key pair authentication, you must first set up key pair authentication with Snowflake. For instructions, refer to Snowflake documentation on key pair authentication.

If both methods are configured, the server will use key pair authentication.

Usage

Standard Usage

Once configured, the server will start automatically when your MCP client needs it. For testing purposes, you can start the server manually:

python server.py

Docker Usage

You can also run the server using Docker:

  1. Build the Docker image:
docker build -t snowflake-mcp .
  1. Configure your MCP client to use Docker:
{
  "mcpServers": {
    "snowflake-docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "snowflake-mcp"
      ],
      "env": {
        "SNOWFLAKE_USER": "your_username",
        "SNOWFLAKE_ACCOUNT": "your_account",
        "SNOWFLAKE_DATABASE": "your_database",
        "SNOWFLAKE_WAREHOUSE": "your_warehouse",
        "SNOWFLAKE_PASSWORD": "your_password"
      }
    }
  }
}

For key pair authentication with Docker, mount your private key file:

{
  "mcpServers": {
    "Snowflake-Docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "-v",
        "/path/to/your/key.p8:/app/rsa_key.p8:ro",
        "-v",
        "/path/to/export/dir/:/export/",
        "snowflake-mcp"
      ],
      "env": {
        "SNOWFLAKE_USER": "your_username",
        "SNOWFLAKE_ACCOUNT": "your_account",
        "SNOWFLAKE_DATABASE": "your_database",
        "SNOWFLAKE_WAREHOUSE": "your_warehouse",
        "SNOWFLAKE_PRIVATE_KEY_FILE": "/app/rsa_key.p8"
      }
    }
  }
}

Features

The server provides these key features:

  • Automatic Connection Management

    • Creates connections when needed
    • Handles timeouts and reconnections
    • Properly closes connections when done
  • Query Execution

    • Execute SQL queries on Snowflake
    • Process and return query results
    • Handle errors appropriately
  • Data Export

    • Export query results to CSV files
    • Compatible with any MCP-compliant client

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later