ต้นแบบ · รุ่นทดลอง: มีทุก server ในทะเบียนทางการ อัปเดตทุก 30 นาที รีวิวและบัญชีผู้ใช้จะมาในขั้นถัดไป
PopNx MCPที่รวม MCP สำหรับคนใช้ AI · อธิบายเป็นภาษาคน

Cost Guard MCP

โดย mcpsmithsรุ่น 0.6.0i★ –iรันบนเครื่อง
ชื่อใน registryio.github.mcpsmiths/cost-guard-mcp

ติดตั้ง

ภาพรวม

คำอธิบายจากผู้ทำ (ภาษาอังกฤษตามต้นฉบับ)

Pre-flight query cost and result-size guardrails for AI agents on BigQuery, Snowflake, Databricks

สามเสาของ PopNx MCP

สามเรื่องนี้ไม่รวมเป็นคะแนนเดียว เพราะความเห็น การวัด และความนิยม เป็นคนละเรื่องกัน

ใช้ทำอะไรได้

ตัวนี้ยังไม่ได้เรียบเรียงเป็นภาษาไทย ด้านล่างคือข้อเท็จจริงที่เราอ่านจาก registry

  • การเชื่อมต่อ: รันบนเครื่อง
  • ช่องทาง (transport): stdio
  • หมวด: ฐานข้อมูลและชุดข้อมูล
  • ต้องใส่ค่าเหล่านี้: GOOGLE_APPLICATION_CREDENTIALS, SNOWFLAKE_PRIVATE_KEY_PATH, SNOWFLAKE_PRIVATE_KEY_PASSPHRASE, SNOWFLAKE_PASSWORD, DATABRICKS_TOKEN, DATABRICKS_CLIENT_SECRET

ติดตั้ง

เลือกโปรแกรม AI ที่คุณใช้ แล้วคัดลอกค่าตั้งไปวาง

ก่อนติดตั้ง

  • ผลตรวจเบื้องต้น: ผ่าน 1 จาก 1 ข้อ
  • รันในเครื่องคุณด้วยสิทธิ์ของผู้ใช้คุณ (ไฟล์ อินเทอร์เน็ต แอปต่าง ๆ)
  • ค่าที่คุณต้องใส่เอง: GOOGLE_APPLICATION_CREDENTIALS, SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_ROLE, SNOWFLAKE_SECONDARY_ROLES, SNOWFLAKE_PRIVATE_KEY_PATH, SNOWFLAKE_PRIVATE_KEY_PASSPHRASE, SNOWFLAKE_PASSWORD, SNOWFLAKE_EDITION, DATABRICKS_SERVER_HOSTNAME, DATABRICKS_HTTP_PATH, DATABRICKS_TOKEN, DATABRICKS_CLIENT_ID, DATABRICKS_CLIENT_SECRET, COST_GUARD_ALLOW_MULTI_STATEMENT_SQL, COST_GUARD_ALLOW_WRITE_STATEMENTS, COST_GUARD_MAX_IN_FLIGHT_QUERIES, COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START, COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME

ค่าที่ติดป้ายความลับคือกุญแจของบัญชีคุณ อย่าส่งให้ใคร และอย่าวางในแชต

ต้องเตรียมก่อน

  • PyPIติดตั้ง uv ของ Python (มีคำสั่ง uvx) ในเครื่อง

คุณใช้แอปไหน

เลือกแอปด้านบน เราจำไว้ให้ ครั้งหน้าปุ่มจะขึ้นว่า “ติดตั้งลง …”

เปิด Claude Desktop → Settings → Developer → Edit Config แล้ววางค่านี้ในไฟล์ claude_desktop_config.json

{
  "mcpServers": {
    "cost-guard": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "ใส่ค่าของคุณ",
        "SNOWFLAKE_ACCOUNT": "ใส่ค่าของคุณ",
        "SNOWFLAKE_USER": "ใส่ค่าของคุณ",
        "SNOWFLAKE_ROLE": "ใส่ค่าของคุณ",
        "SNOWFLAKE_SECONDARY_ROLES": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PASSWORD": "ใส่ค่าของคุณ",
        "SNOWFLAKE_EDITION": "ใส่ค่าของคุณ",
        "DATABRICKS_SERVER_HOSTNAME": "ใส่ค่าของคุณ",
        "DATABRICKS_HTTP_PATH": "ใส่ค่าของคุณ",
        "DATABRICKS_TOKEN": "ใส่ค่าของคุณ",
        "DATABRICKS_CLIENT_ID": "ใส่ค่าของคุณ",
        "DATABRICKS_CLIENT_SECRET": "ใส่ค่าของคุณ",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "ใส่ค่าของคุณ",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "ใส่ค่าของคุณ",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "ใส่ค่าของคุณ",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "ใส่ค่าของคุณ",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "ใส่ค่าของคุณ"
      }
    }
  }
}

