cost-guard-mcp
Pre-flight query cost & result-size guardrails for AI agents, across BigQuery and Snowflake — before the query ever runs.
Why
An AI agent using a warehouse MCP can silently trigger a full-table scan that costs hundreds of dollars, or return millions of rows that flood its own context window. No existing warehouse MCP tells the agent "how much will this cost" or "how much data will this return" before running the query.
What makes this different
- Every cost estimate discloses its accuracy tier —
PRECISE(BigQuerydryRun),UPPER_BOUND(SnowflakeEXPLAIN), orHEURISTIC(Databricks, not yet shipped) — so your agent never over-trusts a heuristic number. - Per-call bounds —
run_query_boundedtakesmax_bytes_billed/max_rows/max_estimated_cost_usdon each call; no shared session state required. - Zero infrastructure — a single local stdio process. No database, no gateway, no Docker Compose.
Tools
describe_engine_capabilities(engine)— what's exact vs. approximate for this engine.estimate_query_cost(engine, sql, warehouse?)— pre-flight cost estimate, tagged with its accuracy tier.run_query_bounded(engine, sql, max_bytes_billed?, max_rows?, max_estimated_cost_usd?)— refuses to run if the estimate exceeds your bound.
Setup
BigQuery
Set GOOGLE_APPLICATION_CREDENTIALS to a service-account key file path (or run gcloud auth application-default login).
Snowflake
Set SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_ROLE (required — no default, never ACCOUNTADMIN), and either SNOWFLAKE_PRIVATE_KEY_PATH (preferred) or SNOWFLAKE_PASSWORD (discouraged).
A note on credentials with MCP hosts
Whatever MCP client/host you use (Claude Desktop, etc.) spawns this server as its own subprocess — it does not automatically inherit your shell's environment variables, even if they're set in your .zshrc/.bashrc. Put them directly in the host's server config instead. For Claude Desktop's claude_desktop_config.json:
{
"mcpServers": {
"cost-guard-mcp": {
"command": "uv",
"args": ["run", "--directory", "/path/to/cost-guard-mcp", "cost-guard-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"BIGQUERY_PROJECT": "your-project-id",
"SNOWFLAKE_ACCOUNT": "your-account",
"SNOWFLAKE_USER": "your-user",
"SNOWFLAKE_ROLE": "your-role",
"SNOWFLAKE_PRIVATE_KEY_PATH": "/path/to/rsa_key.p8"
}
}
}
}
Install
Not yet published to PyPI — for now, clone and run directly:
git clone https://github.com/mcpsmiths/cost-guard-mcp.git
cd cost-guard-mcp
uv sync
uv run cost-guard-mcp
Once published, uvx cost-guard-mcp will work as a one-line install.
Known limitations
- Databricks is not yet supported (deferred past v1).
- Snowflake's
UPPER_BOUNDestimate excludes Cortex AI Function ("AI Credits") cost. - BigQuery Editions/capacity-billed projects cannot get a dollar estimate — only a byte count (capacity billing has no fixed $/byte rate).
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cost_guard_mcp-0.1.0.tar.gz.
File metadata
- Download URL: cost_guard_mcp-0.1.0.tar.gz
- Upload date:
- Size: 107.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67e0e9adf72d6126da2615f119bd2d211fb8c20da9c99f53c15ea49c85876ca3
|
|
| MD5 |
f696e7bbfdb6b43327942c63c2f0945f
|
|
| BLAKE2b-256 |
85d3b4185a16799a2f99e312b43fe75c06dafdfecbf2ceefab61bb6646bf1ba2
|
File details
Details for the file cost_guard_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cost_guard_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
051e6331c0057bdcdb58fc58e56f353f3bc892fa219ee1e1703a1734c5226497
|
|
| MD5 |
5b8d924dad7459aea42dbe0ca1e30496
|
|
| BLAKE2b-256 |
971ba6d386d2ea5559417b0dac7eeec391d46fbbc0054c4b712e22f6b79c80a4
|