Skip to main content
Glama
alizubairs

snowflake-cost-mcp

by alizubairs

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.

Related MCP server: BigQuery FinOps MCP Server

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 .
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)

  1. Every built-in tool runs a hardcoded, parameterized SQL template — no string-built SQL from user input, ever.

  2. 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 plain SELECT / WITH ... SELECT.

  3. 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.

Available Tools

6 tools
find_expensive_queriesA

Find the slowest / most expensive successful queries in the lookback window, ranked by elapsed time. Each result includes a truncated query text preview, warehouse, user, elapsed seconds, and GB scanned.

Args: lookback_days: How many days back to look (default from server config). limit: Max number of queries to return (default from server config, typically 50).

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
lookback_daysNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so description must cover behavioral traits. It mentions it returns 'successful queries', ranked by elapsed time, and lists output fields (truncated query text, warehouse, user, etc.). It does not mention auth, rate limits, or potential repercussions, but for a read-only analysis tool, the disclosed behavior is sufficient and not misleading.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise: a single introductory sentence followed by a clear 'Args' block. Every sentence adds value, no redundancy. The information is front-loaded with the primary purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 simple parameters and an output schema (exists but not shown), the description adequately explains the return fields and ranking criteria. It lacks error handling or edge cases, but for a straightforward lookup tool, it is complete enough for an agent to use effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description includes an 'Args' section that explains both parameters: 'lookback_days' as how many days back to look (with default from server config) and 'limit' as max number of queries (default typically 50). The input schema only provides type and nullability, so the description adds essential meaning and default behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Find the slowest / most expensive successful queries', which is a specific verb ('Find') and resource ('successful queries'). It distinguishes from sibling tools like 'get_query_detail' (specific query) and 'run_readonly_query' (execute a query) by focusing on ranking expensive ones.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use or not use this tool versus alternatives, but the purpose is clear enough for an agent to infer that it's for finding expensive queries, while siblings serve different purposes (e.g., listing warehouses, getting details). No exclusions or when-not listed, but context is adequate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_query_detailA

Get full detail for a single query by its Snowflake QUERY_ID, including warehouse size, database/schema, elapsed time, bytes scanned, rows produced, and any error message.

Args: query_id: The Snowflake QUERY_ID (as shown in QUERY_HISTORY or the Snowsight UI).

ParametersJSON Schema
NameRequiredDescriptionDefault
query_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It lists output fields but does not disclose whether the operation is read-only, any side effects, or authorization requirements. The description is adequate but could be more transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise: a single sentence for purpose, a bullet list of output fields, and an Args section for the parameter. Every sentence adds value, and it is front-loaded with the core function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (though not shown), the description adequately lists the main fields returned. It could mention that the operation is read-only or non-destructive, but overall it provides sufficient context for an agent to use the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description must compensate. It provides a clear, helpful explanation for the lone parameter query_id: 'The Snowflake QUERY_ID (as shown in QUERY_HISTORY or the Snowsight UI).' This adds significant meaning beyond the schema field name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it gets full detail for a single query by QUERY_ID, naming specific fields returned. It distinguishes from sibling tools like find_expensive_queries and get_warehouse_credit_usage, which serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use the tool: for detailed info on a specific query. It provides clear context but does not explicitly state when not to use it or mention alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_warehouse_credit_usageA

Total Snowflake credits consumed per warehouse over the lookback window, split into compute vs. cloud services credits. Use this to see where spend is concentrated before drilling into individual warehouses or queries.

Args: lookback_days: How many days back to look (default from server config, typically 7).

ParametersJSON Schema
NameRequiredDescriptionDefault
lookback_daysNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations, so description carries full burden. It explains what the tool does and what output to expect (total credits per warehouse, split). Does not mention side effects but for a read-only aggregation tool this is sufficient. Could be more explicit about the scope (all warehouses, only active?).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences plus an Args block. Front-loaded with purpose, no wasted words. Efficiently conveys all necessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity (one param, output schema exists), the description covers purpose, usage context, and parameter. Could briefly note that it returns per-warehouse data, but output schema likely handles details. Missing maybe a note about data freshness or caching.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% so description must explain parameters. The one parameter 'lookback_days' is clearly described: 'How many days back to look (default from server config, typically 7).' Provides default behavior and typical value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states verb 'get' and resource 'warehouse credit usage'. Specifies aggregation per warehouse and split into compute vs cloud services. Distinguishes from siblings like find_expensive_queries or list_warehouses.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides usage context: 'Use this to see where spend is concentrated before drilling into individual warehouses or queries.' Implies a hierarchical analysis workflow. Does not explicitly mention when not to use, but context signals suggest alternatives exist.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_warehouse_right_sizing_recommendationsA

Heuristic right-sizing recommendations per warehouse, combining credit usage with query queueing behavior:

  • HIGH credits + very low query count -> likely oversized or left running idle; check auto-suspend and whether it's needed at all.

  • Meaningful average queued-overload time -> likely undersized or under-provisioned for concurrency; consider a larger size or a multi-cluster warehouse.

  • Otherwise -> no strong signal either way.

