Skip to main content

Python-based MCP (Model Context Protocol) server that retrieves dataset, table, and schema information from Google Cloud BigQuery

Project description

BigQuery MCP Server

Python Version Framework

This is a Python-based MCP (Model Context Protocol) server that retrieves dataset, table, and schema information from Google Cloud BigQuery, caches it locally, and serves it via MCP. Its primary purpose is to enable generative AI systems to quickly understand BigQuery's structure and execute queries securely.

Key Features

  • Metadata Management: Retrieves and caches information about BigQuery datasets, tables, and columns
  • Keyword Search: Supports keyword search of cached metadata
  • Secure Query Execution: Provides SQL execution capabilities with automatic LIMIT clause insertion and cost control
  • MCP Compliance: Offers tools via the Model Context Protocol

MCP Server Tools

Available tools:

  1. get_datasets - Retrieves a list of all datasets
  2. get_tables - Retrieves all tables within a specified dataset (requires dataset_id, optionally accepts project_id)
  3. search_metadata - Searches metadata for datasets, tables, and columns
  4. execute_query - Safely executes BigQuery SQL queries with automatic LIMIT clause insertion and cost control
  5. check_query_scan_amount - Retrieves the scan amount for BigQuery SQL queries

Installation and Environment Setup

Prerequisites

  • Python 3.11 or later
  • Google Cloud Platform account
  • GCP project with BigQuery API enabled

Install

uv

uv add bq_mcp_server

pip

pip install bq_mcp_server

Installing Dependencies

This project uses uv for package management:

# Install uv if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv sync

Configuring Option

For a list of configuration values, see:

docs/settings.md

MCP Setting

{
    "mcpServers": {
        "bq_mcp_server": {
            "command": "uv",
            "args": [
                "run",
                "--directory",
                "<your install directory>",
                "bq_mcp_server"
            ],
            "env": {
                "PYTHONPATH": "<your install directory>",
                "PROJECT_IDS": "<your project id>"
            }
        }
    }
}

Running Tests

Running All Tests

pytest

Running Specific Test Files

pytest tests/test_logic.py

Running Specific Test Functions

pytest -k test_function_name

Checking Test Coverage

pytest --cov=bq_mcp_server

Local Development

Starting the MCP Server

uv run bq_mcp_server

Starting the FastAPI REST API Server

uvicorn bq_mcp_server.adapters.web:app --reload

Development Commands

Code Formatting and Linting

# Code formatting
ruff format

# Linting checks
ruff check

# Automatic fixes
ruff check --fix

Dependency Management

# Adding new dependencies
uv add <package>

# Adding development dependencies
uv add --dev <package>

# Updating dependencies
uv sync

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bq_mcp_server-0.1.3.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bq_mcp_server-0.1.3-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file bq_mcp_server-0.1.3.tar.gz.

File metadata

  • Download URL: bq_mcp_server-0.1.3.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for bq_mcp_server-0.1.3.tar.gz
Algorithm Hash digest
SHA256 637529770f75506551afc4ba99c4d9a32fc16e714392d796bad56c344a5c08f4
MD5 b078c6a1633b3af2bbf2eb6da1af71b6
BLAKE2b-256 ae5275262bd8a647843eaf051046b79ff09a20c8e144491f2e1fd7e35f6cbbe2

See more details on using hashes here.

File details

Details for the file bq_mcp_server-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bq_mcp_server-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2fb4a4889715267dc94b39ed4a4f49ef93279d9b0bbbea9207005f918d114305
MD5 a2c52b4cef1b75d4e25a76003b83c7ad
BLAKE2b-256 a9e596ddd746bb59cfbb38ac54ff65419c7cd3f2db29f890b3741391b7011261

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page