Pre-flight query cost & result-size guardrails for AI agents across BigQuery and Snowflake
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
One-click editor setup isnβt available for this listing yet β we donβt have a confirmed install command, and weβd rather show nothing than point your editor at the wrong package or host. Follow the projectβs own setup instructions, linked above.
Pre-flight query cost & result-size guardrails for AI agents, across BigQuery, Snowflake, and Databricks β before the query ever runs.
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.
PRECISE (BigQuery dryRun), UPPER_BOUND (Snowflake EXPLAIN), or HEURISTIC (Databricks EXPLAIN COST) β so your agent never over-trusts a heuristic number.run_query_bounded takes max_bytes_billed / max_rows / max_estimated_cost_usd on each call; no shared session state required.check_credentials(engine, warehouse?) β verifies credentials/connectivity without running any real query; call this first after configuring a new engine. Supports BigQuery, Snowflake, and Databricks.describe_engine_capabilities(engine) β what's exact vs. approximate for this engine.estimate_query_cost(engine, sql, warehouse?, warehouse_size?, edition?) β pre-flight cost estimate, tagged with its accuracy tier. Supports BigQuery, Snowflake, and Databricks. warehouse_size (Snowflake/Databricks) and edition (Snowflake) default to the smallest/standard tier if omitted β set them to match the warehouse you actually run on, or the dollar figure understates cost on a larger one.run_query_bounded(engine, sql, max_bytes_billed?, max_rows?, max_estimated_cost_usd?, warehouse?, warehouse_size?, edition?) β refuses to run if the estimate exceeds your bound. Supports BigQuery, Snowflake, and Databricks.Set GOOGLE_APPLICATION_CREDENTIALS to a service-account key file path (or run gcloud auth application-default login).
Set SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_ROLE (required β no default, never ACCOUNTADMIN), and either SNOWFLAKE_PRIVATE_KEY_PATH (preferred) or SNOWFLAKE_PASSWORD (discouraged).
Set DATABRICKS_SERVER_HOSTNAME and DATABRICKS_HTTP_PATH (from the SQL warehouse's
Connection Details tab), and either DATABRICKS_TOKEN (a personal access token,
simplest) or DATABRICKS_CLIENT_ID + DATABRICKS_CLIENT_SECRET (OAuth machine-to-machine
via a service principal, preferred for automated use). Only Serverless SQL warehouses are
priced accurately β see Known Limitations.
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 β see .mcp.json.example for the exact block, and the "Use with other AI coding tools" section below for where each specific tool wants it.
Also published on the official MCP Registry as io.github.mcpsmiths/cost-guard-mcp.
For local development instead:
Or via Docker:
This walks through the fastest path to a real tool call β no data of your own required (it uses a public BigQuery dataset), no Snowflake trial signup needed.
Get a GCP project with the BigQuery API enabled. Any project works, including the
free-tier Sandbox mode (no billing card required to run dryRun, which is all
estimate_query_cost does). Create one at
console.cloud.google.com if you don't have one.
Get Application Default Credentials: run gcloud auth application-default login
locally, or create a service-account key and point GOOGLE_APPLICATION_CREDENTIALS at
its JSON file.
Add the server to your MCP client β see .mcp.json.example,
filling in only GOOGLE_APPLICATION_CREDENTIALS (leave the Snowflake vars out entirely
for this quickstart).
Restart your MCP client so it picks up the new server config, then ask your agent to
call check_credentials on bigquery. This confirms your setup without running any real
query β you should get back "ok": true and a detail line naming your project. If you
get "ok": false instead, the detail field explains exactly what's missing (usually
GOOGLE_APPLICATION_CREDENTIALS not making it through to the server process β see the
credentials note above, and double check the value is set inside the client's own server
config block, not just your shell).
Ask your agent to call estimate_query_cost against a public dataset β for example:
Use cost-guard-mcp's estimate_query_cost tool on bigquery for this query:
SELECT name, SUM(number) AS total FROMbigquery-public-data.usa_names.usa_1910_2013GROUP BY name ORDER BY total DESC LIMIT 10
You'll know it worked when the response looks like this β the exact numbers will
differ, but accuracy_tier should read PRECISE:
cost-guard-mcp is a standard stdio MCP server β any MCP-compatible client works, not just Claude Desktop. Every client ultimately runs the same command/args/env; only the wrapping file format differs, so there's one canonical definition β .mcp.json.example β instead of a separately maintained copy per tool below.
There is no single file every tool reads automatically (each looks in its own location), but three of the four use the exact same mcpServers wrapper .mcp.json.example already has, so those need nothing more than copying it into place. Fill in your real credential values, then:
| Client | Where it goes | Change needed from .mcp.json.example |
|---|---|---|
| Claude Code | .mcp.json (project) | None β copy as-is, or claude mcp add-json cost-guard-mcp '<the "cost-guard-mcp" object>' |
| Claude Desktop | claude_desktop_config.json | None β copy as-is |
| Cursor | .cursor/mcp.json or ~/.cursor/mcp.json | Add "type": "stdio" inside the server object |
| GitHub Copilot (VS Code) | .vscode/mcp.json | Rename top-level key mcpServers β servers, add "type": "stdio" |
| OpenAI Codex CLI | ~/.codex/config.toml | Same fields, TOML syntax instead of JSON (below) β or codex mcp add cost-guard-mcp -- uvx cost-guard-mcp |
Codex is the one genuine exception (TOML, not JSON), so it still needs its own block:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/cost-guard-mcp)<a href="https://allmcps.com/mcp/cost-guard-mcp"><img src="https://allmcps.com/api/badge/cost-guard-mcp?style=directory" alt="Cost Guard MCP on AllMCPs" /></a>