พิมพ์คำสั่งนี้ใน Terminal

claude mcp add cost-guard --env GOOGLE_APPLICATION_CREDENTIALS='ใส่ค่าของคุณ' --env SNOWFLAKE_ACCOUNT='ใส่ค่าของคุณ' --env SNOWFLAKE_USER='ใส่ค่าของคุณ' --env SNOWFLAKE_ROLE='ใส่ค่าของคุณ' --env SNOWFLAKE_SECONDARY_ROLES='ใส่ค่าของคุณ' --env SNOWFLAKE_PRIVATE_KEY_PATH='ใส่ค่าของคุณ' --env SNOWFLAKE_PRIVATE_KEY_PASSPHRASE='ใส่ค่าของคุณ' --env SNOWFLAKE_PASSWORD='ใส่ค่าของคุณ' --env SNOWFLAKE_EDITION='ใส่ค่าของคุณ' --env DATABRICKS_SERVER_HOSTNAME='ใส่ค่าของคุณ' --env DATABRICKS_HTTP_PATH='ใส่ค่าของคุณ' --env DATABRICKS_TOKEN='ใส่ค่าของคุณ' --env DATABRICKS_CLIENT_ID='ใส่ค่าของคุณ' --env DATABRICKS_CLIENT_SECRET='ใส่ค่าของคุณ' --env COST_GUARD_ALLOW_MULTI_STATEMENT_SQL='ใส่ค่าของคุณ' --env COST_GUARD_ALLOW_WRITE_STATEMENTS='ใส่ค่าของคุณ' --env COST_GUARD_MAX_IN_FLIGHT_QUERIES='ใส่ค่าของคุณ' --env COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START='ใส่ค่าของคุณ' --env COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME='ใส่ค่าของคุณ' -- uvx cost-guard-mcp

เติมค่าที่เว้นว่างไว้ก่อนรัน

เปิดใน Cursor

หรือคัดลอกค่าตั้งเอง

วางในไฟล์ .cursor/mcp.json ของโปรเจกต์ หรือ ~/.cursor/mcp.json

{
  "mcpServers": {
    "cost-guard": {
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "ใส่ค่าของคุณ",
        "SNOWFLAKE_ACCOUNT": "ใส่ค่าของคุณ",
        "SNOWFLAKE_USER": "ใส่ค่าของคุณ",
        "SNOWFLAKE_ROLE": "ใส่ค่าของคุณ",
        "SNOWFLAKE_SECONDARY_ROLES": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PASSWORD": "ใส่ค่าของคุณ",
        "SNOWFLAKE_EDITION": "ใส่ค่าของคุณ",
        "DATABRICKS_SERVER_HOSTNAME": "ใส่ค่าของคุณ",
        "DATABRICKS_HTTP_PATH": "ใส่ค่าของคุณ",
        "DATABRICKS_TOKEN": "ใส่ค่าของคุณ",
        "DATABRICKS_CLIENT_ID": "ใส่ค่าของคุณ",
        "DATABRICKS_CLIENT_SECRET": "ใส่ค่าของคุณ",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "ใส่ค่าของคุณ",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "ใส่ค่าของคุณ",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "ใส่ค่าของคุณ",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "ใส่ค่าของคุณ",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "ใส่ค่าของคุณ"
      }
    }
  }
}

เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง

เปิดใน VS Code

หรือคัดลอกค่าตั้งเอง

วางในไฟล์ .vscode/mcp.json ของโปรเจกต์

