Snowflake

by davidamom

1 stars
287 downloads
Not rated
GitHub

About

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.

Details

Author
davidamom
Repository
davidamom/snowflake-mcp
GitHub stars
1
Downloads
287
License
MIT License
Categories
Database, Other, Infrastructure, Productivity, Developer Tools, Design, AI, Search, Frontend, Security

- Secure Snowflake database access
- Automatic connection lifecycle management
- Password and key pair authentication
- SQL query execution and result processing
- Export queries to CSV files
- Compatible with any MCP-compliant client

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Snowflake
    Command (node, npx, python, etc.) /usr/bin/python3
    Arguments
    • Argument 1 /path/to/snowflake-mcp/server.py

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Below is an example configuration for Claude Desktop, but this server works with any MCP-compatible client. Each client may have its own configuration method:

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

Configuration parameters:
- command: Full path to your Python interpreter. Please modify this according to your Python installation location.
- args: Full path to the server script. Please modify this according to where you cloned the repository.

Example paths for different operating systems:

execute_query

Executes a SQL query on Snowflake and returns the results. Input: SQL query string. Output: Query results in a structured format.

export_to_csv

Executes a SQL query on Snowflake and returns the results. Input: SQL query string. Output: Number of rows exported and the file path of the output file.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

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

Linux

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

Macos

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

Windows

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

An MCP server for interacting with Snowflake databases.

A Model Context Protocol (MCP) server that provides access to Snowflake databases for any MCP-compatible client.

This server implements the Model Context Protocol to allow any MCP client to:

- Execute SQL queries on Snowflake databases
- Automatically handle database connection lifecycle (connect, reconnect on timeout, close)
- Handle query results and errors
- Perform database operations safely
- Connect using either password or key pair authentication

MCP is a standard protocol that allows applications to communicate with AI models and external services. It enables AI models to access tools and data sources beyond their training data, expanding their capabilities through a standardized communication interface. Key features include:

- Based on stdio communication (standard input/output)
- Structured tool definition and discovery
- Standardized tool call mechanism
- Structured results transmission

The Snowflake-MCP server consists of several key components:
- MCP Server- Central component that implements the MCP protocol and handles client requests
- Snowflake Connection Manager- Manages database connections, including creation, maintenance, and cleanup
- Query Processor- Executes SQL queries on Snowflake and processes the results
- Authentication Manager- Handles different authentication methods (password or private key)

The system works through the following communication flow:
- An MCP Client (such as Claude or other MCP-compatible application) sends a request to the MCP Server
- The MCP Server authenticates with Snowflake using credentials from the.envfile
- The MCP Server executes SQL queries on Snowflake
- Snowflake returns results to the MCP Server
- The MCP Server formats and sends the results back to the MCP Client

This architecture allows for seamless integration between AI applications and Snowflake databases while maintaining security and efficient connection management.

git clone https://github.com/davidamom/snowflake-mcp.git

Below is an example configuration for Claude Desktop, but this server works with any MCP-compatible client. Each client may have its own configuration method:

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

- command: Full path to your Python interpreter. Please modify this according to your Python installation location.
- args: Full path to the server script. Please modify this according to where you cloned the repository.

Example paths for different operating systems:

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

Create a.envfile in the project root directory and add the following configuration:

# 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 SNOWFLAKE_ROLE=your_role # Your role # Authentication - Choose one method

This MCP server supports two authentication methods:

SNOWFLAKE_PASSWORD=your_password # Your Snowflake password
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:

- Generate a key pair and register the public key with Snowflake
- Store the private key file securely on your machine
- Provide the full path to the private key file in the configuration

For instructions on setting up key pair authentication, refer toSnowflake documentation on key pair authentication.

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

The server provides automatic connection management features:

- Creates connection when first query is received
- Validates connection parameters

- Keeps track of connection state
- Handles connection timeouts
- Automatically reconnects if connection is lost

- Properly closes connections when server stops
- Releases resources appropriately

The server will start automatically when configured with your MCP client. No manual startup is required in normal operation. Once the server is running, your MCP client will be able to execute Snowflake queries.

For development testing, you can start the server manually using:

Note: Manual server startup is not needed for normal use. The MCP client will typically manage server startup and shutdown based on the configuration.

You can also run the server using Docker. This method is recommended for production environments and ensures consistent execution across different platforms.
- Configure your MCP client to use Docker. Example configuration:

{ "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", "SNOWFLAKE_ROLE": "your_role" } } } }

Note: The Docker implementation uses stdio for communication, so no ports need to be exposed.

If using key pair authentication with Docker, you'll need to mount your private key file:

docker run -i -v /path/to/your/key.p8:/app/rsa_key.p8:ro snowflake-mcp

And update your configuration accordingly:

{ "mcpServers": { "Snowflake-Docker": { "command": "docker", "args": [ "run", "-i", "-v", "/path/to/your/key.p8:/app/rsa_key.p8:ro", //optional "-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_ROLE": "your_role", "SNOWFLAKE_PRIVATE_KEY_FILE": "path_for_your_private_key", "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "your_password_for_private_key" } } } }

- Secure Snowflake database access
- Flexible authentication (password or key pair authentication)
- Robust error handling and reporting
- Automatic connection management
- Query execution and result processing
- Compatible with any MCP-compliant client

The implementation consists of several key classes and modules:

- server.py- The main entry point containing the MCP server implementation.
- SnowflakeConnection- Class that handles all Snowflake database operations, including:

- Connection establishment and reconnection
- Query execution and transaction management
- Connection maintenance and cleanup

- Registers available tools with the MCP framework
- Handles tool call requests from clients
- Manages the lifecycle of connections

The connection lifecycle is carefully managed to ensure reliability:
- Initialization- Connections are created lazily when the first query is received
- Validation- Connection parameters are validated before attempting to connect
- Monitoring- Connections are regularly tested for validity
- Recovery- Automatic reconnection if the connection is lost or times out
- Cleanup- Proper resource release when the server shuts down

The server exposes the following tool to MCP clients:

-

execute_query- Executes a SQL query on Snowflake and returns the results

- Input: SQL query string
- Output: Query results in a structured format

export_to_csv- Executes a SQL query on Snowflake and returns the results

- Input: SQL query string
- Output: Num rows exported. File path of the output file

This implementation follows best practices for both MCP protocol implementation and Snowflake database interaction.

This project is licensed under theMIT License. See theLICENSEfile for details.

Production-grade MCP server for Databricks: SQL Warehouses, Jobs API, multi-workspace support.

Read-only access to Snowflake databases. Requires Snowflake connection information provided via MCP client configuration.

A Snowflake MCP server — SQL queries, schema exploration, and data insights for AI assistants

API-first engine and MCP server that transforms declarative YAML model definitions into optimized SQL for Postgres, Snowflake, ClickHouse, Dremio, and Databricks

Interact with Snowflake databases to query and manage data.

Snowflake MCP server by CData for read-only querying of live Snowflake data from AI agents and MCP clients.

A read-only server for interacting with Snowflake databases, allowing SELECT queries and access to schema context.

Official MCP server for dbt (data build tool) providing integration with dbt Core/Cloud CLI, project metadata discovery, model information, and semantic layer querying capabilities.

Open source MCP server specializing in easy, fast, and secure tools for Databases.

Query and analyze data with MotherDuck and local DuckDB

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.