BQ Agent Gateway
Enables safe, read-only interaction with Google BigQuery through Claude, with layered guardrails preventing dangerous or expensive queries. Exposes tools for listing datasets, tables, estimating costs, and running queries.
README
BQ Agent Gateway
A read-only MCP server that connects Claude to BigQuery with layered guardrails against dangerous and expensive SQL.
What it blocks
Static AST validation (parsed with sqlglot, not regex):
- Anything that isn't a
SELECT(noINSERT/UPDATE/DELETE/MERGE/DDL) SELECT *andtable.*(butCOUNT(*)is fine)CROSS JOINand implicit cartesian products (comma joins with noON)- Multiple statements in one call (blocks
SELECT 1; DROP TABLE ...) - Queries referencing datasets outside an allowlist
- Missing
LIMIT(auto-injected by default) and over-largeLIMITs
BigQuery cost gate:
- A dry-run estimates bytes scanned before running; over-threshold queries are rejected
- Execution sets
maximum_bytes_billedas a hard server-side cap, so even a mis-estimate can't overspend — BigQuery kills the job instead - Row count and wall-clock timeout are capped
Tools exposed
list_datasets, list_tables, describe_table, estimate_query_cost, run_query.
Setup
pip install -r requirements.txt # or: uv pip install -r requirements.txt
cp .env.example .env # then edit values
# Auth: either set GOOGLE_APPLICATION_CREDENTIALS to a service-account key,
# or run:
gcloud auth application-default login
Give the service account only what it needs:
roles/bigquery.dataViewer + roles/bigquery.jobUser. The dataViewer role
cannot mutate data, so the read-only guarantee is enforced at the IAM layer too,
not just in code.
Run
# stdio (for Claude Desktop)
python server.py
# or HTTP
fastmcp run server.py --transport http --port 8000
Register with Claude Desktop
Edit claude_desktop_config.json
(macOS: ~/Library/Application Support/Claude/,
Windows: %APPDATA%\Claude\):
{
"mcpServers": {
"bq-agent-gateway": {
"command": "python",
"args": ["/absolute/path/to/bq-agent-gateway/server.py"],
"env": {
"BQ_PROJECT": "my-gcp-project",
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/key.json",
"BQ_ALLOWED_DATASETS": "analytics,prod_reporting",
"BQ_MAX_BYTES_SCANNED_GIB": "5"
}
}
}
}
Restart Claude Desktop; the BigQuery tools appear in the tools menu.
Design notes / defense in depth
The guardrails are structured as independent layers so a bypass of one doesn't defeat the rest:
- IAM — read-only service account can't write regardless of SQL.
- AST validation — shape checks that regex can't do reliably.
- Dry-run cost gate — the real budget protection for BigQuery.
maximum_bytes_billed— hard cap enforced by BigQuery itself.- Row/time caps — bound the response size and latency.
Toggle any static rule via env vars (see .env.example) without touching code.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.