{
  "servers": {
    "cost-guard": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "cost-guard-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "ใส่ค่าของคุณ",
        "SNOWFLAKE_ACCOUNT": "ใส่ค่าของคุณ",
        "SNOWFLAKE_USER": "ใส่ค่าของคุณ",
        "SNOWFLAKE_ROLE": "ใส่ค่าของคุณ",
        "SNOWFLAKE_SECONDARY_ROLES": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PRIVATE_KEY_PATH": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE": "ใส่ค่าของคุณ",
        "SNOWFLAKE_PASSWORD": "ใส่ค่าของคุณ",
        "SNOWFLAKE_EDITION": "ใส่ค่าของคุณ",
        "DATABRICKS_SERVER_HOSTNAME": "ใส่ค่าของคุณ",
        "DATABRICKS_HTTP_PATH": "ใส่ค่าของคุณ",
        "DATABRICKS_TOKEN": "ใส่ค่าของคุณ",
        "DATABRICKS_CLIENT_ID": "ใส่ค่าของคุณ",
        "DATABRICKS_CLIENT_SECRET": "ใส่ค่าของคุณ",
        "COST_GUARD_ALLOW_MULTI_STATEMENT_SQL": "ใส่ค่าของคุณ",
        "COST_GUARD_ALLOW_WRITE_STATEMENTS": "ใส่ค่าของคุณ",
        "COST_GUARD_MAX_IN_FLIGHT_QUERIES": "ใส่ค่าของคุณ",
        "COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START": "ใส่ค่าของคุณ",
        "COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME": "ใส่ค่าของคุณ"
      }
    }
  }
}

เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง

ตัวนี้รันในเครื่องคุณ แต่ ChatGPT ต่อได้เฉพาะ server บนอินเทอร์เน็ต ลองเลือกแอปอื่น

ตัวเลือกเก็บในคุกกี้บนเครื่องนี้ ไม่ต้องมีบัญชี

