Provides secure access to BigQuery datasets and tables, enabling query execution, schema exploration, and analytics on Google Cloud's data warehouse platform.
Enables enhanced metadata storage, query result caching with TTL management, schema evolution tracking, query analytics, and business context documentation through Supabase database tables.
Click on "Install 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., "@MCP BigQuery Servershow me the top 10 products by sales this month"
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 Server
A FastMCP server for securely accessing BigQuery datasets with intelligent caching, schema evolution tracking, and query analytics via Supabase integration.
Features
Multiple Transport Methods: HTTP, Stdio, and SSE (Server-Sent Events)
BigQuery Integration: Secure access to BigQuery datasets and tables
Intelligent Caching: Query result caching with TTL management and dependency tracking
Supabase Knowledge Base: Enhanced metadata storage and business context
Query Analytics: Performance analysis and optimization recommendations
Schema Evolution Tracking: Monitor table schema changes over time
AI-Powered Suggestions: Query recommendations based on usage patterns
Real-time Events: Server-Sent Events for query monitoring and system status
Read-only Queries: Safety-first approach with read-only SQL execution
Row Level Security: User-based access control and cache isolation
Comprehensive API: RESTful endpoints and MCP protocol support
Installation
Using uv (recommended):
Configuration
Copy the example environment file:
Edit
.envwith your BigQuery and Supabase details:
Supabase Setup
For enhanced caching and analytics features, you'll need a Supabase project with the following tables and policies.
query_cache- Stores cached query resultstable_dependencies- Tracks table dependencies for cache invalidationquery_history- Historical query execution patternsquery_templates- Reusable query templatescolumn_documentation- Business context for table columnsevent_log- System event tracking
Run these SQL queries in your Supabase SQL editor to set up the schema:
These tables enable:
Query result caching and dependency tracking
Schema evolution and documentation
Query analytics and pattern recognition
Real-time event logging
User preferences and settings
Row Level Security (RLS) is enabled for all tables.
You can choose from several RLS policy options:
Option 1: Allow all operations (for development/testing)
Option 2: User-based policies (recommended for production with authentication)
Option 3: Service role policies (for backend services)
Customize the RLS policies as needed for your environment.
The server will work without Supabase but with limited functionality.
Usage
Command Line
Python API
Using with Claude Desktop
To use this MCP BigQuery server with Claude Desktop, you need to configure it in your Claude Desktop configuration file.
1. Install and Configure the Server
First, ensure the server is installed and configured:
2. Configure Claude Desktop
Add the server to your Claude Desktop configuration file:
Configuration file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
For macOS/Linux:
For Windows:
3. Authentication Setup
BigQuery Authentication - Choose one of two authentication methods:
Option A: Service Account Key File
Create a service account in Google Cloud Console
Download the JSON key file
Set the
KEY_FILEenvironment variable to the path of this file
Option B: Default Credentials
Install and configure Google Cloud SDK:
gcloud auth application-default loginRemove the
KEY_FILEfrom the environment variables
Supabase Authentication (Optional but recommended):
Create a Supabase project
Get your project URL and service role key from the Supabase dashboard
Set up the required database schema (see Supabase Setup section)
4. Restart Claude Desktop
After saving the configuration file, restart Claude Desktop completely for the changes to take effect.
5. Using the Server
Once configured, you can interact with your BigQuery data through Claude Desktop with enhanced capabilities:
Basic Operations:
"What datasets do I have available in BigQuery?"
"Show me the schema for the [dataset].[table] table"
"Run a query to get the first 10 rows from [dataset].[table]"
Enhanced Features (with Supabase):
"Analyze the performance of my recent queries"
"What query suggestions do you have for the sales table?"
"Show me the schema changes for [dataset].[table] over the last month"
"Explain what the customer_events table is used for"
"What are the cache statistics?"
Streamlit AI Analyst App
The repository ships with a Streamlit front-end (streamlit_app/app.py) that wraps the MCP BigQuery
server in an interactive "AI data analyst" experience. It uses an OpenAI model to translate natural
language questions into safe, read-only BigQuery SQL, executes the query through the MCP server, and
summarises the results in real time.
Prerequisites
A running instance of the MCP BigQuery server (HTTP transport).
Python dependencies installed (
uv pip install -e .).An OpenAI API key available as an environment variable (
OPENAI_API_KEY) or entered in the UI.
Running the Streamlit app
The sidebar lets you configure the MCP base URL, user/session identifiers, query cost controls and the OpenAI model. Selecting a dataset and optional tables shares schema information with the agent to improve SQL generation. Ask questions in the chat interface and the assistant will:
Propose a BigQuery query plan using the provided metadata and best practices.
Execute the SQL via the MCP server, respecting caching and maximum bytes billed.
Return a Markdown summary, preview table, downloadable CSV and the executed SQL for transparency.
API Endpoints
Resources
GET /resources/list- List all available datasets and tablesGET /bigquery/{project_id}/{dataset_id}/{table_id}- Get table metadata
Tools
POST /tools/execute_bigquery_sql- Execute read-only SQL queries with cachingPOST /tools/get_datasets- Get list of datasets with metadataPOST /tools/get_tables- Get tables in a dataset with documentationPOST /tools/get_table_schema- Get table schema with business contextPOST /tools/get_query_suggestions- Get AI-powered query recommendationsPOST /tools/explain_table- Get comprehensive table documentationPOST /tools/analyze_query_performance- Analyze query performance patternsPOST /tools/get_schema_changes- Track schema evolution over timePOST /tools/manage_cache- Cache management operationsPOST /tools/health_check- System health check
Events (SSE)
GET /events/system- System status eventsGET /events/queries- Query execution eventsGET /events/resources- Resource update events
Health
GET /health- Health check endpoint
MCP Tools and Resources
Resources
resources://list- List all BigQuery resourcesbigquery://{project}/{dataset}/{table}- Access specific table metadata
Tools
Core BigQuery Tools
execute_bigquery_sql- Execute a read-only SQL query with intelligent cachingParameters:
sql,maximum_bytes_billed,use_cache,user_id,force_refresh
get_datasets- Get list of datasets with metadataget_tables- Get tables in a dataset with column documentationget_table_schema- Get comprehensive table schema detailsParameters:
dataset_id,table_id,include_samples,include_documentation
Enhanced Analytics Tools (requires Supabase)
get_query_suggestions- Get AI-powered query recommendationsParameters:
tables_mentioned,query_context,limit,user_id
explain_table- Get comprehensive table documentation and business contextParameters:
project_id,dataset_id,table_id,include_usage_stats,user_id
analyze_query_performance- Analyze historical query performance patternsParameters:
sql,tables_accessed,time_range_hours,user_id,include_recommendations
get_schema_changes- Track schema evolution and changes over timeParameters:
project_id,dataset_id,table_id,limit,include_impact_analysis,user_id
System Management Tools
manage_cache- Comprehensive cache management operationsParameters:
action,target,project_id,dataset_id,table_id,user_id
health_check- System health check including BigQuery, Supabase, and cache statusParameters:
user_id
Intelligent Caching System
The server includes a sophisticated caching system powered by Supabase:
Features
Query Result Caching: Automatic caching of query results with configurable TTL
Table Dependency Tracking: Cache invalidation based on table modifications
Cache Statistics: Hit rates, performance metrics, and usage analytics
User-based Isolation: Row Level Security for multi-tenant environments
Automatic Cleanup: Expired cache entry removal
Cache Management
Development
Setup Development Environment
Project Structure
Authentication
BigQuery Authentication
The server supports two authentication methods:
Service Account Key File: Specify the path in the
KEY_FILEenvironment variableDefault Credentials: Uses Google Cloud SDK default credentials if no key file is provided
Supabase Authentication
Service Role Key: Full access to all tables (recommended for server deployment)
Anonymous Key: Limited access with Row Level Security (RLS) policies
Security
All SQL queries are restricted to read-only operations
Forbidden keywords (INSERT, UPDATE, DELETE, CREATE, DROP, ALTER) are blocked
Project ID validation ensures queries only run against the configured project
Configurable query cost limits via
maximum_bytes_billedparameterRow Level Security (RLS) support for multi-tenant deployments
User-based cache isolation and access control
Event Streaming
The server provides real-time events via Server-Sent Events (SSE):
System Events: Server health, connection status, Supabase connectivity
Query Events: Query start, progress, completion, errors, cache hits/misses
Resource Events: Dataset and table updates, schema changes
Analytics Events: Performance insights, usage patterns
Performance Considerations
Query Caching: Significantly reduces BigQuery costs and improves response times
Connection Pooling: Efficient BigQuery client management
Async Operations: Non-blocking I/O for better concurrency
Lazy Loading: Supabase connections initialized only when needed
Cache Optimization: Intelligent cache key generation and dependency tracking
Monitoring and Observability
The server provides comprehensive monitoring capabilities:
Health Checks: BigQuery and Supabase connectivity status
Cache Metrics: Hit rates, storage usage, performance statistics
Query Analytics: Execution patterns, cost analysis, optimization recommendations
Event Logging: Detailed audit trails for all operations
Error Tracking: Comprehensive error logging and reporting
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests for new functionality
Run the test suite
Submit a pull request
License
[Add your license information here]
Changelog
v0.2.0
Added Supabase integration for enhanced caching and analytics
Implemented intelligent query caching with table dependency tracking
Added AI-powered query suggestions and table explanations
Enhanced schema evolution tracking capabilities
Improved performance analysis and optimization recommendations
Added comprehensive event logging and audit trails
Implemented Row Level Security (RLS) support for multi-tenant deployments