Snowflake MCP server

Integration with Snowflake databases, enabling execution of SQL queries and analysis of enterprise data.
Back to servers
Provider
datawiz168
Release date
Dec 07, 2024
Language
Python
Stats
32 stars

This MCP server implements the Model Context Protocol to allow Claude to execute SQL queries on Snowflake databases. It handles database connections automatically, manages query results and errors, and performs database operations safely.

Installation

Installing via Smithery

To install mcp-service-snowflake for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @datawiz168/mcp-service-snowflake --client claude

Manual Installation

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

Configuration

MCP Client Configuration

Add the following configuration to claude_desktop_config.json:

{
  "mcpServers": {
    "snowflake": {
      "command": "C:\\Users\\K\\anaconda3\\envs\\regular310\\python.exe",
      "args": ["D:\\tools\\mcp-snowflake\\server.py"]
    }
  }
}

Configuration parameters:

  • command: Full path to your Python interpreter
  • args: Full path to the server script

Example paths for different operating systems:

Windows:

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

MacOS/Linux:

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

Snowflake Configuration

Create a .env file in the project root directory with the following configuration:

SNOWFLAKE_USER=your_username      # Your username
SNOWFLAKE_PASSWORD=your_password  # Your password
SNOWFLAKE_ACCOUNT=NRB18479.US-WEST-2    # Example: NRB18479.US-WEST-2
SNOWFLAKE_DATABASE=your_database  # Your database
SNOWFLAKE_WAREHOUSE=your_warehouse # Your warehouse

Connection Management

The server provides automatic connection management features:

  • Automatic connection initialization

    • Creates connection when first query is received
    • Validates connection parameters
  • Connection maintenance

    • Keeps track of connection state
    • Handles connection timeouts
    • Automatically reconnects if connection is lost
  • Connection cleanup

    • Properly closes connections when server stops
    • Releases resources appropriately

Usage

The server will start automatically with the Claude Desktop client. No manual startup is required. Once the server is running, Claude will be able to execute Snowflake queries.

For development testing, you can start the server manually:

python server.py

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

Features

  • Secure Snowflake database access
  • Robust error handling and reporting
  • Automatic connection management
  • Query execution and result processing

Access Control

mcp-server-snowflake controls database access rights precisely through database users. If you only need to read data, simply assign a user with read-only database permissions.

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