Snowflake MCP Server

Snowflake MCP Server

Enables AI assistants to securely connect to Snowflake data warehouses and execute SQL queries through natural language interactions. Supports multiple authentication methods and provides formatted query results with built-in security controls.

Category
访问服务器

README

General-Purpose Snowflake MCP Server

A secure Model Context Protocol (MCP) server that provides AI assistants with safe, efficient access to your Snowflake data warehouse. Execute SQL queries, analyze data, and get insights through natural language interactions.

For more detail information and example usages, reference the Blog.

Python License: MIT

Key Features

  • 🔐 Multiple Authentication: Password, private key, and SSO support
  • 🛡️ Security First: Environment-based config, no hard-coded credentials
  • Performance Optimized: Configurable limits and efficient query execution
  • 🔍 Smart Error Handling: Detailed messages with troubleshooting guidance
  • 📊 Rich Query Results: Formatted tables with metadata and row counts
  • 🧠 AI-Ready: Natural language to SQL through MCP protocol
  • 🏗️ Universal Compatibility: Works with any MCP-compatible AI client

Quick Start

1. Install

git clone https://github.com/sfc-gh-tjia/snowflake-generic-mcp.git
cd snowflake-generic-mcp
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

2. Configure

cp .env.example .env
nano .env  # Add your Snowflake credentials

3. Test

npx @modelcontextprotocol/inspector python snowflake_mcp_server.py

Configuration

Environment Variables

Required:

SNOWFLAKE_ACCOUNT=your-account-identifier  # e.g., abc12345.us-east-1.snowflakecomputing.com
SNOWFLAKE_USERNAME=your-username

Authentication (choose one):

# Option 1: Password
SNOWFLAKE_PASSWORD=your-password

# Option 2: Private Key (recommended)
SNOWFLAKE_PRIVATE_KEY_PATH=/path/to/rsa_key.p8
SNOWFLAKE_PRIVATE_KEY_PASSPHRASE=passphrase  # optional

# Option 3: SSO
SNOWFLAKE_AUTHENTICATOR=externalbrowser

Optional:

SNOWFLAKE_WAREHOUSE=your_warehouse
SNOWFLAKE_DATABASE=your_database
SNOWFLAKE_SCHEMA=your_schema
SNOWFLAKE_ROLE=your_role
SNOWFLAKE_MAX_ROWS=100

Private Key Setup (Recommended)

  1. Generate key pair:
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
  1. Add public key to Snowflake:
ALTER USER your_username SET RSA_PUBLIC_KEY='your-public-key-content';

AI Tool Integration

Connect the MCP server to your AI assistant for natural language database interactions.

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "snowflake": {
      "command": "/opt/homebrew/bin/uv",
      "args": ["--directory", "/path/to/your/project", "run", "snowflake_mcp_server.py"]
    }
  }
}

Cursor

Option 1: Project-specific in Cursor Settings → Tools & Integration → MCP tools
Option 2: Global config in ~/.cursor/mcp.json

{
  "mcpServers": {
    "snowflake": {
      "command": "/opt/homebrew/bin/uv", 
      "args": ["--directory", "/absolute/path/to/your/project", "run", "snowflake_mcp_server.py"]
    }
  }
}

Example Usage

Once connected, you can interact with your Snowflake data using natural language:

"What tables are available in my database?"
"Show me the schema of the users table"
"Find all customers who made purchases this month"
"Analyze sales trends for Q4"
"Help me optimize this slow query"
"Count records in each table"
"Show me the top 10 customers by revenue"

The server handles:

  • Query execution with proper formatting and metadata
  • Error handling with helpful troubleshooting suggestions
  • Security logging for dangerous operations
  • Performance limits to prevent resource exhaustion

Security Best Practices

⚠️ IMPORTANT SECURITY NOTICE: This server executes raw SQL queries on your Snowflake instance. Always follow these security practices:

  1. Use private key authentication instead of passwords
  2. Create dedicated Snowflake user with minimal permissions:
CREATE USER mcp_user PASSWORD = 'secure_password';
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO USER mcp_user;
GRANT USAGE ON DATABASE your_db TO USER mcp_user;
GRANT SELECT ON ALL TABLES IN SCHEMA your_db.public TO USER mcp_user;
  1. Secure private keys: chmod 600 /path/to/rsa_key.p8
  2. Use environment variables - never hard-code credentials
  3. Use project-specific configurations for sensitive environments
  4. ⚠️ SQL Injection Risk: This server executes any SQL query provided by AI assistants. Ensure:
    • Your Snowflake user has minimal required permissions
    • No admin or elevated privileges for the MCP user
    • Consider using read-only access for sensitive environments
    • Monitor query logs for unexpected operations
  5. Network Security: Ensure proper firewall rules and VPN access if required

Troubleshooting

Common Issues

Environment Variables Not Set:

  • Check .env file format (no quotes, no spaces around =)
  • Set variables in shell profile for global access

Connection Errors:

  • Verify account identifier format (include region if needed)
  • Check network connectivity and warehouse status
  • Verify credentials and permissions

Authentication Failures:

  • For private key: Ensure public key is set in Snowflake
  • For SSO: Test browser login first
  • Check if user account is locked

Path Issues:

  • Use absolute paths in configuration files
  • Verify paths with which uv or which python

Debug Mode

Server Logs:

export MCP_LOG_LEVEL=DEBUG
python snowflake_mcp_server.py

Client Logs:

  • Claude Desktop: ~/Library/Logs/Claude/mcp*.log
  • Cursor: Output panel → "MCP Logs"

License

MIT License - see LICENSE file for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选