Snowflake MCP Server
Enables Claude to interact with Snowflake data warehouses through natural language for executing SQL queries, exploring schemas, and monitoring data freshness. It streamlines data analysis workflows by bringing Snowflake capabilities directly into the AI conversation.
README
Snowflake MCP Server 🎿
A Model Context Protocol (MCP) server that enables Claude to interact with your Snowflake data warehouse through natural language.
🌟 What is this?
Instead of logging into Snowflake UI and writing SQL manually, simply ask Claude in natural language and let it query your data warehouse for you!
This MCP server gives Claude the ability to:
- ✅ Execute SQL queries on Snowflake
- ✅ List tables in your schemas
- ✅ Describe table structures
- ✅ Check data freshness (when tables were last updated)
How It's Different
| Traditional Approach | With Snowflake MCP |
|---|---|
| Open Snowflake UI → Write SQL → Run → Copy results | Ask Claude → Get insights instantly |
| Context switching between tools | Everything in one conversation |
| Remember exact table/column names | Claude helps you discover schema |
| Repetitive daily checks | Automate monitoring workflows |
📋 Table of Contents
- Quick Start
- Installation
- Configuration
- Available Tools
- Usage Examples
- How It Works
- Security
- Extending
- Troubleshooting
- FAQ
- Contributing
- License
🚀 Quick Start
See QUICKSTART.md for a 5-minute setup guide!
# 1. Clone the repo
git clone https://github.com/Legolasan/snowflake_mcp.git
cd snowflake_mcp
# 2. Install dependencies
pip install -r requirements.txt
# 3. Configure credentials
cp .env.example .env
nano .env # Add your Snowflake credentials
# 4. Test connection
python test_connection.py
# 5. Add to Claude Code (see Configuration section)
📦 Installation
Prerequisites
- Python 3.8 or higher
- Snowflake account with access credentials
- Claude Code CLI (for MCP integration) - Get it here
Note: You do NOT need a separate Claude API key! The MCP server runs locally and only requires Snowflake credentials. See FAQ for details.
Install Dependencies
pip install -r requirements.txt
This installs:
mcp- Model Context Protocol SDKsnowflake-connector-python- Snowflake database driverpython-dotenv- Environment variable management
⚙️ Configuration
1. Snowflake Credentials
Copy the example environment file:
cp .env.example .env
Edit .env with your Snowflake credentials:
SNOWFLAKE_USER=your_username
SNOWFLAKE_PASSWORD=your_password
SNOWFLAKE_ACCOUNT=abc12345.us-east-1
SNOWFLAKE_WAREHOUSE=COMPUTE_WH
SNOWFLAKE_DATABASE=PROD_DB
SNOWFLAKE_SCHEMA=PUBLIC
Finding your account identifier:
- Your Snowflake URL:
https://abc12345.us-east-1.snowflakecomputing.com - Your account ID:
abc12345.us-east-1
⚠️ Security: Never commit .env to git! It's protected by .gitignore.
2. Claude Code MCP Configuration
Add this to your Claude Code MCP settings:
File: ~/.config/claude-code/mcp.json
Option A: Using .env file (Recommended)
{
"mcpServers": {
"snowflake": {
"command": "bash",
"args": [
"-c",
"source /path/to/snowflake_mcp/.env && python /path/to/snowflake_mcp/server.py"
]
}
}
}
Option B: Direct environment variables
{
"mcpServers": {
"snowflake": {
"command": "python",
"args": ["/path/to/snowflake_mcp/server.py"],
"env": {
"SNOWFLAKE_USER": "your_username",
"SNOWFLAKE_PASSWORD": "your_password",
"SNOWFLAKE_ACCOUNT": "your_account",
"SNOWFLAKE_WAREHOUSE": "COMPUTE_WH",
"SNOWFLAKE_DATABASE": "your_database",
"SNOWFLAKE_SCHEMA": "PUBLIC"
}
}
}
}
3. Restart Claude Code
After updating the MCP configuration, restart Claude Code to load the server.
🛠️ Available Tools
1. query_snowflake
Execute any SQL query on Snowflake and get formatted results.
Parameters:
sql(required): SQL query to executelimit(optional): Max rows to return (default: 100)
Example prompts:
- "Show me the top 10 customers by revenue"
- "How many orders were placed yesterday?"
- "What's the average order value this month?"
2. list_tables
List all tables in a schema with row counts.
Parameters:
schema(optional): Schema name (defaults to configured schema)
Example prompts:
- "What tables are available?"
- "List all tables in the ANALYTICS schema"
3. describe_table
Get detailed structure of a table (columns, types, constraints).
Parameters:
table_name(required): Name of the table
Example prompts:
- "Describe the ORDERS table"
- "What columns are in the CUSTOMERS table?"
- "Show me the schema for user_events"
4. check_table_freshness
Monitor when data was last updated (requires timestamp column).
Parameters:
table_name(required): Table to checktimestamp_column(optional): Timestamp column name (default: UPDATED_AT)
Example prompts:
- "When was the ORDERS table last updated?"
- "Is my ETL pipeline running? Check staging table freshness"
- "Show me data recency for all my tables"
💡 Usage Examples
Basic Queries
You: "What tables do we have in Snowflake?"
Claude: [uses list_tables]
"You have 12 tables including ORDERS, CUSTOMERS, PRODUCTS..."
You: "Show me the structure of the orders table"
Claude: [uses describe_table]
"The ORDERS table has 8 columns: ORDER_ID (NUMBER),
CUSTOMER_ID (NUMBER), ORDER_DATE (TIMESTAMP)..."
You: "Get the top 5 orders from today"
Claude: [uses query_snowflake with SQL]
"Here are the top 5 orders from today..."
Data Monitoring
You: "Is my data fresh? Check when orders table was last updated"
Claude: [uses check_table_freshness]
"Orders table was last updated 2 hours ago with 1,234 total rows"
You: "Are there any gaps in yesterday's data?"
Claude: [writes and executes SQL to check]
"I found a 3-hour gap between 2am-5am..."
Multi-Step Analysis
You: "Compare this week's sales to last week"
Claude: [executes multiple queries]
"This week: $125K (up 15% from last week's $108K)..."
You: "Show me the breakdown by category"
Claude: [refines query based on context]
"Electronics: +25%, Clothing: +10%, Home: -5%..."
🔍 How It Works
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ You ask │────────▶│ Claude Code │────────▶│ MCP Server │
│ Claude in │ │ decides │ │ executes │
│ natural │ │ which tool │ │ on │
│ language │ │ to use │ │ Snowflake │
└─────────────┘ └──────────────┘ └─────────────┘
│
▼
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Claude │◀────────│ Results │◀────────│ Snowflake │
│ analyzes & │ │ returned │ │ Database │
│ explains │ │ │ │ │
└─────────────┘ └──────────────┘ └─────────────┘
- You ask Claude a question about your data
- Claude decides which tool to use (or writes custom SQL)
- MCP server executes the query on Snowflake
- Results are returned to Claude
- Claude analyzes and responds with insights!
🔒 Security
Best Practices
- ✅ Use read-only credentials for the MCP server
- ✅ Never commit
.envfile to version control - ✅ Use dedicated warehouse for MCP queries
- ✅ Set resource monitors to control costs
- ✅ Review queries before execution (Claude shows them to you)
- ✅ Limit result sizes (default 100 rows, configurable)
Snowflake Permissions
Recommended minimal permissions:
-- Create a read-only role for MCP
CREATE ROLE MCP_READONLY;
-- Grant database and schema access
GRANT USAGE ON DATABASE PROD_DB TO ROLE MCP_READONLY;
GRANT USAGE ON SCHEMA PROD_DB.PUBLIC TO ROLE MCP_READONLY;
-- Grant SELECT on all tables
GRANT SELECT ON ALL TABLES IN SCHEMA PROD_DB.PUBLIC TO ROLE MCP_READONLY;
-- Grant warehouse usage
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE MCP_READONLY;
-- Assign role to user
GRANT ROLE MCP_READONLY TO USER mcp_user;
🚀 Extending This Server
Want to add more capabilities? Here's how:
Adding a New Tool
- Add the tool function in
server.py:
@self.app.call_tool()
async def check_data_quality(arguments: dict[str, Any]) -> list[TextContent]:
"""Check for nulls, duplicates, and anomalies"""
table_name = arguments.get("table_name")
# Your implementation here
conn = self._get_connection()
cursor = conn.cursor()
# ... run quality checks
return [TextContent(type="text", text=results)]
- Register the tool in the
toolsproperty:
Tool(
name="check_data_quality",
description="Check table for data quality issues",
inputSchema={
"type": "object",
"properties": {
"table_name": {"type": "string", "description": "Table to check"}
},
"required": ["table_name"]
}
)
- Restart the MCP server and Claude will have access to it!
Ideas for New Tools
- 📊 Data Quality Checks - Null counts, duplicates, outliers
- 💰 Cost Monitoring - Query costs, warehouse usage, credit burn
- ⚡ Performance Analysis - Slow queries, table statistics
- 🔄 Pipeline Monitoring - Stream lag, pipe status, task runs
- 📈 Automated Reports - Daily summaries, trend analysis
- 🔍 Schema Drift Detection - Track table changes over time
🐛 Troubleshooting
Connection Issues
"Connection failed" or "Authentication error"
- ✅ Verify credentials in
.envfile - ✅ Check Snowflake account identifier format
- ✅ Ensure warehouse is running
- ✅ Test with:
python test_connection.py
"Network timeout"
- ✅ Check firewall/VPN settings
- ✅ Verify Snowflake account is accessible
- ✅ Test connection from command line
MCP Server Issues
"Tool not found" or "Server not responding"
- ✅ Restart Claude Code after config changes
- ✅ Check MCP config file syntax (valid JSON)
- ✅ Verify file paths in MCP config are correct
- ✅ Check Claude Code logs for errors
"Permission denied"
- ✅ Verify Snowflake user has SELECT permissions
- ✅ Check database and schema names are correct
- ✅ Ensure warehouse has USAGE granted
Python/Dependency Issues
"ModuleNotFoundError: No module named 'mcp'"
- ✅ Run:
pip install -r requirements.txt - ✅ Use correct Python environment
"Snowflake connector errors"
- ✅ Update connector:
pip install --upgrade snowflake-connector-python - ✅ Check Python version (3.8+ required)
❓ Frequently Asked Questions
Do I need a Claude API key?
No! The MCP server itself does NOT require a Claude API key. Here's what you actually need:
What You Need:
- Claude Code CLI - Authenticate once with
claude auth login - Snowflake credentials - In your
.envfile - That's it!
How It Works:
┌─────────────────────┐
│ Claude Code CLI │ ← Uses your Claude subscription
└──────────┬──────────┘
│ Local communication (stdio)
┌──────────▼──────────┐
│ MCP Server │ ← NO API key needed!
│ (server.py) │ Just queries Snowflake
└──────────┬──────────┘
│ Snowflake credentials only
┌──────────▼──────────┐
│ Snowflake DB │
└─────────────────────┘
The MCP server is just a local tool provider that extends Claude Code's capabilities. It runs on your machine and only talks to Snowflake.
Cost Breakdown:
- ✅ Claude Code usage: Included in your Claude subscription
- ✅ MCP Server: Free (runs locally, no external API calls)
- ✅ Snowflake queries: Your normal Snowflake compute costs apply
Can I use this without Claude Code?
The MCP server is specifically designed to work with MCP-compatible clients like Claude Code. However, you could:
- Use it with other MCP clients (if they support MCP protocol)
- Adapt the code to work as a standalone CLI tool
- Use the Snowflake query functions directly in your own Python scripts
Is my data secure?
Yes! Here's why:
- ✅ Runs locally - MCP server runs on your machine
- ✅ Direct connection - Queries go straight to Snowflake
- ✅ No third-party servers - Your data never leaves your network
- ✅ Credentials stay local -
.envfile is never uploaded
Your Snowflake credentials and query results stay between your machine and Snowflake. Claude Code sees query results only when you ask it to analyze them.
What's the difference between this and Snowflake's UI?
| Feature | Snowflake UI | Snowflake MCP |
|---|---|---|
| Query execution | ✅ Manual | ✅ AI-assisted |
| Natural language | ❌ No | ✅ Yes |
| Multi-step analysis | Manual | ✅ Automated |
| Context across queries | ❌ No | ✅ Yes |
| Schema discovery | Manual search | ✅ Ask Claude |
| Daily monitoring | Repetitive | ✅ Can automate |
| Cost | Free | Free + Snowflake compute |
Does this work with other data warehouses?
The current implementation is Snowflake-specific, but the pattern can be adapted for:
- PostgreSQL
- MySQL
- BigQuery
- Databricks
- Redshift
- Any database with a Python connector!
Check the Contributing section if you want to add support for other databases.
🤝 Contributing
We welcome contributions! Here's how you can help:
Ways to Contribute
- 🐛 Report bugs - Open an issue with reproduction steps
- 💡 Suggest features - Share ideas for new tools
- 📝 Improve docs - Fix typos, add examples
- 🔧 Submit PRs - Add new tools or fix issues
Development Setup
# Fork and clone
git clone https://github.com/yourusername/snowflake_mcp.git
cd snowflake_mcp
# Install dev dependencies
pip install -r requirements.txt
# Create feature branch
git checkout -b feature/my-new-tool
# Make changes and test
python test_connection.py
# Submit PR!
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Model Context Protocol
- Uses Snowflake Python Connector
- Inspired by the power of AI-assisted data analysis
📚 Learn More
Built as a learning project for integrating AI with data warehouses 🚀
Questions? Open an issue or start a discussion!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。