snowflake-cost-mcp
Provides read-only visibility into Snowflake warehouse cost and query performance, including credit usage by warehouse, expensive queries, and heuristic right-sizing recommendations.
README
snowflake-cost-mcp
An MCP server that gives Claude (or any MCP-speaking agent) direct, read-only visibility into Snowflake warehouse cost and query performance — credit usage by warehouse, the most expensive queries in a window, and heuristic right-sizing recommendations.
Why this exists (and what it deliberately doesn't do)
Snowflake already ships an official, actively-developed managed MCP server covering schema browsing, Cortex Analyst/Search, and general query execution — and several community servers cover similar ground. This project intentionally does not duplicate any of that. It exists for the one thing none of them focus on: cost attribution and performance right-sizing, using Snowflake's ACCOUNT_USAGE views.
Use this alongside the official Snowflake MCP server, not instead of it.
Tools
| Tool | What it does |
|---|---|
list_warehouses |
Warehouse inventory: size, auto-suspend/resume, running/queued queries |
get_warehouse_credit_usage |
Credits consumed per warehouse over a lookback window |
find_expensive_queries |
Slowest/costliest successful queries in a window |
get_query_detail |
Full detail for one query by QUERY_ID |
get_warehouse_right_sizing_recommendations |
Heuristic oversized/undersized/no-signal call per warehouse |
run_readonly_query |
Ad-hoc SELECT-only escape hatch — disabled by default |
ACCOUNT_USAGE views are eventually consistent (Snowflake documents up to ~45 minutes–a few hours of latency), so treat results as "recent history," not real-time.
Prerequisites
You need a Snowflake role that can read ACCOUNT_USAGE. Create a dedicated, least-privilege role rather than reusing ACCOUNTADMIN:
CREATE ROLE IF NOT EXISTS mcp_cost_monitor;
GRANT IMPORTED PRIVILEGES ON DATABASE snowflake TO ROLE mcp_cost_monitor;
GRANT USAGE ON WAREHOUSE compute_xs TO ROLE mcp_cost_monitor;
GRANT ROLE mcp_cost_monitor TO USER your_service_user;
This role can read account usage metadata and nothing else — no write grants anywhere. That's the real security boundary; the in-code SQL guard is a backup, not a substitute for this.
Setup
1. Install
pip install -e .
2. Configure authentication (key-pair recommended)
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
ALTER USER your_service_user SET RSA_PUBLIC_KEY='<contents of rsa_key.pub, header/footer stripped>';
Copy .env.example to .env and fill in SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, and SNOWFLAKE_PRIVATE_KEY_PATH (pointing at rsa_key.p8). Username/password auth is supported as a fallback for local/dev use — see .env.example.
3. Run it standalone (sanity check)
snowflake-cost-mcp
It will sit waiting on stdio — that's expected; it's meant to be launched by an MCP client, not run interactively.
4. Wire it into Claude Desktop / Claude Code
{
"mcpServers": {
"snowflake-cost": {
"command": "snowflake-cost-mcp",
"env": {
"SNOWFLAKE_ACCOUNT": "your_account_identifier",
"SNOWFLAKE_USER": "your_service_user",
"SNOWFLAKE_PRIVATE_KEY_PATH": "/absolute/path/to/rsa_key.p8",
"SNOWFLAKE_ROLE": "MCP_COST_MONITOR"
}
}
}
}
Security model (defense in depth)
- Every built-in tool runs a hardcoded, parameterized SQL template — no string-built SQL from user input, ever.
run_readonly_query(the only tool that accepts free-form SQL) is off by default and, when enabled, is passed through a guard that rejects anything except a plainSELECT/WITH ... SELECT.- The Snowflake role itself should be read-only (see Prerequisites) — that's the boundary that actually matters if there's ever a bug in this server.
Development
pip install -e ".[dev]"
pytest -q
ruff check src tests
Tests run entirely against a mocked Snowflake connection — no live account needed to develop or run CI.
Roadmap
- Validate end-to-end against a real Snowflake trial account
- Publish to the public MCP registry
- Add a storage-cost tool (database/table storage spend)
- Optional streamable-HTTP transport for a hosted/enterprise mode
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。