Skip to main content
Glama
README.md
# ๐Ÿ”Ž bq-mcp

**A read-only MCP server for BigQuery โ€” schema, cost, and catalog tools for any AI assistant.**

[![CI](https://img.shields.io/github/actions/workflow/status/ARAVINDHRAJA123/bq-mcp/ci.yml?style=for-the-badge&logo=githubactions&logoColor=white&label=CI)](https://github.com/ARAVINDHRAJA123/bq-mcp/actions)
[![Read-only](https://img.shields.io/badge/Access-Read--only-10b981?style=for-the-badge&logo=googlecloud&logoColor=white)](#safety)
[![MCP](https://img.shields.io/badge/Protocol-MCP-4285F4?style=for-the-badge&logo=anthropic&logoColor=white)](https://modelcontextprotocol.io)

`pip install`, add one config line, and Claude Code / Claude Desktop / Cursor can browse your
BigQuery schemas, estimate query cost, and list datasets/tables โ€” natively, without you
pasting DDL into chat.

## Why

I built the pieces of this three times over โ€” once embedded in
[sql-review-agent](https://github.com/ARAVINDHRAJA123/sql-review-agent), once in
[Bank-Statement-Analyser](https://github.com/ARAVINDHRAJA123/Bank-Statement-Analyser).
Each time it was locked to that one project. This pulls the tools out into a standalone
package anyone can point at their own warehouse.

## Tools

| Tool | What it does |
|---|---|
| `dry_run(sql)` | Estimate bytes scanned + cost **without executing** the query |
| `get_table_metadata(dataset, table)` | Schema, partition key, clustering, row count, size |
| `list_tables(dataset)` | All tables in a dataset |
| `list_datasets()` | All datasets in the project |

## Safety

- **`dry_run` never executes** โ€” BigQuery's dry-run mode only plans the query
- Only `SELECT`/`WITH` statements are accepted; `INSERT`/`UPDATE`/`DELETE`/`DROP`/etc. are rejected before they ever reach BigQuery
- **Cost guardrail:** if a dry-run estimates above `BQ_MCP_MAX_COST_USD` (default $5), the response includes an explicit warning instead of silently reporting a huge number
- Metadata/listing tools only call BigQuery's catalog APIs โ€” they cannot read table *rows*, only structure

## Install

```bash
git clone https://github.com/ARAVINDHRAJA123/bq-mcp.git
cd bq-mcp
python3 -m venv venv && ./venv/bin/pip install -e .
export GCP_PROJECT=your-project   # uses Application Default Credentials
```

Add to your MCP client config (e.g. `claude_desktop_config.json` or Claude Code's `.mcp.json`):

```json
{
  "mcpServers": {
    "bigquery": {
      "command": "/path/to/bq-mcp/venv/bin/bq-mcp",
      "env": { "GCP_PROJECT": "your-project", "BQ_LOCATION": "US" }
    }
  }
}
```

## Stack

`Python` ยท `google-cloud-bigquery` ยท `mcp` (FastMCP)

---

Built by [Aravindhraja R](https://github.com/ARAVINDHRAJA123) ยท part of a small
BigQuery/AI toolset alongside [QueryDoctor](https://querydoctor-616665622891.asia-south1.run.app)
and [BigQuery Cost Sentinel](https://github.com/ARAVINDHRAJA123/bq-cost-sentinel).
---

## Multi-IDE MCP Setup (`AGENTS.md`, `SKILL.md` & Read-Only Annotations)

Every tool is annotated with MCP `ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True)` so MCP clients recognize them as safe read-only operations.

- **Universal instructions & skill:** `AGENTS.md` + `.github/skills/bq-mcp/SKILL.md` (`agentskills.io`-compliant).
- **VS Code Copilot (`.vscode/mcp.json`), Claude Code (`.mcp.json`), or Cursor (`.cursor/mcp.json`):**
  ```json
  {
    "mcpServers": {
      "bq-mcp": {
        "command": "bq-mcp",
        "env": {
          "GCP_PROJECT": "your-project",
          "BQ_LOCATION": "US",
          "BQ_MCP_MAX_COST_USD": "5.0"
        }
      }
    }
  }
  ```

## License

[MIT](LICENSE)