C

Cost Guard MCP

by mcpsmiths · io.github.mcpsmiths/cost-guard-mcp

Lets AI agents estimate the cost and result size of BigQuery and Snowflake queries before they run, then execute them only within per-call byte, row, and dollar bounds. Estimates are labeled with an accuracy tier so agents never over-trust an approximate figure.

pypi Local · stdio GlamaOfficial MCP Registry High confidence

Install

Add to ~/Library/Application Support/Claude/claude_desktop_config.json

Windows / Linux path
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "io-github-mcpsmiths-cost-guard-mcp": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "<YOUR_VALUE>",
        "SNOWFLAKE_ACCOUNT": "<VALUE>",
        "SNOWFLAKE_USER": "<VALUE>",
        "SNOWFLAKE_ROLE": "<VALUE>",
        "SNOWFLAKE_SECONDARY_ROLES": "<VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "<YOUR_VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "<YOUR_VALUE>",
        "SNOWFLAKE_PASSWORD": "<YOUR_VALUE>",
        "SNOWFLAKE_EDITION": "<VALUE>",
        "DATABRICKS_SERVER_HOSTNAME": "<VALUE>",
        "DATABRICKS_HTTP_PATH": "<VALUE>",
        "DATABRICKS_TOKEN": "<YOUR_VALUE>",
        "DATABRICKS_CLIENT_ID": "<VALUE>",
        "DATABRICKS_CLIENT_SECRET": "<YOUR_VALUE>",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "<VALUE>",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "<VALUE>",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "<VALUE>",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "<VALUE>",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "<VALUE>"
      }
    }
  }
}

Restart Claude Desktop to activate the new server.

Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)

Windows / Linux path
Windows: .cursor\mcp.json (project) or %USERPROFILE%\.cursor\mcp.json (global)
Linux: .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)
{
  "mcpServers": {
    "io-github-mcpsmiths-cost-guard-mcp": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "<YOUR_VALUE>",
        "SNOWFLAKE_ACCOUNT": "<VALUE>",
        "SNOWFLAKE_USER": "<VALUE>",
        "SNOWFLAKE_ROLE": "<VALUE>",
        "SNOWFLAKE_SECONDARY_ROLES": "<VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "<YOUR_VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "<YOUR_VALUE>",
        "SNOWFLAKE_PASSWORD": "<YOUR_VALUE>",
        "SNOWFLAKE_EDITION": "<VALUE>",
        "DATABRICKS_SERVER_HOSTNAME": "<VALUE>",
        "DATABRICKS_HTTP_PATH": "<VALUE>",
        "DATABRICKS_TOKEN": "<YOUR_VALUE>",
        "DATABRICKS_CLIENT_ID": "<VALUE>",
        "DATABRICKS_CLIENT_SECRET": "<YOUR_VALUE>",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "<VALUE>",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "<VALUE>",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "<VALUE>",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "<VALUE>",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "<VALUE>"
      }
    }
  }
}

Cursor usually picks up config changes automatically; if the server does not appear, reload the window.

Add to .mcp.json (project) or ~/.claude.json (global)

Windows / Linux path
Windows: .mcp.json (project) or %USERPROFILE%\.claude.json (global)
Linux: .mcp.json (project) or ~/.claude.json (global)
{
  "mcpServers": {
    "io-github-mcpsmiths-cost-guard-mcp": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "<YOUR_VALUE>",
        "SNOWFLAKE_ACCOUNT": "<VALUE>",
        "SNOWFLAKE_USER": "<VALUE>",
        "SNOWFLAKE_ROLE": "<VALUE>",
        "SNOWFLAKE_SECONDARY_ROLES": "<VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "<YOUR_VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "<YOUR_VALUE>",
        "SNOWFLAKE_PASSWORD": "<YOUR_VALUE>",
        "SNOWFLAKE_EDITION": "<VALUE>",
        "DATABRICKS_SERVER_HOSTNAME": "<VALUE>",
        "DATABRICKS_HTTP_PATH": "<VALUE>",
        "DATABRICKS_TOKEN": "<YOUR_VALUE>",
        "DATABRICKS_CLIENT_ID": "<VALUE>",
        "DATABRICKS_CLIENT_SECRET": "<YOUR_VALUE>",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "<VALUE>",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "<VALUE>",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "<VALUE>",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "<VALUE>",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "<VALUE>"
      }
    }
  }
}

The server will be available in the next Claude Code session.

Add to .vscode/mcp.json