ค่าที่ต้องใส่เอง

  • GOOGLE_APPLICATION_CREDENTIALS ความลับ env
    BigQuery: path to a service-account key file (Application Default Credentials). Required to use the bigquery engine.
  • SNOWFLAKE_ACCOUNT env
    Snowflake: account identifier. Required to use the snowflake engine.
  • SNOWFLAKE_USER env
    Snowflake: username. Required to use the snowflake engine.
  • SNOWFLAKE_ROLE env
    Snowflake: role to assume. Required to use the snowflake engine; has no default and must never be ACCOUNTADMIN (ACCOUNTADMIN, SECURITYADMIN and ORGADMIN are rejected before any Snowflake connection i…
  • SNOWFLAKE_SECONDARY_ROLES env
    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 ความลับ env
    Snowflake: path to an RSA private key file for key-pair auth (preferred over SNOWFLAKE_PASSWORD). Either this or SNOWFLAKE_PASSWORD is required to use the snowflake engine.
  • SNOWFLAKE_PRIVATE_KEY_PASSPHRASE ความลับ env
    Snowflake: passphrase for an encrypted SNOWFLAKE_PRIVATE_KEY_PATH key file, if the key is encrypted.
  • SNOWFLAKE_PASSWORD ความลับ env
    Snowflake: password (discouraged; prefer SNOWFLAKE_PRIVATE_KEY_PATH). Either this or SNOWFLAKE_PRIVATE_KEY_PATH is required to use the snowflake engine.
  • SNOWFLAKE_EDITION env
    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 env
    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 env
    Databricks: SQL warehouse HTTP path (from the warehouse's Connection Details tab, e.g. /sql/1.0/warehouses/ ). Required to use the databricks engine.
  • DATABRICKS_TOKEN ความลับ env
    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 env
    Databricks: OAuth machine-to-machine service-principal client ID (preferred for automated use). Requires DATABRICKS_CLIENT_SECRET as well.
  • DATABRICKS_CLIENT_SECRET ความลับ env
    Databricks: OAuth machine-to-machine service-principal client secret. Requires DATABRICKS_CLIENT_ID as well.
  • COST_GUARD_ALLOW_MULTI_STATEMENT_SQL env
    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…
  • COST_GUARD_ALLOW_WRITE_STATEMENTS env
    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)…
  • COST_GUARD_MAX_IN_FLIGHT_QUERIES env
    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 c…
  • COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START env
    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 b…
  • COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME env
    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 warehou…

ค่าตั้งนี้สร้างจากข้อมูลใน registry ของผู้ทำ ถ้าไม่ตรงกับ README ให้เชื่อ README

ทำอะไรได้บ้าง

รันในเครื่องคุณ รายการเครื่องมือจะขึ้นในแอป AI หลังติดตั้ง

ผลตรวจเบื้องต้นi

เราตรวจจากข้อมูลที่ใครก็เปิดดูได้ ยังไม่ได้อ่านโค้ด ข้อที่ไม่เกี่ยวกับตัวนี้ไม่นับในตัวหาร · ตรวจเมื่อ 7 พ.ย. 2569

  • ✓ ผ่าน

    ตัวตนผู้ทำตรงกับ repo

    ชื่อใน registry ยืนยันด้วยบัญชี GitHub mcpsmiths ซึ่งเป็นเจ้าของ repo

  • … ยังไม่ตรวจ

    ยังมีคนดูแล

    ยังไม่ได้อ่านข้อมูล repo จาก GitHub

  • … ยังไม่ตรวจ

    มีสัญญาอนุญาต (license)

    ยังไม่ได้อ่านข้อมูล repo จาก GitHub

  • – ไม่เกี่ยว

    endpoint ตอบ

    ตัวนี้รันบนเครื่องคุณ ไม่มี endpoint บนอินเทอร์เน็ต

  • – ไม่เกี่ยว

    ล็อกอินแบบ OAuth

    ตัวนี้รันบนเครื่อง ใช้ค่าที่ตั้งในเครื่องแทน

  • … ยังไม่ตรวจ

    คำอธิบายเครื่องมือไม่มีคำสั่งแอบแฝง

    รันในเครื่องคุณ เราอ่านรายการเครื่องมือได้เฉพาะตัวที่มี endpoint บนอินเทอร์เน็ต

เทียบกับตัวอื่นในหมวด ฐานข้อมูลและชุดข้อมูลi

  • ดาวมากกว่า 0% ของอีก 954 ตัวในหมวดนี้
  • ส่งรุ่นใหม่เข้า registry ล่าสุดกว่า 73% ของอีก 954 ตัวในหมวดนี้
  • ผลตรวจเบื้องต้นดีกว่าหรือเท่ากับ 100% ของอีก 954 ตัวในหมวดนี้

เทียบกับทุก server ที่ยังใช้งานในหมวดนี้ทั้งทะเบียน ดาวนับเฉพาะเมื่อผู้ลงทะเบียนเป็นเจ้าของ repo

คำถามที่พบบ่อย

Cost Guard MCP ปลอดภัยไหม?

จากการตรวจเบื้องต้นของเรา ผ่าน 1 จาก 1 ข้อที่ตรวจได้ เรายังไม่ได้อ่านโค้ด ก่อนใส่กุญแจหรือ token ให้ดูว่า server ขอสิทธิ์อะไร และเลือกกุญแจที่ทำได้เท่าที่จำเป็น

ต้องใช้กุญแจหรือรหัสอะไรบ้าง?

ต้องใส่ค่าเหล่านี้: GOOGLE_APPLICATION_CREDENTIALS, SNOWFLAKE_PRIVATE_KEY_PATH, SNOWFLAKE_PRIVATE_KEY_PASSPHRASE, SNOWFLAKE_PASSWORD, DATABRICKS_TOKEN, DATABRICKS_CLIENT_SECRET

ตัวนี้รันบนเครื่องหรือบนคลาวด์?

รันบนเครื่องของคุณ โปรแกรม AI จะเปิด server ขึ้นมาเองเมื่อใช้ ข้อมูลไม่ต้องผ่านเซิร์ฟเวอร์ของผู้ทำ (ยกเว้นตัวที่ไปเรียกบริการออนไลน์ต่อ)

ยังมีคนดูแลอยู่ไหม?

repo บน GitHub มีการแก้โค้ดล่าสุด – และส่งรุ่นล่าสุด (0.6.0) เข้า registry 18 วันที่ผ่านมา

ใช้กับโปรแกรมไหนได้บ้าง?

โปรแกรมที่รองรับ MCP เช่น Claude Desktop, Claude Code, Cursor และ VS Code ตัวนี้ต้องมี Python (uv) ในเครื่องด้วย

มีตัวไหนใช้แทนได้บ้าง?

ในหมวดเดียวกันมี Supabase, MongoDB MCP Server, Elasticsearch MCP Server

ตัวที่ใช้แทนได้

server หมวดเดียวกันจากผู้ทำคนอื่น เรียงตามดาว

อ่านการ์ด:★ ดาว GitHubiสามเสา: รีวิว · ผลตรวจ · การใช้งานiอัปเดต = วันที่ส่งรุ่นล่าสุดเข้า registryi

Supabase

โดย supabase

server ทางการของ Supabase ให้ AI สร้างตาราง ถามข้อมูล และดูการตั้งค่าโปรเจกต์ในฐานข้อมูล Supabase ของคุณ

บนเครื่องหรือคลาวด์★ 2,993Apache-2.0อัปเดต เมื่อวาน
ติดตั้ง

MongoDB MCP Server

โดย mongodb-js

MongoDB Model Context Protocol Server

รันบนเครื่อง★ 1,157Apache-2.0อัปเดต 3 วันที่ผ่านมา
ติดตั้ง

Elasticsearch MCP Server

โดย cr7258

MCP server for interacting with Elasticsearch

รันบนเครื่อง★ 315Apache-2.0อัปเดต 14 เดือนที่ผ่านมา
ติดตั้ง

README จากผู้ทำ

เปิดอ่าน README

ส่วนนี้คัดจาก repo ของผู้ทำตามต้นฉบับ PopNx MCP ไม่ได้ตรวจหรือรับรองเนื้อหา ตัด HTML รูปภาพ และสคริปต์ออกแล้ว ลิงก์จะพาออกนอกเว็บ

cost-guard-mcp

Pre-flight query cost & result-size guardrails for AI agents, across BigQuery, Snowflake, and Databricks — 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 (BigQuery dryRun), UPPER_BOUND (Snowflake EXPLAIN), or HEURISTIC (Databricks EXPLAIN COST) — so your agent never over-trusts a heuristic number.
  • Per-call bounds — run_query_bounded takes max_bytes_billed / max_rows / max_estimated_cost_usd on each call; no shared session state required. max_rows defaults to 1000 and the serialised result is capped at 8 MiB; executed on every result says whether the query ran.
  • Zero infrastructure — a single local stdio process. No database, no gateway, no Docker Compose.

Tools

  • check_credentials(engine, warehouse?) — verifies credentials/connectivity without running a real query or a dry run; call this first after configuring a new engine. Supports BigQuery, Snowflake, and Databricks. What runs: BigQuery makes one metadata call; Snowflake logs in, runs USE WAREHOUSE when a warehouse is given (SELECT CURRENT_WAREHOUSE() when none is), reads the pinned warehouse's SHOW WAREHOUSES row, and runs one session-context statement only when that row says STARTED — otherwise ok: true with a detail built from the row (the statement could resume a suspended warehouse); Databricks reads the configured SQL warehouse through the Warehouses API (a control-plane GET) and opens a session (SELECT current_user()) only when it is RUNNING — otherwise ok: false with no session (the session could start a stopped warehouse). An unreadable state counts as not running on both. Opt in with COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME=true / COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START=true — see Known limitations.
  • 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. Accepts exactly one SQL statement per call, and only read statements by default — first keyword SELECT, WITH, VALUES, SHOW, DESCRIBE, DESC or EXPLAIN (see Known limitations). warehouse_size (Snowflake/Databricks) and edition (Snowflake) can only raise the estimate — the dollar figure is priced at the warehouse the query is pinned to, as the server observes it (the SHOW WAREHOUSES size/type/generation, or the Databricks Warehouses API), and at the operator-configured SNOWFLAKE_EDITION, whichever is higher. Warehouse types without a modelled rate (Snowpark-optimized, Databricks Classic/Pro) get a byte estimate but no dollar figure. On a Snowflake warehouse that is not STARTED the cloud-provider and query-history lookups are skipped (Gen1 rates at the observed size, heuristic runtime, caveat) — the query-history lookup is also skipped whenever no warehouse argument is given; on a Databricks warehouse that is not RUNNING, or whose state cannot be read, no session is opened and no byte or dollar figure is returned — see Known limitations.
  • 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. max_rows defaults to 1000 (pass a larger value to raise it); results over 8 MiB serialised are truncated to whole rows with reason: result_size_exceeded; executed: true on ok and on the two truncation refusals (row_cap_exceeded, result_size_exceeded — the query ran), false on every other refusal (the query was never submitted, or BigQuery refused to run it). Supports BigQuery, Snowflake, and Databricks. Accepts exactly one SQL statement per call, and only read statements by default — first keyword SELECT, WITH, VALUES, SHOW, DESCRIBE, DESC or EXPLAIN (see Known limitations). A max_estimated_cost_usd cap is checked against that observed-warehouse estimate and refuses when no dollar figure exists. Not gated on warehouse state: its estimate and execution may resume/start the warehouse. Result rows carry the constant rows_provenance: warehouse_data_untrusted: they are data the warehouse returned, never instructions.

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). Optionally set SNOWFLAKE_EDITION to the account's edition — standard (default), enterprise, business_critical or vps — which sets the USD/credit price of every estimate; the per-call edition argument can only raise it.

  • SNOWFLAKE_ROLE is the *only* authorization boundary for the SQL an agent sends through this server, so it is enforced, not just documented. ACCOUNTADMIN, SECURITYADMIN and ORGADMIN are rejected (case-insensitively, quoted or not) before any Snowflake connection is opened: the check runs when the Snowflake configuration is first loaded, which is on the first Snowflake tool call, so the server process itself starts regardless of the value and a bad role surfaces as check_credentials returning ok: false (or as a tool error from estimate_query_cost/run_query_bounded), not as a startup exit. Every session also activates only that role — secondary roles are pinned to NONE in the login request, so a user whose Snowflake DEFAULT_SECONDARY_ROLES is ('ALL') no longer lends every other role it holds to model-written SQL. SNOWFLAKE_USER should ideally hold no role other than SNOWFLAKE_ROLE.
  • SNOWFLAKE_SECONDARY_ROLES (optional, default NONE; the only other value is ALL) is the opt-out for deployments that reached objects only through a secondary role. Prefer granting those objects to SNOWFLAKE_ROLE instead; set ALL only if you accept that the agent's SQL runs with every role the user holds. check_credentials reports the active secondary-role set (CURRENT_SECONDARY_ROLES()) so you can confirm what is in force.
  • Every session also carries a Snowflake-side statement deadline (STATEMENT_TIMEOUT_IN_SECONDS: 60 s for check_credentials/estimate_query_cost, 120 s for run_query_bounded, matching its watchdog) so a query cannot keep running — and billing — if this process dies mid-call. The value is applied *read-then-lower*: the server reads the session's effective value first and only issues ALTER SESSION when that value is 0 (unbounded), unparseable, or above the target. A stricter account- or user-level policy (say 30 s) is therefore never raised; note that a session-level value would otherwise override account/user levels in Snowflake's parameter hierarchy (only the warehouse level combines lowest-wins).
  • Snowflake sessions are also pinned to one statement per call: EXPLAIN USING JSON and the run_query_bounded execution are submitted with num_statements=1 and the session logs in with MULTI_STATEMENT_COUNT=1, so Snowflake itself rejects ;-separated text that the server-side scanner (see Known limitations) did not already refuse. There is no opt-out; multi-statement Snowflake text was never supported.
  • COST_GUARD_SNOWFLAKE_ALLOW_WAREHOUSE_RESUME=true (optional, off by default; the value must be exactly true) lets check_credentials and estimate_query_cost run SELECT CURRENT_REGION(), the QUERY_HISTORY read and the session-context SELECT on a warehouse whose SHOW WAREHOUSES state is not STARTED (and the QUERY_HISTORY read without a warehouse argument), accepting that they can resume it and bill compute. See Known limitations for what is skipped by default.
