Skip to main content
Glama
caron14

mcp-bigquery-dryrun

by caron14

mcp-bigquery-dryrun

PyPI PyPI - Downloads

The mcp-bugquery-dryrun package provides a minimal MCP server for BigQuery SQL validation and dry-run analysis. This server provides exactly two tools for validating and analyzing BigQuery SQL queries without executing them.

** IMPORTANT: This server does NOT execute queries. All operations are dry-run only. Cost estimates are approximations based on bytes processed.**

Features

  • SQL Validation: Check BigQuery SQL syntax without running queries

  • Dry-Run Analysis: Get cost estimates, referenced tables, and schema preview

  • Parameter Support: Validate parameterized queries

  • Cost Estimation: Calculate USD estimates based on bytes processed

Related MCP server: mcp-server-sql-analyzer

Quick Start

Prerequisites

  • Python 3.10+

  • Google Cloud SDK with BigQuery API enabled

  • Application Default Credentials configured

Installation

# Install from PyPI
pip install mcp-bigquery-dryrun

# Or with uv
uv pip install mcp-bigquery-dryrun

From Source

# Clone the repository
git clone https://github.com/caron14/mcp-bigquery-dryrun.git
cd mcp-bigquery-dryrun

# Install with uv (recommended)
uv pip install -e .

# Or install with pip
pip install -e .

Authentication

Set up Application Default Credentials:

gcloud auth application-default login

Or use a service account key:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json

Configuration

Environment Variables

Variable

Description

Default

BQ_PROJECT

GCP project ID

From ADC

BQ_LOCATION

BigQuery location (e.g., US, EU, asia-northeast1)

None

SAFE_PRICE_PER_TIB

Default price per TiB for cost estimation

5.0

Claude Code Integration

Add to your Claude Code configuration:

{
  "mcpServers": {
    "bq-dryrun": {
      "command": "mcp-bigquery-dryrun",
      "env": {
        "BQ_PROJECT": "your-gcp-project",
        "BQ_LOCATION": "asia-northeast1",
        "SAFE_PRICE_PER_TIB": "5.0"
      }
    }
  }
}

Or if installed from source:

{
  "mcpServers": {
    "bq-dryrun": {
      "command": "python",
      "args": ["-m", "mcp_bigquery_dryrun"],
      "env": {
        "BQ_PROJECT": "your-gcp-project",
        "BQ_LOCATION": "asia-northeast1",
        "SAFE_PRICE_PER_TIB": "5.0"
      }
    }
  }
}

Tools

bq_validate_sql

Validate BigQuery SQL syntax without executing the query.

Input:

{
  "sql": "SELECT * FROM dataset.table WHERE id = @id",
  "params": {"id": "123"}  // Optional
}

Success Response:

{
  "isValid": true
}

Error Response:

{
  "isValid": false,
  "error": {
    "code": "INVALID_SQL",
    "message": "Syntax error at [3:15]",
    "location": {
      "line": 3,
      "column": 15
    },
    "details": [...]  // Optional
  }
}

bq_dry_run_sql

Perform a dry-run to get cost estimates and metadata without executing the query.

Input:

{
  "sql": "SELECT * FROM dataset.table",
  "params": {"id": "123"},  // Optional
  "pricePerTiB": 6.0  // Optional, overrides default
}

Success Response:

{
  "totalBytesProcessed": 1073741824,
  "usdEstimate": 0.005,
  "referencedTables": [
    {
      "project": "my-project",
      "dataset": "my_dataset",
      "table": "my_table"
    }
  ],
  "schemaPreview": [
    {
      "name": "id",
      "type": "STRING",
      "mode": "NULLABLE"
    },
    {
      "name": "created_at",
      "type": "TIMESTAMP",
      "mode": "REQUIRED"
    }
  ]
}

Error Response:

{
  "error": {
    "code": "INVALID_SQL",
    "message": "Table not found: dataset.table",
    "details": [...]  // Optional
  }
}

Examples

Validate a Simple Query

# Tool: bq_validate_sql
{
  "sql": "SELECT 1"
}
# Returns: {"isValid": true}

Validate with Parameters

# Tool: bq_validate_sql
{
  "sql": "SELECT * FROM users WHERE name = @name AND age > @age",
  "params": {
    "name": "Alice",
    "age": 25
  }
}

Get Cost Estimate

# Tool: bq_dry_run_sql
{
  "sql": "SELECT * FROM `bigquery-public-data.samples.shakespeare`",
  "pricePerTiB": 5.0
}
# Returns bytes processed, USD estimate, and schema

Analyze Complex Query

# Tool: bq_dry_run_sql
{
  "sql": """
    WITH user_stats AS (
      SELECT user_id, COUNT(*) as order_count
      FROM orders
      GROUP BY user_id
    )
    SELECT * FROM user_stats WHERE order_count > 10
  """
}

