BigQuery Readonly MCP
Provides read-only access to Google BigQuery, allowing listing of projects, datasets, tables, schema retrieval, dry-run estimates, and safe SELECT query execution with configurable limits and error handling.
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., "@BigQuery Readonly MCPRun a query to get the top 10 products by sales from dataset retail.orders"
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.
BigQuery Readonly MCP
BigQuery Readonly MCP is a FastAPI-based Custom MCP server for safely querying BigQuery from ChatGPT. It is designed as a reusable internal analytics MCP: each tool accepts project_id, while the initial validation project is ice-sh.
Scope
GitHub repository:
Growth-Management/bigquery-readonly-mcpCloud Run deploy project:
bigquery-mcp-prodInitial BigQuery validation project:
ice-shAllowed email domain:
impress.co.jpDefault
maximumBytesBilled: 1GBDefault
max_results: 1000Default query timeout: 60 seconds
Security Model
The MCP server uses Google OAuth and BigQuery calls run with the authenticated user's access token. It does not use a service account to impersonate users for BigQuery query execution.
Users should receive the minimum required IAM permissions:
roles/bigquery.jobUseron the project where jobs are createdroles/bigquery.dataVieweron only the datasets they may inspect
The server enforces readonly SQL before execution. run_readonly_query and dry_run_query only allow one SELECT or WITH statement and reject DML, DDL, EXPORT, LOAD, grants, revokes, and procedure calls.
MCP Tools
list_projectslist_datasetslist_tablesget_table_schemadry_run_queryrun_readonly_query
All tools accept project_id where applicable. If omitted, the default is ice-sh.
Endpoints
GET /healthzPOST /mcpGET /oauth/authorizeGET /oauth/callbackGET /.well-known/oauth-authorization-server
Local Development
Create a local environment and install dependencies:
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txtSet local environment variables. Do not commit real secrets.
export BASE_URL="http://localhost:8080"
export GOOGLE_OAUTH_CLIENT_ID="..."
export GOOGLE_OAUTH_CLIENT_SECRET="..."
export SESSION_SECRET="replace-with-random-value"
export ALLOWED_DOMAIN="impress.co.jp"
export DEFAULT_PROJECT_ID="ice-sh"
export MAXIMUM_BYTES_BILLED="1073741824"
export MAX_RESULTS="1000"
export QUERY_TIMEOUT_SECONDS="60"Run the app:
uvicorn app.main:app --host 0.0.0.0 --port 8080 --reloadRun tests:
pytestOAuth Setup
Configure a Google OAuth Web application in bigquery-mcp-prod:
Consent screen: internal or equivalent organization-limited configuration
Authorized domain:
impress.co.jpRedirect URI:
https://<cloud-run-url>/oauth/callbackScopes:
openidemailprofilehttps://www.googleapis.com/auth/bigquery.readonly
Store these values in Secret Manager rather than the repository:
google-oauth-client-idgoogle-oauth-client-secretbigquery-mcp-session-secret
Cloud Run Deployment
The GitHub Actions workflow expects these GitHub Secrets:
GCP_PROJECT_ID:bigquery-mcp-prodGCP_WORKLOAD_IDENTITY_PROVIDERGCP_DEPLOY_SERVICE_ACCOUNTBASE_URL: deployed Cloud Run URL or custom domain
The deploy service account needs only deployment permissions, such as Artifact Registry write and Cloud Run deploy permissions. It is not used for BigQuery query execution.
Initial Validation On ice-sh
Use a user account in the allowed domain with the required BigQuery IAM permissions, then verify:
MCP connects to
/mcpGoogle OAuth login succeeds
dataset list can be retrieved from
ice-shtable list can be retrieved
schema can be retrieved
dry run returns estimated bytes processed
SELECTexecutes within limitsDML and DDL are rejected before BigQuery execution
unauthorized projects return Access Denied
audit logs are emitted to Cloud Logging
Audit Logging
Every tool call logs a structured audit event with:
timestampuser_emailtoolproject_iddatasettablebytes_processedsuccesserror
Some fields may be empty when the tool does not target a dataset or table, or when validation fails before a BigQuery job is created.
Current Phase Coverage
Phase 1: FastAPI app,
/healthz,/mcp, OAuth authorize/callback skeleton, user email lookupPhase 2: six initial BigQuery tools
Phase 3: readonly SQL guard,
maximumBytesBilled,max_results, timeout, basic query error handlingPhase 4 preview: structured audit log helper is included, but production log filtering and retention policy still need validation
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Growth-Management/bigquery-readonly-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server