GCP BigQuery MCP Server
GCP BigQuery MCP 服务器
用于 Google Cloud Platform BigQuery 的企业级 MCP (Model Context Protocol) 服务器,采用 工作负载身份联合 (Workload Identity Federation) 认证。通过模型上下文协议提供对 BigQuery 的安全、无密钥访问。
主要功能
零服务账号密钥 - 100% 工作负载身份联合
Google Workspace 集成 - OIDC 用户认证
符合 MCP 协议 - 遵循官方 MCP SDK 最佳实践
多租户 - YAML 允许列表 + BigQuery 数据集上的 IAM 条件
安全中间件 - 速率限制、提示注入检测、数据脱敏
Model Armor 预检 - 工具执行前的可选内容安全筛选
私有服务连接 (PSC) - 面向企业消费者的可选私有入口
客户管理加密 (CMEK) - BigQuery 数据集的 CMEK 加密
全面的审计日志 - 7 年保留期以满足合规性要求
Terraform 基础设施 - 用于可重复部署的完整 IaC
Cloud Run 部署 - 无服务器、自动扩缩容架构
OpenTelemetry - 分布式追踪和按租户指标
Related MCP server: bq_mcp_server
项目结构
db-mcp/
├── src/ # TypeScript source code
│ ├── auth/ # WIF authentication modules
│ ├── bigquery/ # BigQuery client, discovery, optimization
│ ├── mcp/ # MCP protocol handlers and tools
│ ├── security/ # Security middleware
│ ├── monitoring/ # Health checks and monitoring
│ ├── telemetry/ # OpenTelemetry instrumentation
│ ├── config/ # Configuration management
│ └── utils/ # Logging utilities
├── tests/ # Unit, integration, and performance tests
├── terraform/ # Infrastructure as Code
│ └── modules/ # Reusable Terraform modules
├── docs/ # Comprehensive documentation
├── scripts/ # Deployment and utility scripts
├── examples/ # Usage examples
├── .github/workflows/ # CI/CD automation
└── Dockerfile # Production container image安全架构
传统方法(已弃用)
存储在文件/密钥中的服务账号密钥
永不过期的永久凭据
需要手动轮换密钥
凭据泄露风险高
工作负载身份联合(已实现)
系统中无任何密钥
1 小时令牌有效期,自动轮换
基于属性的访问控制,实现细粒度权限管理
完整的审计追踪,记录所有访问行为
攻击面减少 90%
快速入门
前置条件
已启用计费的 GCP 项目
Terraform >= 1.5.0
Node.js >= 22.0.0
Docker (用于容器化)
安装
# Clone and install dependencies
npm install
# Copy environment configuration
cp .env.example .env
# Build the project
npm run build本地开发
# Development mode with hot reload
npm run dev
# Run tests
npm test
# Type checking
npm run typecheck生产部署
# Build Docker image
docker build -t mcp-bigquery-server .
# Deploy infrastructure with Terraform
cd terraform
terraform init
terraform apply
# Deploy to Cloud Run
gcloud run deploy mcp-bigquery-server \
--image gcr.io/YOUR_PROJECT/mcp-bigquery-server \
--region us-central1MCP 工具
该服务器提供以下 MCP 工具:
工具 | 描述 |
| 在 BigQuery 数据集上执行 SQL 查询 |
| 列出所有可用的 BigQuery 数据集 |
| 列出特定数据集中的表 |
| 获取表的模式信息 |
服务器能力:
资源:BigQuery 数据集列表
工具:查询执行和模式检查
Stderr 日志记录:所有日志输出到 stderr (兼容 JSON-RPC)
优雅关闭:支持 SIGTERM/SIGINT 处理
架构
Client Request
↓
MCP Protocol Layer (JSON-RPC)
↓
Security Middleware (rate limiting, injection detection)
↓
Workload Identity Federation
↓ (OIDC Token)
Identity Pool
↓ (Attribute Mapping)
Service Account Impersonation
↓ (1-hour access token)
BigQuery API核心组件
工作负载身份联合 - 带有 OIDC 提供商的开发/测试/生产身份池
安全中间件 - 速率限制、提示注入检测、SQL 注入防护
BigQuery 集成 - 连接池、查询优化、数据集发现
监控 - 健康检查、OpenTelemetry 追踪、Cloud Monitoring 集成
文档
文档 | 描述 |
本地开发、测试和生产的完整指南 | |
系统设计和组件文档 | |
安全中间件和最佳实践 | |
工作负载身份联合详细信息 | |
完整生产部署指南 | |
容器配置 | |
可观测性设置 | |
完整文档地图 |
测试
# Run all tests
npm test
# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:performance
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watch开发命令
npm run build # Build TypeScript
npm run dev # Development with hot reload
npm run start # Start production server
npm run lint # Run ESLint
npm run lint:fix # Fix linting issues
npm run format # Format with Prettier
npm run typecheck # TypeScript type checkingCI/CD
GitHub Actions 工作流自动执行:
在拉取请求上运行测试
构建并推送 Docker 镜像
在主分支上部署到 Cloud Run
使用工作负载身份联合(无密钥)
监控
Cloud Monitoring: 预配置仪表板,在
mcp.tool.calls.total和mcp.tool.call.duration上具有tenant_id维度Cloud Logging: 结构化 JSON 日志
Cloud Trace: 通过 OpenTelemetry 进行分布式追踪,带有
tenant.id跨度属性审计日志: 在 BigQuery 中保留 7 年
警报: 电子邮件/Slack 通知
合规性
GDPR: 数据驻留和访问日志记录
HIPAA: 访问控制和审计追踪
SOC 2: 身份管理和监控
PCI-DSS: 认证和授权
贡献
欢迎贡献!请参阅 CONTRIBUTING.md 获取指南。
许可证
MIT 许可证 - 详情请参阅 LICENSE
致谢
基于 MCP SDK 构建
由 Google Cloud BigQuery 提供支持
基础设施由 Terraform 提供
状态: 生产就绪 版本: 1.0.0 最后更新: 2026 年 4 月
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
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 Connectors
The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Cloud-hosted MCP server for secure AI access to enterprise data sources via CData Connect AI.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA 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
- AlicenseAqualityCmaintenanceA Python MCP server that retrieves and caches BigQuery metadata (datasets, tables, columns) and enables secure SQL query execution with cost control, file export, and keyword search.6MIT
- AlicenseNot gradedqualityDmaintenanceProduction-ready MCP server for BigQuery that translates natural language questions to SQL, executes queries securely, and delivers results via stdio or HTTP for integration with GitHub Copilot, Power BI, and web applications.237MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for secure BigQuery access across multiple Google Cloud projects, enabling querying, schema exploration, and data analysis with SQL validation and read-only controls.2MIT
Appeared in Searches
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/erayguner/db-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server