Windows / Linux path
Windows: .vscode\mcp.json
Linux: .vscode/mcp.json
{
  "servers": {
    "io-github-mcpsmiths-cost-guard-mcp": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "<YOUR_VALUE>",
        "SNOWFLAKE_ACCOUNT": "<VALUE>",
        "SNOWFLAKE_USER": "<VALUE>",
        "SNOWFLAKE_ROLE": "<VALUE>",
        "SNOWFLAKE_SECONDARY_ROLES": "<VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "<YOUR_VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "<YOUR_VALUE>",
        "SNOWFLAKE_PASSWORD": "<YOUR_VALUE>",
        "SNOWFLAKE_EDITION": "<VALUE>",
        "DATABRICKS_SERVER_HOSTNAME": "<VALUE>",
        "DATABRICKS_HTTP_PATH": "<VALUE>",
        "DATABRICKS_TOKEN": "<YOUR_VALUE>",
        "DATABRICKS_CLIENT_ID": "<VALUE>",
        "DATABRICKS_CLIENT_SECRET": "<YOUR_VALUE>",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "<VALUE>",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "<VALUE>",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "<VALUE>",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "<VALUE>",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "<VALUE>"
      }
    }
  }
}

Reload the VS Code window to activate.

Add to ~/.codeium/windsurf/mcp_config.json

Windows / Linux path
Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json
Linux: ~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "io-github-mcpsmiths-cost-guard-mcp": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "<YOUR_VALUE>",
        "SNOWFLAKE_ACCOUNT": "<VALUE>",
        "SNOWFLAKE_USER": "<VALUE>",
        "SNOWFLAKE_ROLE": "<VALUE>",
        "SNOWFLAKE_SECONDARY_ROLES": "<VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "<YOUR_VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "<YOUR_VALUE>",
        "SNOWFLAKE_PASSWORD": "<YOUR_VALUE>",
        "SNOWFLAKE_EDITION": "<VALUE>",
        "DATABRICKS_SERVER_HOSTNAME": "<VALUE>",
        "DATABRICKS_HTTP_PATH": "<VALUE>",
        "DATABRICKS_TOKEN": "<YOUR_VALUE>",
        "DATABRICKS_CLIENT_ID": "<VALUE>",
        "DATABRICKS_CLIENT_SECRET": "<YOUR_VALUE>",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "<VALUE>",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "<VALUE>",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "<VALUE>",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "<VALUE>",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "<VALUE>"
      }
    }
  }
}

Restart Windsurf (or refresh its MCP servers panel) to activate the new server.

Windsurf Next uses ~/.codeium/windsurf-next/mcp_config.json. Devin Desktop (the Windsurf rebrand) uses ~/.config/devin/mcp_config.json and imports the Windsurf file.

Add to ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Windows / Linux path
Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
  "mcpServers": {
    "io-github-mcpsmiths-cost-guard-mcp": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "<YOUR_VALUE>",
        "SNOWFLAKE_ACCOUNT": "<VALUE>",
        "SNOWFLAKE_USER": "<VALUE>",
        "SNOWFLAKE_ROLE": "<VALUE>",
        "SNOWFLAKE_SECONDARY_ROLES": "<VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "<YOUR_VALUE>",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "<YOUR_VALUE>",
        "SNOWFLAKE_PASSWORD": "<YOUR_VALUE>",
        "SNOWFLAKE_EDITION": "<VALUE>",
        "DATABRICKS_SERVER_HOSTNAME": "<VALUE>",
        "DATABRICKS_HTTP_PATH": "<VALUE>",
        "DATABRICKS_TOKEN": "<YOUR_VALUE>",
        "DATABRICKS_CLIENT_ID": "<VALUE>",
        "DATABRICKS_CLIENT_SECRET": "<YOUR_VALUE>",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "<VALUE>",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "<VALUE>",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "<VALUE>",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "<VALUE>",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "<VALUE>"
      }
    }
  }
}

Cline reloads cline_mcp_settings.json automatically; if the server does not appear, reload the VS Code window.

Open it from Cline's MCP Servers panel → Configure. Roo Code uses a different file and format.

Configuration

Environment variables this server reads. Secrets stay on your machine.

