Enables interaction with Google BigQuery to execute read-only SQL queries, list datasets and tables, inspect table schemas, retrieve sample data, and estimate query costs, allowing AI agents to analyze data stored in BigQuery.
BigQuery MCP Server
A Model Context Protocol (MCP) server for accessing Google BigQuery. This server enables Large Language Models (LLMs) to understand BigQuery dataset structures and execute SQL queries.
Features
Authentication and Connection Management
Supports Application Default Credentials (ADC) or service account key files
Configurable project ID and location settings
Authentication verification on startup
Tools
query
Execute read-only (SELECT) BigQuery SQL queries
Configurable maximum results and bytes billed
Security checks to prevent non-SELECT queries
list_all_datasets
List all datasets in the project
Returns an array of dataset IDs
list_all_tables_with_dataset
List all tables in a specific dataset with their schemas
Requires a datasetId parameter
Returns table IDs, schemas, time partitioning information, and descriptions
get_table_information
Get table schema and sample data (up to 20 rows)
Support for partitioned tables with partition filters
Warnings for queries on partitioned tables without filters
dry_run_query
Check query validity and estimate cost without execution
Returns processing size and estimated cost
Security Features
Only SELECT queries are allowed (read-only access)
Default limit of 500GB for query processing to prevent excessive costs
Partition filter recommendations for partitioned tables
Secure handling of authentication credentials
Installation
Local Installation
Docker Installation
You can also run the server in a Docker container:
Or using Docker Compose:
MCP Configuration
To use this server with an MCP-enabled LLM, add it to your MCP configuration:
You can also use Application Default Credentials instead of a service account key file:
Setting up Application Default Credentials
To authenticate using Application Default Credentials:
Install the Google Cloud SDK if you haven't already:
Run the authentication command:
Follow the prompts to log in with your Google account that has access to the BigQuery project.
The credentials will be saved to your local machine and automatically used by the BigQuery MCP server.
Testing
You can use inspector for testing and debugging.
Usage
Using the Helper Script
The included run-server.sh
script makes it easy to start the server with common configurations:
Manual Execution
You can also run the compiled binary directly:
Example Client
An example Node.js client is included in the examples
directory:
Command Line Options
--project-id
: Google Cloud project ID (required)--location
: BigQuery location (default: asia-northeast1)--key-file
: Path to service account key file (optional)--max-results
: Maximum rows to return (default: 1000)--max-bytes-billed
: Maximum bytes to process (default: 500000000000, 500GB)
Required Permissions
The service account or user credentials should have one of the following:
roles/bigquery.user
(recommended)
Or both of these:
roles/bigquery.dataViewer
(for reading table data)roles/bigquery.jobUser
(for executing queries)
Example Usage
Query Tool
List All Datasets Tool
List All Tables With Dataset Tool
Get Table Information Tool
Dry Run Query Tool
Error Handling
The server provides detailed error messages for:
Authentication failures
Permission issues
Invalid queries
Missing partition filters
Excessive data processing requests
Code Structure
The server is organized into the following structure:
License
MIT
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A Model Context Protocol server that enables LLMs to understand BigQuery dataset structures and execute SQL queries.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides access to BigQuery. This server enables LLMs to inspect database schemas and execute queries.Last updated -120MIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact with GraphQL APIs by providing schema introspection and query execution capabilities.Last updated -5201MIT License
- -securityFlicense-qualityA Model Context Protocol server that enables LLMs to interact with GraphQL APIs by providing schema introspection and query execution capabilities.Last updated -1
MCP TapData Serverofficial
-securityFlicense-qualityA Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.Last updated -