MCP HubMCP Hub
isaacwasserman

mcp-snowflake-server

by: isaacwasserman

mcp snowflake server

46created 13/12/2024
Visit
snowflake

📌Overview

Purpose: To provide an implementation of the Model Context Protocol (MCP) for seamless database interaction with Snowflake, allowing users to execute SQL queries and access data insights dynamically.

Overview: The Snowflake MCP Server is designed to facilitate interaction with Snowflake databases through a range of tools and resources. It operates by executing SQL queries and maintaining a continuously updated memo of data insights, enhancing the analytical capabilities of users.

Key Features:

  • Dynamic Resource (memo://insights): Automatically aggregates and updates data insights during analysis, enabling users to refer to a live data insights memo.

  • Core Tools:

    • read_query: Executes data retrieval queries and returns results as an array of objects.
    • write_query: Processes modifications to the database, such as INSERT, UPDATE, or DELETE commands, returning the number of affected rows.
    • create_table: Allows for the creation of new tables, providing confirmation upon successful creation.
    • list_tables: Retrieves a list of all tables within the database without requiring any input.
    • describe-table: Delivers detailed column information for specified tables, including names and types.
    • append_insight: Adds data insights to the memo resource, triggering an update for the insights memo.

Snowflake MCP Server

smithery badge PyPI - Version


Overview

A Model Context Protocol (MCP) server implementation providing database interaction with Snowflake. It enables running SQL queries via tools and exposes data insights and schema context as resources.


Components

Resources

  • memo://insights
    Continuously updated memo aggregating discovered data insights. Updated automatically when new insights are appended.

  • context://table/{table_name}
    (If prefetch enabled) Per-table schema summaries including columns and comments, exposed as individual resources.


Tools

Query Tools

  • read_query
    Execute SELECT queries to read data.
    Input:

    • query (string): The SELECT SQL query to execute
      Returns: Query results as array of objects
  • write_query (enabled only with --allow-write)
    Execute INSERT, UPDATE, or DELETE queries.
    Input:

    • query (string): SQL modification query
      Returns: Number of affected rows or confirmation
  • create_table (enabled only with --allow-write)
    Create new tables.
    Input:

    • query (string): CREATE TABLE SQL statement
      Returns: Confirmation of creation

Schema Tools

  • list_databases
    List all databases.
    Returns: Array of database names

  • list_schemas
    List schemas within a database.
    Input:

    • database (string)
      Returns: Array of schema names
  • list_tables
    List tables within a database and schema.
    Input:

    • database (string)
    • schema (string)
      Returns: Array of table metadata
  • describe_table
    View column information for a table.
    Input:

    • table_name (string): Fully qualified (database.schema.table)
      Returns: Array of column definitions with names, types, nullability, defaults, comments

Analysis Tools

  • append_insight
    Add data insights to the memo resource.
    Input:
    • insight (string)
      Returns: Confirmation
      Effect: Updates memo://insights resource

Usage with Claude Desktop

Installing via Smithery

To install Snowflake Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install mcp_snowflake_server --client claude

Installing via UVX

"mcpServers": {
  "snowflake_pip": {
    "command": "uvx",
    "args": [
      "--python=3.12",  
      "mcp_snowflake_server",
      "--account", "your_account",
      "--warehouse", "your_warehouse",
      "--user", "your_user",
      "--password", "your_password",
      "--role", "your_role",
      "--database", "your_database",
      "--schema", "your_schema"
      // Optionally: "--allow_write"
      // Optionally: "--log_dir", "/absolute/path/to/logs"
      // Optionally: "--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
      // Optionally: "--exclude_tools", "{tool_name}", ["{other_tool_name}"]
    ]
  }
}

Installing Locally

  1. Install Claude AI Desktop App.

  2. Install uv:

curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create a .env file with Snowflake credentials:
SNOWFLAKE_USER="xxx@your_email.com"
SNOWFLAKE_ACCOUNT="xxx"
SNOWFLAKE_ROLE="xxx"
SNOWFLAKE_DATABASE="xxx"
SNOWFLAKE_SCHEMA="xxx"
SNOWFLAKE_WAREHOUSE="xxx"
SNOWFLAKE_PASSWORD="xxx"
# Alternatively:
# SNOWFLAKE_AUTHENTICATOR="externalbrowser"
  1. [Optional] Modify runtime_config.json to set exclusion patterns for databases, schemas, or tables.

  2. Test locally:

uv --directory /absolute/path/to/mcp_snowflake_server run mcp_snowflake_server
  1. Add the server to your claude_desktop_config.json:
"mcpServers": {
  "snowflake_local": {
    "command": "/absolute/path/to/uv",
    "args": [
      "--python=3.12",
      "--directory", "/absolute/path/to/mcp_snowflake_server",
      "run", "mcp_snowflake_server"
      // Optionally: "--allow_write"
      // Optionally: "--log_dir", "/absolute/path/to/logs"
      // Optionally: "--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
      // Optionally: "--exclude_tools", "{tool_name}", ["{other_tool_name}"]
    ]
  }
}

Notes

  • Write operations are disabled by default; enable explicitly with --allow-write.
  • Supports filtering specific databases, schemas, or tables via exclusion patterns.
  • Exposes additional per-table context resources if prefetching is enabled.
  • The append_insight tool updates the memo://insights resource dynamically.

License

MIT