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
Setup instructions
Provider
David Amom
Release date
Mar 20, 2025
Language
Python
Stats
4 stars

The Snowflake MCP Server implements the Model Context Protocol to provide AI applications with secure access to Snowflake databases. It handles SQL query execution, manages database connections, and works with any MCP-compatible client like Claude.

Installation

Prerequisites

git clone https://github.com/davidamom/snowflake-mcp.git
pip install -r requirements.txt

Configuration

Setting Up Your Snowflake Connection

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

# 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

Authentication Methods

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
    

If both methods are configured, key pair authentication takes priority.

Client Configuration

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

Windows Example

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

MacOS/Linux Example

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

Usage

Standard Usage

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

python server.py

Using Docker

For production environments, Docker is recommended:

  1. Build the image:
docker build -t snowflake-mcp .
  1. Configure your MCP client with 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",
        "SNOWFLAKE_ROLE": "your_role"
      }
    }
  }
}

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_ROLE": "your_role",
        "SNOWFLAKE_PRIVATE_KEY_FILE": "path_for_your_private_key",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "your_password_for_private_key"
      }
    }
  }
}

Features and Capabilities

The Snowflake MCP Server provides:

  • SQL Query Execution: Execute queries against your Snowflake database
  • Connection Management: Automatic handling of connection lifecycle
  • Flexible Authentication: Support for both password and key pair authentication
  • Error Handling: Robust error reporting and recovery
  • CSV Export: Export query results to CSV files
  • Compatibility: Works with any MCP-compliant client

The server exposes two main tools to MCP clients:

  • execute_query: Run SQL queries and return structured results
  • export_to_csv: Execute a query and save results to a CSV file

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "snowflake" '{"command":"python","args":["server.py"]}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "snowflake": {
            "command": "python",
            "args": [
                "server.py"
            ]
        }
    }
}

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "snowflake": {
            "command": "python",
            "args": [
                "server.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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