这是一个实现与Snowflake数据库交互的模型上下文协议(MCP)服务器。该服务器允许通过工具运行SQL查询,并将数据洞察和模式上下文作为资源公开。
memo://insights
一个持续更新的备忘录,汇总了发现的数据洞察。
当通过append_insight工具添加新的洞察时,会自动更新。
context://table/{表名}
(如果启用了预取功能)每个表的模式摘要,包括列和注释,作为单独的资源公开。
该服务器公开以下工具:
read_query
执行SELECT查询以从数据库中读取数据。
输入:
query(字符串):要执行的SELECT SQL查询write_query(仅在启用--allow-write时可用)
执行INSERT、UPDATE或DELETE查询。
输入:
query(字符串):SQL修改查询create_table(仅在启用--allow-write时可用)
在数据库中创建新表。
输入:
query(字符串):CREATE TABLE SQL语句list_databases
列出Snowflake实例中的所有数据库。
返回值: 数据库名称数组
list_schemas
列出特定数据库内的所有模式。
输入:
database(字符串):数据库名称list_tables
列出特定数据库和模式内的所有表。
输入:
database(字符串):数据库名称schema(字符串):模式名称describe_table
查看特定表的列信息。
输入:
table_name(字符串):完全限定的表名(database.schema.table)append_insightinsight(字符串):从分析中发现的数据洞察memo://insights资源的更新要通过Smithery自动安装Snowflake服务器用于Claude Desktop:
npx -y @smithery/cli install mcp_snowflake_server --client claude
"mcpServers": {
"snowflake_pip": {
"command": "uvx",
"args": [
"--python=3.12", // 可选:指定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"
// 可选:"--private_key_path", "your_private_key_absolute_path"
// 可选:"--allow_write"
// 可选:"--log_dir", "/absolute/path/to/logs"
// 可选:"--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
// 可选:"--exclude_tools", "{tool_name}", ["{other_tool_name}"]
]
}
}
"mcpServers": {
"snowflake_production": {
"command": "uvx",
"args": [
"--python=3.12",
"mcp_snowflake_server",
"--connections-file", "/path/to/snowflake_connections.toml",
"--connection-name", "production"
// 可选:"--allow_write"
// 可选:"--log_dir", "/absolute/path/to/logs"
// 可选:"--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
// 可选:"--exclude_tools", "{tool_name}", ["{other_tool_name}"]
]
},
"snowflake_staging": {
"command": "uvx",
"args": [
"--python=3.12",
"mcp_snowflake_server",
"--connections-file", "/path/to/snowflake_connections.toml",
"--connection-name", "staging"
]
}
}
安装uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
.env文件:SNOWFLAKE_USER="xxx@your_email.com"
SNOWFLAKE_ACCOUNT="xxx"
SNOWFLAKE_ROLE="xxx"
SNOWFLAKE_DATABASE="xxx"
SNOWFLAKE_SCHEMA="xxx"
SNOWFLAKE_WAREHOUSE="xxx"
SNOWFLAKE_PASSWORD="xxx"
SNOWFLAKE_PASSWORD="xxx"
SNOWFLAKE_PRIVATE_KEY_PATH=/absolute/path/key.p8
# 或者使用外部浏览器认证:
# SNOWFLAKE_AUTHENTICATOR="externalbrowser"
[可选] 修改runtime_config.json以设置数据库、模式或表的排除模式。
本地测试:
uv --directory /absolute/path/to/mcp_snowflake_server run mcp_snowflake_server
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"
// 可选:"--allow_write"
// 可选:"--log_dir", "/absolute/path/to/logs"
// 可选:"--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
// 可选:"--exclude_tools", "{tool_name}", ["{other_tool_name}"]
]
}
}
"mcpServers": {
"snowflake_local": {
"command": "/absolute/path/to/uv",
"args": [
"--python=3.12",
"--directory", "/absolute/path/to/mcp_snowflake_server",
"run", "mcp_snowflake_server",
"--connections-file", "/absolute/path/to/snowflake_connections.toml",
"--connection-name", "development"
// 可选:"--allow_write"
// 可选:"--log_dir", "/absolute/path/to/logs"
// 可选:"--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
// 可选:"--exclude_tools", "{tool_name}", ["{other_tool_name}"]
]
}
}
--allow-write。append_insight工具会动态更新memo://insights资源。MIT