This is a heuristic starting point for investigation, not a guaranteed cost-saving recommendation -- always sanity-check against actual workload requirements before resizing a production warehouse.

Args: lookback_days: How many days back to look (default from server config).

ParametersJSON Schema
NameRequiredDescriptionDefault
lookback_daysNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses the heuristic nature, that it's a starting point not guaranteed, and advises caution. It explains the logic behind recommendations but does not detail return format or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with an introduction, bullet points for heuristics, and a caution. It is concise but front-loads the key purpose. Slightly verbose in the bullet examples but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the existence of an output schema (not shown), the description covers the tool's purpose, heuristic logic, and parameter meaning. It omits details on the exact output, but the output schema likely handles that. It is complete for a heuristic investigation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Only one parameter (lookback_days) with 0% schema coverage. Description adds 'default from server config' which provides context beyond the schema, but could specify format or range more clearly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it provides heuristic right-sizing recommendations per warehouse, combining credit usage and query queueing behavior. It differentiates from sibling tools like get_warehouse_credit_usage and list_warehouses by offering synthesized insights.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides scenarios for when to suspect oversized or undersized warehouses and advises sanity-checking before resizing. However, it does not explicitly state when not to use or mention alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_warehousesA

List all warehouses visible to the connected role, with size, auto-suspend, and auto-resume settings, and current running/queued query counts.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It indicates a read-only listing operation with specific data, but does not disclose edge cases, rate limits, or behavior under load. Adequate but not exceptional.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, 20 words, efficiently conveys all key points. Front-loaded with action and resource, then details. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and presence of output schema, description covers scope and key fields. Could mention pagination or default ordering, but for a simple list tool, it is sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has zero parameters, so description does not need to add semantics. Baseline 4 applies; description adds no parameter info but that is unnecessary. It does mention output fields.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the verb 'list' and resource 'warehouses', specifies exact details returned (size, auto-suspend/resume settings, query counts), and implicitly distinguishes from siblings that deal with queries or recommendations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description implies usage for listing warehouses, but lacks explicit guidance on when to use this vs alternatives like get_warehouse_credit_usage or run_readonly_query. No exclusions or prerequisites mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

run_readonly_queryA

Run an arbitrary read-only SELECT query against Snowflake, for cost or performance investigation beyond the built-in tools. Disabled by default -- must be explicitly enabled via SNOWFLAKE_MCP_ALLOW_ARBITRARY_QUERIES=true in the server environment. Only SELECT / WITH...SELECT statements are accepted; the connected Snowflake role should also be read-only as the primary security boundary.

Args: sql: A single read-only SELECT statement.

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses read-only nature, security boundary via role limitation, and enablement requirement. With no annotations, description carries full burden and does well, though rate limits or error handling omitted.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences plus a one-line parameter doc, front-loaded with purpose and constraints. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given one parameter and output schema present, description adequately covers purpose, constraints, enablement, and parameter semantics. Output schema details not needed in description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% coverage but description clarifies 'sql' must be a 'single read-only SELECT statement', adding constraint beyond the schema. Compensates for missing schema description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States 'run an arbitrary read-only SELECT query against Snowflake' with specific purpose 'for cost or performance investigation beyond the built-in tools', clearly distinguishing from sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Indicates it is disabled by default and must be explicitly enabled, only accepts SELECT/WITH...SELECT, and advises a read-only role. Could explicitly mention alternatives but implies siblings are for common investigations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 6 tool updatesv0.1.0
    • First observedfind_expensive_queries
    • First observedget_query_detail
    • First observedget_warehouse_credit_usage
    • First observedget_warehouse_right_sizing_recommendations
    • First observedlist_warehouses
    • First observedrun_readonly_query

TDQS

A4.4/5.0
Disambiguation5/5

Each tool targets a distinct aspect of Snowflake cost and performance: queries (expensive vs detail), warehouses (credit usage, sizing recommendations, listing), and a fallback for arbitrary queries. No overlap in purpose.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern using snake_case (find_expensive_queries, get_query_detail, list_warehouses, etc.). Predictable and readable.

Tool Count5/5

With 6 tools, the surface is well-scoped for Snowflake cost management—covering query and warehouse analysis without bloat. Each tool earns its place.

Completeness4/5

Covers core cost investigation (expensive queries, warehouse usage, sizing) and includes a generic run tool for gaps. Missing finer breakdowns (e.g., by user/database) but no critical dead ends.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables intelligent data analysis and querying of Snowflake databases through specialized AI agents. Features 20+ tools for data operations, lineage tracing, usage analysis, and performance optimization with multi-agent architecture.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables cost optimization and financial operations for Google BigQuery through natural language interactions. Provides insights into BigQuery spending, usage patterns, and cost management recommendations.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides read-only access to Umbrella Cost finops platform, enabling natural language querying of multi-cloud cost data, optimization recommendations, anomaly detection, and budget tracking across AWS, Azure, and GCP.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI assistants to analyze cloud billing data in FOCUS format through natural language queries. Provides 36+ predefined cost analysis queries, custom SQL execution, and schema documentation for multi-cloud cost optimization and FinOps practices.
    11
    Apache 2.0

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alizubairs/Snowflake-Cost-Performance-MCP-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server