Secure BigQuery MCP Gateway
Provides a secure gateway for AI assistants to query BigQuery data with enforced read-only access, dataset boundaries, result limits, query budget limits, and audit-friendly BigQuery labels.
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., "@Secure BigQuery MCP GatewayWhat were total sales by region last quarter?"
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.
Secure BigQuery MCP Gateway
A public reference implementation for connecting an AI assistant to BigQuery without giving the assistant a Google credential. It runs a remote MCP server on Cloud Run and enforces read-only access, dataset boundaries, result limits, query budget limits, and audit-friendly BigQuery labels.
Portfolio project, not a client system. It contains no customer data, project IDs, service-account keys, or production endpoints.
The design problem
An AI assistant needs to answer questions from an analytics warehouse while a business owner is offline. The common mistake is to reuse a person's Google OAuth refresh token for every part of the connection. This creates a fragile and over-privileged integration.
This project splits the trust boundary:
AI assistant / scheduled workflow
└── authenticates to the MCP endpoint
└── Cloud Run MCP gateway
└── uses its own restricted service account for BigQueryThe caller can request an approved tool. It never receives direct Google Cloud credentials. The Cloud Run service identity can query only approved reporting data. It cannot modify the warehouse.
Related MCP server: bq-readonly-mcp
What it demonstrates
Remote MCP over Streamable HTTP, the recommended transport for deployed MCP servers.
Python MCP implementation with a Cloud Run-ready container.
Separate inbound caller authentication and outbound Google service identity.
Application Default Credentials rather than a service-account JSON key.
BigQuery dry-run cost checks plus
maximum_bytes_billedenforcement.SQL guardrails: one statement,
SELECT/WITH ... SELECTonly, dataset allowlist, row cap, timeout, and query labels.A production-minded recommendation to grant access to curated reporting views rather than raw operational tables.
See the architecture decision record for the security rationale.
Important caveat about inbound authentication
The reference build protects /mcp with a bearer token injected from Secret Manager. This is
appropriate for a controlled machine-to-machine scheduler and makes the identity separation
visible in a small project.
For a Claude product that supports MCP OAuth/OIDC discovery, replace the middleware with a standards-compliant OAuth/OIDC token verifier. The correct choice depends on the Claude client and scheduling system; BigQuery access remains unchanged because it always comes from the Cloud Run service account.
Local development
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
cp .env.example .env
# Update .env with a non-production project, allowed reporting dataset, and random token.
python -m secure_bigquery_mcp_gateway.appThe MCP endpoint is available at http://localhost:8080/mcp. Supply:
Authorization: Bearer <MCP_BEARER_TOKEN>Run the policy tests without any external test runner:
python -m unittest discover -s testsDeploy to Cloud Run
Before deploying, create a dedicated service account and grant:
roles/bigquery.jobUseron the query project.roles/bigquery.dataVieweron only the approved dataset or, preferably, curated views.
Build and deploy from the client-owned Google Cloud project:
gcloud builds submit --tag europe-west2-docker.pkg.dev/PROJECT_ID/mcp/secure-bigquery-mcp-gateway
gcloud run deploy secure-bigquery-mcp-gateway \
--image europe-west2-docker.pkg.dev/PROJECT_ID/mcp/secure-bigquery-mcp-gateway \
--region europe-west2 \
--service-account claude-bq-mcp@PROJECT_ID.iam.gserviceaccount.com \
--allow-unauthenticated \
--set-env-vars GOOGLE_CLOUD_PROJECT=PROJECT_ID,ALLOWED_DATASETS=analytics_reporting \
--set-secrets MCP_BEARER_TOKEN=mcp-bearer-token:latestThe application needs no GOOGLE_APPLICATION_CREDENTIALS file. Cloud Run supplies short-lived
credentials for its attached service account automatically.
--allow-unauthenticated is intentional for this reference build: the remote MCP caller cannot
usually mint a Google Cloud IAM token. The application protects /mcp with its own bearer-token
layer, which is separate from the Cloud Run service identity used for BigQuery. For an OAuth/OIDC
capable MCP client, replace this with a standards-compliant verifier and add edge protection.
Production checklist
Use reporting views or an authorised view layer, not raw customer/event tables.
Store the bearer token in Secret Manager and rotate it; use OAuth/OIDC when the MCP client supports it.
Set a conservative byte cap and alert on BigQuery job labels.
Restrict Cloud Run ingress and use a custom domain/WAF when appropriate.
Test a cold start, a denied write query, an over-budget query, and the real overnight caller.
Keep deployment privileges separate from the running service account.
Project story for clients
I designed this gateway to solve the gap between an AI assistant's ability to call tools and a production data warehouse's need for least-privilege access. The key decision is separating the assistant's authentication to the MCP endpoint from the Cloud Run service account that executes constrained, read-only BigQuery queries.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityBmaintenanceEnables reading BigQuery data from ChatGPT using read-only SQL queries, with OAuth authentication and project-level access control.
- Alicense-qualityBmaintenanceA read-only BigQuery MCP server with auto-LIMIT injection, dry-run cost guard, and ADC authentication. Allows safe SQL querying of BigQuery by LLMs without risk of data modification or unexpected costs.1MIT
- Alicense-qualityBmaintenanceEnables LLMs to explore BigQuery datasets and tables, run safe read-only queries, and optionally perform vector search using BigQuery embeddings.9MIT
- Alicense-qualityCmaintenanceEnables AI assistants to query and analyze Google BigQuery data, including schema browsing, running queries, and comparing datasets through natural language.MIT
Related MCP Connectors
Paid remote MCP for AI Studio Workspace approval gate MCP, structured receipts, audit logs, and revi
Remote MCP for AI Studio Android release gate MCP, structured receipts, audit logs, and reviewer-rea
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/raghurs49/secure-bigquery-mcp-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server