mcp-snowflake-service
by: datawiz168
MCP server implementation for Snowflake integration
📌Overview
Purpose: To provide Claude with reliable access to Snowflake databases through a Model Context Protocol (MCP) server.
Overview: This server implements the Model Context Protocol, enabling Claude to execute SQL queries on Snowflake databases while managing the database connection lifecycle efficiently and safely.
Key Features:
-
SQL Query Execution: Empowers Claude to perform SQL queries on Snowflake databases seamlessly.
-
Automatic Connection Management: Handles lifecycle events such as connecting, reconnecting on timeouts, and closing connections to enhance reliability.
-
Error Handling: Manages query results and errors robustly to ensure smooth database interactions.
-
Secure Operations: Facilitates safe database operations, protecting data integrity during transactions.
MCP Snowflake Service
A Model Context Protocol (MCP) server that provides Claude access to Snowflake databases.
This server implements the Model Context Protocol to allow Claude to:
- Execute SQL queries on Snowflake databases
- Automatically handle database connection lifecycle (connect, reconnect on timeout, close)
- Handle query results and errors
- Perform database operations safely
Installation / 安装
- Clone this repository / 克隆此仓库
git clone https://github.com/datawiz168/mcp-snowflake-service.git
- Install dependencies / 安装依赖
pip install -r requirements.txt
Configuration / 配置说明
MCP Client Configuration Example / MCP 客户端配置示例
Add the following configuration to claude_desktop_config.json
/ 在 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. Please modify this according to your Python installation location.args
: Full path to the server script. Please modify this according to where you cloned the repository.
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 / Snowflake 配置
Create a .env
file in the project root directory and add the following configuration / 在项目根目录下创建 .env
文件,添加以下配置:
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
Development / 开发
To contribute code or report issues:
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License / 许可
This project is licensed under the MIT License.
此项目采用 MIT 许可证。