mcp-bigquery-evals
A BigQuery MCP server with mandatory cost guardrails that dry-run every query before execution, and a measurable accuracy badge from an eval harness.
README
<div align="center">
mcp-bigquery-evals
The BigQuery MCP server with mandatory cost guardrails and a measurable accuracy number.
uvx mcp-bigquery-evals · works with any MCP-compatible client · v0.1.0
</div>
Why use this over the other BigQuery MCPs
| Most BQ MCPs | mcp-bigquery-evals |
|
|---|---|---|
| Cost guardrails | none | mandatory dry-run before every query, refuses if over cap |
| Quality signal | "trust me" | live accuracy badge, recomputed every release |
| Write operations | usually enabled | disabled by design (read-only) |
| Errors when things break | raw API exceptions | 7 stable error codes an agent can switch on |
| Local dev without GCP | impossible | in-memory sqlite-backed fake ships in the box |
What ships in the box
- 7 read-only MCP tools for warehouse discovery and querying
- Mandatory dry-run cost cap on every
run_query(default 100 MB scanned, about $0.0005 per query) - Result-set-equivalence eval harness (Spider/BIRD methodology) with a live accuracy badge in this README
- Structured BigQuery errors with 7 stable codes (
invalid_sql,table_not_found,permission_denied,unauthenticated,rate_limited,query_timeout,unknown) - Two BigQueryClient implementations:
RealBigQueryClient(production, wrapsgoogle-cloud-bigquery) andFakeBigQueryClient(in-memory, sqlite-backed, for dev and CI without GCP credentials)
Quickstart (5 minutes)
1. Install
uvx mcp-bigquery-evals --help
First run takes about 30s while uv fetches dependencies; subsequent runs are instant from the local cache. Plain pip install mcp-bigquery-evals also works.
2. Authenticate to GCP
gcloud auth application-default login
3. Wire into your MCP client
Open your MCP client's server config (developer settings) and add:
{
"mcpServers": {
"bigquery": {
"command": "uvx",
"args": ["mcp-bigquery-evals", "serve"],
"env": {
"BIGQUERY_PROJECT": "YOUR_GCP_PROJECT_ID_HERE"
}
}
}
}
Restart your client. The MCP indicator should show "bigquery" with 7 tools.
4. Try it
Using the bigquery tool, find the top 5 most-viewed Stack Overflow questions tagged 'python'.
The agent chains list_datasets, list_tables, describe_table, run_query to answer. Every run_query is dry-run-cost-capped before execution.
Detailed setup, troubleshooting, and the alternative pip install path live in docs/mcp_client_setup.md.
The 7 tools
| Tool | Purpose |
|---|---|
list_datasets() |
List all datasets in your GCP project |
list_tables(dataset_id) |
List tables in a dataset |
describe_table(table_id) |
Schema, row count, size |
sample_table(table_id, n=5) |
Up to n sample rows |
search_schema(term) |
Fuzzy-match a term against all column names |
estimate_cost(sql) |
Free dry-run; returns bytes_scanned and estimated USD |
run_query(sql, max_bytes_scanned=100MB) |
Dry-run, refuse if over cap, then execute |
All tools are read-only. There are no write operations in v1 by design. See docs/architecture.md for the design rationale.
Cost guardrails
Every run_query call dry-runs first (free) before execution. If the dry-run estimate exceeds max_bytes_scanned, the call returns a structured error rather than burning bytes:
{
"error": "cost_cap_exceeded",
"would_scan": "1.4 GB",
"cap": "100.0 MB",
"estimated_usd": 0.007,
"hint": "narrow your WHERE clause or pass max_bytes_scanned=1500000000 to override"
}
The agent reads the structured error and self-corrects (narrows the WHERE clause, raises the cap explicitly, picks a different table).
Eval harness
Every release runs a result-set-equivalence eval suite against bigquery-public-data and updates the accuracy badge above. The methodology matches Spider and BIRD academic benchmarks: execute both gold and predicted SQL, compare result sets as multisets of rows (order-independent, with float tolerance, Decimal handling, NULL equality, NaN equality, ARRAY/STRUCT recursion, bool/int distinction).
Run locally:
mcp-bigquery-evals evals run --model <your-model-id>
Full methodology, golden-pairs YAML format, and how to add your own pairs: docs/how_evals_work.md.
Development
git clone https://github.com/Umarfarook1/mcp-bigquery-evals
cd mcp-bigquery-evals
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest # unit tests (no GCP needed; ~160 tests)
pytest -m bq # real-BQ integration tests (needs GCP creds)
pytest -m live # end-to-end with real model + real BQ
Contributing
Issues and PRs welcome. Highest-leverage contributions:
- More verified golden NL-to-SQL pairs against
bigquery-public-data - Prompt improvements with before/after eval numbers showing the accuracy badge moved
- Bug reports with minimum reproductions
License
MIT, see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。