NameRequiredDescription
GOOGLE_APPLICATION_CREDENTIALS secret No Path to a service-account key file for BigQuery. Alternatively, run `gcloud auth application-default login`.
SNOWFLAKE_ACCOUNT No Snowflake account identifier.
SNOWFLAKE_USER No Snowflake user name.
SNOWFLAKE_ROLE No Snowflake role (required, no default, never ACCOUNTADMIN).
SNOWFLAKE_SECONDARY_ROLES No Snowflake: secondary roles activated at login. NONE (default) means only SNOWFLAKE_ROLE is active in the session; ALL is the explicit opt-out that activates every role granted to SNOWFLAKE_USER.
SNOWFLAKE_PRIVATE_KEY_PATH secret No Path to Snowflake private key file (preferred over password).
SNOWFLAKE_PRIVATE_KEY_PASSPHRASE secret No Snowflake: passphrase for an encrypted SNOWFLAKE_PRIVATE_KEY_PATH key file, if the key is encrypted.
SNOWFLAKE_PASSWORD secret No Snowflake password (discouraged; use SNOWFLAKE_PRIVATE_KEY_PATH instead).
SNOWFLAKE_EDITION No Snowflake: account edition that sets the USD/credit price of estimates - standard (default), enterprise, business_critical or vps. The per-call edition argument can only raise it.
DATABRICKS_SERVER_HOSTNAME No Databricks: SQL warehouse server hostname (e.g. my-workspace.cloud.databricks.com, no scheme, no trailing slash). Required to use the databricks engine.
DATABRICKS_HTTP_PATH No Databricks: SQL warehouse HTTP path (from the warehouse's Connection Details tab, e.g. /sql/1.0/warehouses/<warehouse-id>). Required to use the databricks engine.
DATABRICKS_TOKEN secret No Databricks: personal access token (simplest auth option). Either this or DATABRICKS_CLIENT_ID + DATABRICKS_CLIENT_SECRET is required to use the databricks engine.
DATABRICKS_CLIENT_ID No Databricks: OAuth machine-to-machine service-principal client ID (preferred for automated use). Requires DATABRICKS_CLIENT_SECRET as well.
DATABRICKS_CLIENT_SECRET secret No Databricks: OAuth machine-to-machine service-principal client secret. Requires DATABRICKS_CLIENT_ID as well.
COST_GUARD_ALLOW_MULTI_STATEMENT_SQL No Set to 1 to let estimate_query_cost/run_query_bounded accept text containing more than one SQL statement. Off by default: the cost cap is only known to cover the single statement the dry run/EXPLAIN priced. Skips only this server's scanner: Snowflake still rejects multi-statement text (sessions are pinned to MULTI_STATEMENT_COUNT=1), and only a single SELECT/WITH/VALUES statement is wrapped in a LIMIT subquery - a script runs unwrapped and its row cap (max_rows, default 1000) is enforced by the paged fetch.
COST_GUARD_ALLOW_WRITE_STATEMENTS No Set to 1 (exactly that value) to let estimate_query_cost/run_query_bounded accept statements that are not reads. Off by default: only text whose first keyword (after comments and opening parentheses) is SELECT, WITH, VALUES, SHOW, DESCRIBE, DESC or EXPLAIN is estimated or run - a WITH must be followed by a SELECT or VALUES - because warehouse rows re-enter the model's context and can steer the next call. The gate is defence in depth: the authorisation boundary is the credential's grants (deploy a read-only principal). With COST_GUARD_ALLOW_MULTI_STATEMENT_SQL=1 every statement in the text must be a read, so BigQuery scripts (DECLARE/SET/BEGIN) need both opt-outs. Any other value leaves the gate on.
COST_GUARD_MAX_IN_FLIGHT_QUERIES No Maximum number of run_query_bounded calls allowed in flight at once (positive integer, default 8). A cancelled call keeps its slot until its warehouse query completes or the 120 s watchdog fires; a call over the cap fails with a tool error naming this variable before any warehouse connection is opened.
COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START No Set to true (exactly that value) to let the read-only Databricks tools (check_credentials, estimate_query_cost) open a session on a SQL warehouse that is not RUNNING, which starts the warehouse and bills compute until it auto-stops. Off by default: the server first reads the warehouse's state through the Warehouses API (GET /api/2.0/sql/warehouses/<id>, CAN_VIEW/CAN_USE suffices) and, unless it is RUNNING - also when the state cannot be read - check_credentials returns ok=false and estimate_query_cost returns no byte or dollar figure, without opening a session. run_query_bounded is not gated: its own pre-execution estimate and the execution may start the warehouse. Any other value leaves the guard on.
COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME No Set to true (exactly that value) to let the read-only Snowflake tools run SELECT CURRENT_REGION(), the INFORMATION_SCHEMA.QUERY_HISTORY read and check_credentials' session-context SELECT on a warehouse that is not STARTED, which can resume a suspended AUTO_RESUME warehouse and bill compute until it auto-suspends. Off by default: those statements are skipped unless the pinned warehouse's SHOW WAREHOUSES state is STARTED (also skipped when no warehouse is pinned or the state cannot be read), and the QUERY_HISTORY read is skipped whenever estimate_query_cost is called without a warehouse argument; estimate_query_cost then prices at Gen1 rates with the byte-tier heuristic and says so in a caveat, and check_credentials returns ok=true with a detail built from the SHOW WAREHOUSES row. USE WAREHOUSE, EXPLAIN USING JSON, SHOW WAREHOUSES and SELECT CURRENT_WAREHOUSE() always run; run_query_bounded is not gated. Any other value leaves the guard on.

Similar servers