Databricks

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 — a Classic/Pro warehouse gets a byte estimate but no dollar figure, see Known Limitations.

By default check_credentials and estimate_query_cost refuse to open a session unless the warehouse's state, read through the Warehouses API, is RUNNING (they also refuse when the state cannot be read); set COST_GUARD_DATABRICKS_ALLOW_WAREHOUSE_START=true (exactly that value) to let them start a stopped warehouse, billing compute. run_query_bounded is not gated. See Known limitations.

Concurrency (optional)

COST_GUARD_MAX_IN_FLIGHT_QUERIES (default 8) caps how many run_query_bounded calls may be in flight at once — counting calls the host has already cancelled, until their worker thread exits (at most the 120 s watchdog). A call over the cap fails immediately with a tool error naming this variable, before any warehouse connection is opened. Must be a positive integer (the server refuses to start otherwise); raise it only if your host legitimately runs more concurrent billable queries.

Read-only statements (optional opt-out)

By default estimate_query_cost and run_query_bounded accept only read statements: the first keyword after comments and any opening parentheses must be SELECT, WITH, VALUES, SHOW, DESCRIBE, DESC or EXPLAIN, and a WITH is admitted only when the statement after its CTE list resolves to SELECT or VALUES (Spark SQL allows WITH ... INSERT). Anything else is refused before any dry run, EXPLAIN or execution, because warehouse rows re-enter the model's context and can steer the next call (DECISIONS.md #13). The gate is defence in depth, not the authorisation boundary: that is the deployed credential's grants, so deploy a read-only principal — BigQuery: data-viewer plus job-user roles; Snowflake: a role with USAGE/SELECT only, never an admin role; Databricks: SELECT/USE privileges on the warehouse's catalogs. Operators who intend this server to run writes under its credential can set COST_GUARD_ALLOW_WRITE_STATEMENTS=1 (exactly that value, read per call; anything else keeps the gate on). 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.

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

ตัดมาแค่ช่วงต้น อ่านต่อใน repo

ถาม PopNx