bq-readonly-mcp
Provides read-only access to Google BigQuery datasets, including the ability to list datasets, list tables, get table metadata, describe columns, run SELECT queries with automatic LIMIT and cost control, and estimate query costs.
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., "@bq-readonly-mcpshow me the tables in the sales dataset"
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.
bq-readonly-mcp
π Read-only BigQuery MCP server with auto-LIMIT, dry-run cost guard, and ADC auth. Safe for LLMs to query your BigQuery β no DML, no surprises, no runaway bills.
β¨ Why this exists
LLMs connected to BigQuery can accidentally scan terabytes if the MCP layer lets them run arbitrary SQL. bq-readonly-mcp prevents that by design: every query goes through a strict SELECT/WITH-only validator, gets an automatic LIMIT injected before it runs, and is priced via a dry-run before any bytes are billed. If the estimated cost exceeds the cap (default 1 GB), the query is refused outright β before a single byte hits your bill.
The server runs as a local stdio process under your OS account, uses Application Default Credentials, and exposes zero write operations. There is no INSERT, no UPDATE, no DELETE, no DDL β anywhere in the codebase. The only thing it can do is read, and it does that safely.
π οΈ The 7 tools
Tool | What it does | Use when⦠|
| List datasets in the project, with optional name filter | Starting exploration, finding what exists |
| List tables in a dataset, with optional name filter | Drilling into a specific dataset |
| Table type, partitioning, clustering, row count, size | Checking if a table is large before querying |
| Column schema for a table (no data scan) | Understanding the shape of a table cheaply |
| Full bundle: metadata + columns + 3 sample rows | Onboarding to an unfamiliar table |
|
| Running ad-hoc SQL |
| Standalone dry-run β returns estimated bytes and USD cost | Checking query cost before running it |
π Quick start
Recommended β run directly via uvx (no install needed):
uvx bq-readonly-mcp --project your-project-id --location USFrom PyPI (persistent install):
uv tool install bq-readonly-mcp
bq-readonly-mcp --project your-project-id --location USFrom source:
git clone https://github.com/mariadb-RupeshBiswas/bq-readonly-mcp.git
cd bq-readonly-mcp
uv run bq-readonly-mcp --project your-project-id --location USFor a full walkthrough (five steps from zero), see docs/QUICKSTART.md.
π Authentication
The server uses Application Default Credentials (ADC). Run this once:
gcloud auth application-default loginFor non-interactive environments (CI, containers, service accounts), pass a key file:
bq-readonly-mcp --project your-project-id --key-file /path/to/service-account.jsonOr set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json.
π Plug it into your editor
Full walkthroughs for each client β config file paths, JSON snippets, restart steps β are in docs/EDITOR_SETUP.md.
Covered clients: Claude Code, Claude Desktop, Cursor, Windsurf, GitHub Copilot (VS Code), Cline, Continue.dev, Zed, Gemini CLI.
Claude Code β quick example:
claude mcp add --transport stdio bq-readonly -- \
uvx bq-readonly-mcp --project your-project-id --location USOr add to ~/.claude.json (global) or .mcp.json (project-level):
{
"mcpServers": {
"bq-readonly": {
"command": "uvx",
"args": [
"bq-readonly-mcp",
"--project", "your-project-id",
"--location", "US"
]
}
}
}Ready-to-paste configs for all supported clients are in mcp-config-examples/.
βοΈ Configuration reference
All flags can also be set via environment variables. CLI flags take precedence over env vars; env vars take precedence over defaults.
CLI flag | Env var | Default | Description |
|
| (required) | GCP project to query |
|
|
| BigQuery processing location |
|
| (none β all allowed) | Space-separated dataset allowlist; comma-separated in env var |
|
|
| Rows injected by auto-LIMIT |
|
|
| Hard cap on per-query LIMIT |
|
|
| Per-query bytes-billed cap |
|
|
| Rows returned by |
|
| (uses ADC) | Path to service-account JSON |
π‘οΈ Safety model
SELECT/WITH only β The SQL validator strips comments, then rejects any statement that doesn't start with
SELECTorWITH, or that contains DML/DDL keywords (INSERT,UPDATE,DELETE,DROP,CREATE,MERGE, β¦).Auto-LIMIT β
LIMIT Nis injected if absent. The caller can raise it up to--max-limit(default 10,000).Dry-run cost guard β Every
run_querycall first runs a dry-run to estimate cost. Queries exceeding--max-bytes-billedare refused before any bytes are billed.Dataset allowlist β Optional
--datasetsflag restricts access to named datasets. A startup warning is logged when unset.Defense in depth β
maximumBytesBilledis also set on the real job as a server-side backstop.
Full details and threat model β SECURITY.md
π« What it does NOT do
Write operations of any kind (INSERT, UPDATE, DELETE, DDL) β by design, forever
Vector / embedding search β deferred to a future release
Multi-project queries β one server, one GCP project
Job history / audit log access β privacy footgun, intentionally omitted
Storage API (export, streaming reads)
These are intentional omissions. v0.1 focuses on safe, read-only schema exploration and SQL queries.
π€ vs other BigQuery MCPs
Feature | bq-readonly-mcp | pvoo/bigquery-mcp ecosystem |
Read-only enforced | β validator + zero write tools | Varies by fork |
Dry-run cost guard | β refuses over-budget queries | Not standard |
Auto-LIMIT injection | β default 50, cap 10,000 | Not standard |
Dataset allowlist | β
optional | Not standard |
ADC auth | β | β |
Vector / embedding search | No (v0.1) | Some forks |
PyPI package | β
| Varies |
π» Development
# Install with dev deps
uv sync --extra dev
# Run unit tests (fast, no BigQuery required)
uv run pytest tests/unit/ -q
# Run integration tests (requires ADC + BigQuery access)
uv run pytest -m integration -q
# Lint
uv run ruff check src tests
# Type check
uv run mypy srcπ License
MIT β see LICENSE
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/mariadb-RupeshBiswas/bq-readonly-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server