kamalmemon/mcp-bigquery-gateway
If you are the rightful owner of mcp-bigquery-gateway and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The MCP BigQuery Gateway is a server that integrates Google BigQuery with AI assistants using the Model Context Protocol.
MCP BigQuery Gateway
A Model Context Protocol (MCP) server for Google BigQuery integration with AI assistants.
⚠️ Disclaimer: This code is largely generated through AI-assisted development ("vibe coding"). While it has been tested, we make no guarantees about correctness, security, or reliability. Use at your own risk in production environments.
Prerequisites
Required
- 🐳 Docker
- Google Cloud CLI
- Google Cloud Project with BigQuery API enabled
Features
- List datasets and tables
- Get table schemas
- Execute SQL queries
- With 🔒 read-only access - Only
SELECTqueries andWITHclauses (Common Table Expressions) are allowed. All DDL (CREATE, DROP, ALTER), DML (INSERT, UPDATE, DELETE), and other write operations are blocked for security.
- With 🔒 read-only access - Only
- Query validation
Query Validation
The validate_query tool uses BigQuery's dry run feature to validate queries without execution:
- Validates SQL syntax
- Shows bytes that will be processed and billed
- Returns expected result schema
- Free and instant execution
Example response:
{
"valid": true,
"total_bytes_processed": 1048576,
"total_bytes_billed": 10485760,
"schema": [{"name": "column_name", "type": "STRING"}]
}
Use this to catch errors and estimate costs before running queries.
Available Tools
Once configured, these tools will be available:
execute_query- Execute SQL querieslist_datasets- List BigQuery datasetslist_tables- List tables in a datasetget_table_schema- Get table schemavalidate_query- Validate SQL queriesget_job_details- Get full query text and job metadata for analysis
Use Cases
Query Optimization
Identify and optimize expensive BigQuery queries using Claude. Ask for "the top 3 queries by slot time in the last 24 hours", then use get_job_details to retrieve the full query text for any high-cost job. Claude can then analyze the query and suggest optimizations like better partitioning, efficient joins, or reduced data scanning to potentially cut costs from 14TB to 1-2TB.
Setup
1. Clone and Authenticate
# Clone the repository
git clone https://github.com/kamalmemon/mcp-bigquery-gateway.git
cd mcp-bigquery-gateway
# Authenticate with Google Cloud
make auth
# Set your project
gcloud config set project YOUR_PROJECT_ID
2. Build Docker Container
# Build the Docker image and generate Cursor configuration
make build
The make build command will:
- ✅ Verify Google Cloud authentication
- 🧪 Run all tests
- 🐳 Build the Docker container locally
- 📋 Generate the Cursor MCP configuration JSON
3. Configure Cursor
After make build completes, it will display a JSON configuration. Copy this JSON and save it to either:
- Global configuration:
~/.cursor/mcp.json(applies to all projects) - Project-specific:
./.cursor/mcp.json(applies only to this project)
💡 Tip: You can also find an example configuration in
Then restart Cursor.
4. Test the Setup
# Test the container runs correctly
make run
# You should see the MCP server start and wait for connections
Usage
Commands
make auth- Setup Google Cloud authenticationmake build- Build Docker image and show Cursor configmake run- Start interactive Docker containermake test- Run tests locallymake format- Format and lint codemake clean- Clean up
Authentication
The Docker container uses your local Google Cloud credentials:
- Run
make authto authenticate with Google Cloud - Your
~/.config/gclouddirectory is mounted read-only into the container - The configuration automatically uses your current project from
gcloud config get-value project
Troubleshooting
- "No project set": Run
gcloud config set project YOUR_PROJECT_ID - "Not authenticated": Run
make auth - "Docker image not found": Run
make buildfirst - Cursor not connecting: Ensure you saved the JSON to the correct
.cursor/mcp.jsonfile and restarted Cursor
License
This project is licensed under the MIT License - see the file for details.