BigQuery Validator
The BigQuery Validator server provides tools for validating and analyzing BigQuery SQL queries without executing them.
SQL Validation: Check BigQuery SQL syntax for correctness using the
bq_validate_sqltoolDry-Run Analysis: Perform dry-run operations using the
bq_dry_run_sqltool to obtain:Cost estimates in USD based on bytes processed (customizable price per TiB)
Referenced tables identification
Output schema preview
Parameter Support: Both validation and dry-run tools support parameterized queries with key-value pairs
Safe Operation: All operations are dry-run only - no queries are executed or data modified
Provides tools for validating BigQuery SQL syntax and performing dry-run analysis to get cost estimates, schema previews, and metadata without executing queries
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@BigQuery Validator estimate the cost of SELECT * FROM sales.transactions WHERE date > '2024-01-01'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-bigquery
Safe BigQuery exploration through Model Context Protocol
Documentation | Quick Start | Examples
Overview
mcp-bigquery is a Model Context Protocol (MCP) server that enables AI assistants (such as Claude) to interact securely with Google BigQuery.
Key Features
Secure execution: All operations are strictly limited to dry-run verification. The server never executes queries that mutate data or incur execution costs.
Cost transparency: Provides estimates of query costs and processed bytes before execution.
Static analysis: Analyzes query dependencies and validates SQL syntax.
Schema exploration: Browses datasets, tables, and columns.
Business Value
Problem | Solution with mcp-bigquery |
Unintentional execution of costly queries | Pre-execution cost estimation |
Delayed development due to SQL syntax errors | Early syntax error detection |
Lack of visibility into schema structures | Secure schema metadata discovery |
Risk of unauthorized data mutation by AI | Enforced dry-run constraints |
Related MCP server: sql-review-agent
Quick Start
Step 1: Installation
Install the package via pip:
pip install mcp-bigqueryStep 2: Authentication
Set up Google Cloud Platform authentication:
# For user account authentication
gcloud auth application-default login
# For service account authentication
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.jsonStep 3: Claude Desktop Configuration
Configure the server in the Claude Desktop configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Add the following entry:
{
"mcpServers": {
"mcp-bigquery": {
"command": "mcp-bigquery",
"env": {
"BQ_PROJECT": "your-gcp-project-id"
}
}
}
}Step 4: Verification
Restart Claude Desktop and run the following queries to verify the setup:
"What datasets are available in my BigQuery project?"
"Can you estimate the cost of: SELECT * FROM dataset.table"
"Show me the schema for the users table"
Available Tools
SQL Validation and Analysis
Tool | Purpose | Primary Use Case |
bq_validate_sql | Check SQL syntax | Verification prior to query execution |
bq_dry_run_sql | Retrieve cost estimates and metadata | Pre-execution cost assessment |
bq_extract_dependencies | Map table dependencies | Lineage and dependency mapping |
bq_validate_query_syntax | Detailed syntax analysis | Debugging complex SQL queries |
Schema Discovery
Tool | Purpose | Primary Use Case |
bq_list_datasets | List all datasets in the project | Initial project discovery |
bq_list_tables | List tables with partitioning metadata | Dataset structure browsing |
bq_describe_table | Get detailed schema details | Column-level verification |
bq_get_table_info | Retrieve comprehensive metadata | Table statistics analysis |
bq_preview_table | Preview table data (cost-free) | Checking sample records without data scan costs |
Thebq_preview_table tool uses client.list_rows (API: tabledata.list) to retrieve sample rows directly, resulting in zero bytes scanned and no execution costs. To prevent unintended exposure of sensitive information (such as PII) to the LLM, this tool is disabled by default. You must explicitly opt in by setting MCP_BQ_ENABLE_PREVIEW=true in your environment config.
Configuration
Environment Variables
Variable | Purpose | Default |
| Target GCP Project ID | Determined via ADC |
| Target BigQuery Region | Not set |
| Price per TiB for cost estimation | 5.0 |
| Logging verbosity (DEBUG, INFO, WARNING, ERROR, CRITICAL) | WARNING |
| Enable the bq_preview_table tool (true/false) | false |
Example .env File
For local testing or development environments, you can define these variables in a .env file:
BQ_PROJECT=your-gcp-project-id
BQ_LOCATION=asia-northeast1
SAFE_PRICE_PER_TIB=5.0
LOG_LEVEL=WARNING
MCP_BQ_ENABLE_PREVIEW=trueComplete Claude Desktop Configuration Example
{
"mcpServers": {
"mcp-bigquery": {
"command": "mcp-bigquery",
"env": {
"BQ_PROJECT": "my-production-project",
"BQ_LOCATION": "asia-northeast1",
"SAFE_PRICE_PER_TIB": "6.0",
"LOG_LEVEL": "WARNING",
"MCP_BQ_ENABLE_PREVIEW": "true"
}
}
}
}Troubleshooting
Mapped Errors and Solutions
Authentication Error
Error: Could not automatically determine credentialsSolution: Re-authenticate using the command line:
gcloud auth application-default login
Permission Denied
Error: User does not have bigquery.tables.get permissionSolution: Grant the
BigQuery Data Viewerrole to the target identity:gcloud projects add-iam-policy-binding YOUR_PROJECT \ --member="user:your-email@example.com" \ --role="roles/bigquery.dataViewer"
Project ID Missing
Error: Project ID is requiredSolution: Ensure the
BQ_PROJECTvariable is set correctly in your configuration.
Examples of Usage
Example 1: Check Costs Before Running
# Before running an expensive query...
query = "SELECT * FROM `bigquery-public-data.github_repos.commits`"
# First, check the cost
result = bq_dry_run_sql(sql=query)
print(f"Estimated cost: ${result['usdEstimate']}")
print(f"Data processed: {result['totalBytesProcessed'] / 1e9:.2f} GB")
# Output:
# Estimated cost: $12.50
# Data processed: 2500.00 GBExample 2: Understand Table Structure
# Check table schema
result = bq_describe_table(
dataset_id="your_dataset",
table_id="users"
)
# Output:
# ├── user_id (INTEGER, REQUIRED)
# ├── email (STRING, NULLABLE)
# ├── created_at (TIMESTAMP, REQUIRED)
# └── profile (RECORD, REPEATED)
# ├── name (STRING)
# └── age (INTEGER)Example 3: Track Data Dependencies
# Understand query dependencies
query = """
WITH user_stats AS (
SELECT user_id, COUNT(*) as order_count
FROM orders
GROUP BY user_id
)
SELECT u.name, s.order_count
FROM users u
JOIN user_stats s ON u.id = s.user_id
"""
result = bq_extract_dependencies(sql=query)
# Output:
# Tables: ['orders', 'users']
# Columns: ['user_id', 'name', 'id']
# Dependency Graph:
# orders → user_stats → final_result
# users → final_resultProject Status and Version History
Version | Release Date | Summary of Changes |
v0.7.1 | 2026-08-17 | Refined mcp dependency constraints and streamlined wiki documentation |
v0.7.0 | 2026-06-21 | Added cost-free table preview tool ( |
v0.6.0 | 2026-06-21 | Thread-safe caching, recursive AST queries, backoff retries, and Google API exception mapping |
v0.5.0 | 2026-01-02 | Consolidated formatters, client cache, and unified logging controls |
v0.4.2 | 2025-12-08 | Modular schema explorer and unified client/logging controls |
v0.4.1 | 2025-01-22 | Error handling and debug logging improvements |
v0.4.0 | 2025-01-22 | Added schema discovery tools |
v0.3.0 | 2025-01-17 | Integrated SQL static analysis engine |
v0.2.0 | 2025-01-16 | Initial release supporting basic validation and dry-run queries |
Development and Contribution
For instructions on local development setup and contribution policies, please refer to the CONTRIBUTING.md guide.
# Clone the repository
git clone https://github.com/caron14/mcp-bigquery.git
cd mcp-bigquery
# Install development dependencies
pip install -e ".[dev]"
# Execute the test suite
pytest tests/License
This project is licensed under the MIT License. See LICENSE for details.
Available Tools
9 toolsbq_describe_tableB
Get table schema, metadata, and statistics
Inputs: table_id (required), dataset_id (required), project_id, format_output.
bq_dry_run_sqlB
Perform a dry-run of a BigQuery SQL query to get cost estimates and metadata
Inputs: sql (required), params, pricePerTiB.
bq_extract_dependenciesC
Extract table and column dependencies from BigQuery SQL
Inputs: sql (required), params.
bq_get_table_infoB
Get comprehensive table information including partitioning and clustering
Inputs: table_id (required), dataset_id (required), project_id.
bq_list_datasetsB
List all datasets in the BigQuery project
Inputs: project_id, max_results.
bq_list_tablesA
List all tables in a BigQuery dataset with metadata
Inputs: dataset_id (required), project_id, max_results, table_type_filter.
bq_preview_tableB
Get a preview of table data without running a query job (cost-free)
Inputs: table_id (required), dataset_id (required), project_id, max_results.
bq_validate_query_syntaxC
Enhanced syntax validation with detailed error reporting
Inputs: sql (required), params.
bq_validate_sqlA
Validate BigQuery SQL syntax without executing the query
Inputs: sql (required), params.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Several tools have overlapping purposes: bq_validate_sql and bq_validate_query_syntax both validate syntax, while bq_describe_table and bq_get_table_info both return table metadata. Agents could easily confuse these and pick the wrong tool.
Naming is mostly consistent with a clear bq_ prefix and snake_case verb_noun pattern. The main inconsistency is validate_sql versus validate_query_syntax, which are different names for the same kind of operation.
Nine tools is a reasonable count for a BigQuery exploration and validation server, but at least two pairs are redundant. Trimming the duplicates would make the set tighter without losing any real capability.
The server covers dataset/table discovery, schemas, partitioning/clustering metadata, data previews, SQL syntax validation, dry-run cost estimation, and dependency extraction. Minor gaps exist, such as no way to list columns independently or execute queries, but these are outside the validator scope.
Maintenance
Related MCP Connectors
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Query Postgres, MySQL, BigQuery, Iceberg and files with DuckDB, with per-query cost checks.
1Query OneLens cloud-cost data in natural language: breakdowns, trends, cost centers. Read-only.
DBRE-grade SQL analysis inside any MCP client. No connection. No install. Paste a query.
Related MCP Servers
- AlicenseAqualityFmaintenanceValidates BigQuery SQL syntax and performs dry-run analysis without executing queries, providing cost estimates, referenced tables, and schema previews.2Apache 2.0
- FlicenseNot gradedqualityDmaintenanceEnables reviewing BigQuery SQL queries for performance issues, cost estimation, and suggested rewrites via an MCP interface.1-
- AlicenseAqualityBmaintenanceEnables AI agents to run BigQuery queries safely under a configurable policy, with parsing, dry-run byte limits, row caps, and audit logging for every request.5MIT
- AlicenseAqualityCmaintenanceEnables estimating a BigQuery query's cost before running it, using a free dry run to report bytes processed and the estimated on-demand USD charge. It also flags common sources of wasted spend, such as SELECT * and missing partition filters on partitioned tables.1MIT