A powerful BigQuery analytics MCP (Model Context Protocol) tool designed to work with Desktop Commander. Provides cost-protected BigQuery queries, automated CSV output, and comprehensive data analysis through AI-powered conversations.
π― Designed for use with Desktop Commander MCP clients:
- Claude Desktop
- Cursor
- Claude Code
- Windsurf
- GitHub Copilot in VS Code
- And other MCP-compatible tools
This tool is designed to work with Desktop Commander MCP.
π For installation instructions, visit: desktopcommander.app
Once installed, you can use natural language to interact with BigQuery:
- "Run a cost-safe BigQuery query on my user data"
- "Analyze GitHub language trends and save as CSV"
- "Check my BigQuery usage costs for this month"
- "Generate a cohort analysis report"
- Version: 14.0.0 or higher
- Installation:
- macOS:
brew install nodeor download from nodejs.org - Windows: Download from nodejs.org or use
winget install OpenJS.NodeJS - Linux:
# Ubuntu/Debian curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs # CentOS/RHEL/Fedora sudo dnf install npm nodejs
- macOS:
- Installation:
- macOS:
brew install google-cloud-sdk - Windows: Download from cloud.google.com/sdk
- Linux:
curl https://sdk.cloud.google.com | bash exec -l $SHELL gcloud init
- macOS:
# Authenticate with Google Cloud
gcloud auth login
# Get list of projects
gcloud projects list
# Set your project (replace with your actual project ID) from list above
gcloud config set project your-bigquery-project-id
# Test BigQuery access
bq ls
# If you need application default credentials
gcloud auth application-default login# Check Node.js version
node --version # Should be 14.0.0+
# Check if BigQuery CLI works
bq version
# Test authentication
bq ls # Should list your datasets
# Clone the repository
git clone https://github.com/desktop-commander/bigquery-cli-toolkit.git
# OR
# git clone git@gh.dc.app:desktop-commander/bigquery-cli-toolkit.git
cd bigquery-cli-toolkit
# π QUICK: Try the interactive demo immediately (works with any Google account)
npm run demo
# OR test your system setup
node test-installation.js# π― NEW: Run the interactive demo to see everything in action
node interactive-demo.js
# Or run individual examples:
# Try the built-in test query (works with any project)
node run-query.js queries/test-query.sql
# π₯ Try these public dataset queries (no setup needed):
# See trending Wikipedia articles from the past week
node run-query.js queries/examples/public-wikipedia-trending.sql
# Analyze programming language popularity on GitHub
node run-query.js queries/examples/public-github-languages.sql
# Web analytics insights from Google Analytics sample data
node run-query.js queries/examples/public-google-analytics.sql
# Business intelligence with NYC taxi data
node run-query.js queries/examples/public-nyc-taxi-insights.sql
# Check your BigQuery usage and costs
node run-query.js queries/examples/query-performance.sqlChoose your use case:
# Analyze daily sales metrics
node run-query.js queries/examples/daily-metrics.sql --output sales-report.csv# Run cohort analysis
node run-query.js queries/templates/user-cohort-analysis.sql --output cohorts.csv# Analyze your BigQuery usage and costs
node run-query.js queries/examples/cost-analysis.sql --output cost-report.csv# Check data freshness across your tables
node run-query.js queries/examples/data-freshness-check.sql# Copy a template and modify it for your needs
cp queries/examples/daily-metrics.sql my-custom-analysis.sql
# Edit my-custom-analysis.sql with your table names and columns
node run-query.js my-custom-analysis.sql --output my-results.csvπ You're now running BigQuery analytics with cost protection and automated CSV output!
Runs BigQuery queries with cost protection and dry-run validation.
# Basic usage
node safe-query.js queries/user-analysis.sql
# Custom byte limit (default: 100MB)
node safe-query.js queries/large-analysis.sql 1073741824 # 1GB limit
# Get help
node safe-query.js --helpFeatures:
- π‘οΈ Cost protection with customizable byte limits
- π Dry-run validation before execution
- π° Cost estimation display
- β‘ Interactive confirmation for expensive queries
Runs queries with automatic CSV output and intelligent analysis.
# Basic usage
node run-query.js queries/analytics.sql
# Advanced options
node run-query.js queries/report.sql --output reports/data.csv
node run-query.js queries/big-query.sql --limit 20000000000 # 20GB limit
node run-query.js queries/test.sql --dry-run
node run-query.js queries/sample.sql --preview 20Features:
- π Automatic CSV output with timestamps
- π Preview of results
- π Smart data analysis and pattern detection
- βοΈ Configurable byte limits and output options
Creates and manages BigQuery views for complex analyses.
node create-view.js queries/create-summary-view.sqlbigquery-cli-toolkit/
βββ π§ Core Scripts
β βββ package.json # Project configuration
β βββ safe-query.js # Cost-protected query runner
β βββ run-query.js # Universal query runner
β βββ create-view.js # BigQuery view creator
β βββ test-installation.js # Installation verification
β
βββ π queries/ # SQL query files
β βββ examples/ # Example queries
β βββ templates/ # Query templates
β βββ test-query.sql # Basic test query
β
βββ π results/ # Query output directory
β βββ (generated CSV files)
β
βββ π dashboards/ # HTML visualizations (optional)
β βββ (dashboard files)
β
βββ βοΈ scripts/ # Helper utilities
β βββ (automation scripts)
β
βββ π documentation/ # Guides and examples
β βββ query-examples.md # SQL query examples
β βββ best-practices.md # BigQuery best practices
β βββ troubleshooting.md # Common issues
β
βββ π§ Configuration
βββ .gitignore # Git ignore rules
βββ LICENSE # MIT license
βββ CONTRIBUTING.md # Contribution guidelines
βββ CHANGELOG.md # Version history
# Check data freshness
node run-query.js queries/examples/data-freshness-check.sql
# Run standard reports
node run-query.js queries/examples/daily-metrics.sql --output reports/daily.csv
# Monitor query performance
node safe-query.js queries/examples/performance-metrics.sql# Comprehensive data analysis
node run-query.js queries/examples/weekly-analysis.sql --output weekly/analysis.csv
# Cost analysis
node run-query.js queries/examples/cost-analysis.sql --output weekly/costs.csv
# Performance trends
node run-query.js queries/examples/performance-trends.sql --output weekly/performance.csv# Test expensive queries safely
node safe-query.js queries/large-dataset-analysis.sql 5368709120 # 5GB limit
# Dry-run before execution
node run-query.js queries/expensive-query.sql --dry-run
# Preview results before full execution
node run-query.js queries/sample-analysis.sql --preview 100Create a .env file for custom configuration:
# BigQuery Configuration
BIGQUERY_PROJECT_ID=your-project-id
BIGQUERY_DATASET=your-dataset
BIGQUERY_DEFAULT_LOCATION=US
# Cost Protection
MAX_QUERY_BYTES=104857600 # 100MB default
SAFE_MODE_ENABLED=true
# Output Settings
DEFAULT_OUTPUT_DIR=./results
CSV_DELIMITER=,
INCLUDE_HEADERS=truenode safe-query.js query.sql [max_bytes] [--help]node run-query.js query.sql [options]
--output <file> Custom output filename
--limit <bytes> Maximum bytes to process
--dry-run Validate query without executing
--preview <rows> Show preview of results
--no-analysis Skip automatic data analysis
--format <type> Output format (csv, json, table)-- queries/examples/basic-exploration.sql
SELECT
COUNT(*) as total_rows,
COUNT(DISTINCT column_name) as unique_values,
MIN(date_column) as earliest_date,
MAX(date_column) as latest_date
FROM `your-project.your-dataset.your-table`
WHERE date_column >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)-- queries/examples/query-performance.sql
SELECT
job_id,
query,
total_bytes_processed,
total_slot_ms,
creation_time
FROM `your-project.region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT`
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)
ORDER BY total_bytes_processed DESC
LIMIT 10-- queries/examples/cost-analysis.sql
SELECT
DATE(creation_time) as query_date,
COUNT(*) as total_queries,
SUM(total_bytes_processed) as total_bytes,
AVG(total_bytes_processed) as avg_bytes_per_query
FROM `your-project.region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT`
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
GROUP BY DATE(creation_time)
ORDER BY query_date DESC# Re-authenticate
gcloud auth login
gcloud auth application-default login
# Check current authentication
gcloud auth list
# Test BigQuery access
bq ls# Check version
node --version
# Update Node.js (macOS)
brew upgrade node
# Update Node.js (Windows)
winget upgrade OpenJS.NodeJS# Validate query syntax
node run-query.js your-query.sql --dry-run
# Check with cost protection
node safe-query.js your-query.sql
# Enable debug mode
DEBUG=1 node run-query.js your-query.sql# Check BigQuery permissions
bq show your-dataset-name
# List accessible projects
gcloud projects list
# Set correct project
gcloud config set project your-project-id- Use date filters to limit data volume
- Sample data for exploratory analysis
- Break complex queries into smaller parts
- Use views for frequently accessed data combinations
- Always dry-run expensive queries first
- Set appropriate byte limits
- Use streaming exports for large result sets
- Monitor query costs in the Google Cloud Console
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Add your changes and tests
- Commit:
git commit -am 'Add feature' - Push:
git push origin feature-name - Submit a Pull Request
# Clone and setup
git clone https://github.com/desktop-commander/bigquery-cli-toolkit.git
cd bigquery-cli-toolkit
# Test installation
node test-installation.js
# Run tests
npm test
# Lint code
npm run lintThis toolkit was built with Desktop Commander, an AI-powered command-line interface that brings natural language interaction to your development workflow.
Desktop Commander enables you to:
- Run queries naturally: "Analyze user engagement for the last 30 days"
- Generate reports automatically: "Create a CSV report of daily metrics"
- Monitor costs: "Check if this query is safe to run"
- Schedule analyses: "Run this analysis every morning"
# Clone this toolkit to your workspace
git clone https://github.com/desktop-commander/bigquery-cli-toolkit.git
# Desktop Commander can now help you:
# - Run queries with cost protection
# - Generate and customize analytics reports
# - Automate BigQuery workflows
# - Create custom dashboardsLearn more about Desktop Commander at desktopcommander.app
MIT License - see LICENSE file for details.
Current version: 1.0.0
A powerful toolkit for BigQuery analytics with built-in safety and automation. Built with Desktop Commander to enable seamless BigQuery integration and workflow automation.