Testing

Run tests with pytest:

# Run all tests (requires BigQuery credentials)
pytest tests/

# Run only tests that don't require credentials
pytest tests/test_min.py::TestWithoutCredentials

Development

# Install development dependencies
uv pip install -e ".[dev]"

# Run the server locally
python -m mcp_bigquery_dryrun

# Or using the console script
mcp-bigquery-dryrun

Limitations

  • No Query Execution: This server only performs dry-runs and validation

  • Cost Estimates: USD estimates are approximations based on bytes processed

  • Parameter Types: Initial implementation treats all parameters as STRING type

  • Cache Disabled: Queries always run with use_query_cache=False for accurate estimates

License

Apache-2.0

Changelog

0.1.0 (2024-08-12)

  • Initial release

Available Tools

2 tools
bq_dry_run_sqlB

Perform a dry-run of a BigQuery SQL query to get cost estimates and metadata

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL query to dry-run
paramsNoOptional query parameters (key-value pairs)
pricePerTiBNoPrice per TiB for cost estimation (defaults to env var or 5.0)

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations provided, the description bears full responsibility for behavioral disclosure. It only states the tool performs a dry-run and returns cost estimates and metadata, but fails to mention key aspects such as idempotency (safe to call multiple times), required permissions, rate limits, or what exactly 'metadata' includes. The non-destructive nature is implied but not explicit.

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 a single sentence that efficiently conveys the tool's purpose. It is front-loaded and contains no unnecessary words or information, earning its place.

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

Completeness3/5

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

For a tool with 3 parameters (one nested object) and no output schema, the description is minimal. It outlines the goal but omits details on return values, error handling, and edge cases. While the tool is straightforward, the lack of output schema means the description should provide more context on what the agent can expect from the dry-run results.

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?

Schema description coverage is 100%, with each parameter described in the input schema. The description itself adds no additional semantic meaning beyond what the schema provides. Baseline is 3 because the schema does the heavy lifting; the description does not compensate for any gaps.

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

Purpose4/5

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

The description clearly states the tool performs a dry-run of a BigQuery SQL query to get cost estimates and metadata. It uses a specific verb (dry-run) and resource (BigQuery SQL query). However, it does not distinguish from the sibling tool 'bq_validate_sql', which may also involve checking queries, reducing clarity on when to use each.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like bq_validate_sql. There is no mention of prerequisites, context, or situations where this tool is appropriate or not, leaving the agent with no decision support.

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

bq_validate_sqlA

Validate BigQuery SQL syntax without executing the query

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL query to validate
paramsNoOptional query parameters (key-value pairs)

TDQS

A3.7/5.0
Behavior2/5

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

No annotations are provided, and the description only states the tool validates without executing. It does not disclose what happens on invalid syntax, auth requirements, or whether it checks table existence, leaving significant behavioral gaps.

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 a single 8-word sentence with no extraneous information, achieving maximum conciseness.

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

Completeness3/5

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

Given the tool's simplicity (2 parameters, no output schema, no annotations), the description is minimally adequate but lacks details about return values or behavior on errors, which would help agents understand the output.

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?

Schema description coverage is 100%; both parameters have clear descriptions in the schema. The tool description adds no extra parameter information beyond what the schema already provides.

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 specifies the verb 'validate' and the resource 'BigQuery SQL syntax', and clearly states it does not execute the query, distinguishing it from bq_dry_run_sql which executes a dry run.

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 use for syntax checking only, not execution. It contrasts with 'without executing', but does not explicitly name when not to use or mention bq_dry_run_sql as an alternative.

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.

  1. 2 tool updatesv0.2.0
    • First observedbq_dry_run_sql
    • First observedbq_validate_sql

TDQS

A3.8/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: one provides cost estimates and metadata via dry-run, the other validates SQL syntax. There is no overlap.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern starting with 'bq_' and ending with '_sql', making the naming predictable and clear.

Tool Count5/5

The server is narrowly scoped to BigQuery dry-run and validation. Two tools perfectly cover this domain without unnecessary extras.

Completeness5/5

The tool set fully covers the stated purpose of dry-running and validating SQL queries. No obvious gaps exist for the intended functionality.

Maintenance

ActivityInactive
ResponsivenessNo issues

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

  • A
    license
    Not graded
    quality
    B
    maintenance
    A read-only BigQuery MCP server with auto-LIMIT injection, dry-run cost guard, and ADC authentication. Allows safe SQL querying of BigQuery by LLMs without risk of data modification or unexpected costs.
    1
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables read-only interaction with Google BigQuery, including SQL queries, dataset/table listing, schema retrieval, table preview, and metadata access via service account authentication.
    -