bricks-use

bricks-use

MCP server for executing Databricks SQL queries and comparing table data, supporting CLI and VS Code integration.

Category
访问服务器

README

<div align="center">

<img src="https://raw.githubusercontent.com/aymenfurter/bricks-use/refs/heads/main/bricks-use.png" alt="Project Logo" width="820" />

CI/CD Pipeline Python 3.11+ License: MIT Code style: black Type Checked: mypy Databricks

A powerful Model Context Protocol (MCP) server for executing Databricks SQL queries and comparing table data.

⚠️ This project is purely meant for demo purposes - use at your own risk!

</div>


Table of Contents

Features

Feature Description
Execute SQL Queries Run any SQL query on Databricks with configurable result limits
Table Information Get detailed information about tables including schema and row counts
Table Comparison Compare two tables by downloading their data and running CLI diff
Quick Comparison Fast metadata-only comparison of tables

Quick Start

# 1. Clone and setup
git clone https://github.com/aymenfurter/bricks-use.git
cd bricks-use
python -m venv .venv && source .venv/bin/activate

# 2. Install dependencies
pip install -r requirements.txt

# 3. Configure environment (see setup section)
cp .env.example .env  # Edit with your credentials

# 4. Run the server or use CLI
python databricks_server.py  # For MCP server
# OR
./bricks query "SELECT * FROM my_table LIMIT 10"  # For CLI

Setup

Prerequisites

<table> <tr> <td><strong>Python</strong></td> <td>3.11 or higher</td> </tr> <tr> <td><strong>Databricks</strong></td> <td>Workspace access</td> </tr> <tr> <td><strong>Token</strong></td> <td>Personal access token</td> </tr> </table>

Environment Variables

Set the following environment variables or create a .env file:

# Databricks Configuration
DATABRICKS_SERVER_HOSTNAME=your-workspace.cloud.databricks.com
DATABRICKS_HTTP_PATH=/sql/1.0/warehouses/your-warehouse-id
DATABRICKS_ACCESS_TOKEN=your-personal-access-token

# Optional Settings
DATABRICKS_CATALOG=main                    # Defaults to 'main'
DATABRICKS_SCHEMA=default                  # Defaults to 'default'
DATABRICKS_TEMP_DIR=/tmp/databricks_mcp    # Temp directory

Installation

  1. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    

CLI Usage

Use the ./bricks command-line tool for direct interaction:

# Execute SQL queries
./bricks query "SELECT * FROM my_table LIMIT 10"
./bricks query "SELECT COUNT(*) FROM users WHERE active = true" --limit 50

# Get table information
./bricks info my_table
./bricks info users --catalog production --schema analytics

# Compare tables
./bricks compare table1 table2
./bricks compare old_users new_users --quick
./bricks compare sales_2023 sales_2024 --catalog1 prod --schema1 sales

# Output options
./bricks query "SELECT * FROM table" --format json
./bricks info my_table --format table

MCP Tools

<div align="center">

Tool Purpose Key Parameters
execute_query Execute SQL queries query, limit
get_table_info Get table metadata table_name, catalog, schema
compare_tables Full data comparison table1, table2, diff_lines
quick_compare_tables Metadata comparison table1, table2

</div>


execute_query

Execute a SQL query on Databricks.

Parameters:

  • query (str): SQL query to execute
  • limit (int, optional): Maximum rows to return (default: 1000)

get_table_info

Get information about a Databricks table.

Parameters:

  • table_name (str): Name of the table
  • catalog (str, optional): Catalog name
  • schema (str, optional): Schema name

compare_tables

Compare data between two tables by downloading full data and running diff.

Parameters:

  • table1 (str): First table name
  • table2 (str): Second table name
  • catalog1 (str, optional): Catalog for table1
  • schema1 (str, optional): Schema for table1
  • catalog2 (str, optional): Catalog for table2
  • schema2 (str, optional): Schema for table2
  • diff_lines (int, optional): Number of diff context lines (default: 10)

quick_compare_tables

Quick metadata-only comparison without downloading data.

Parameters:

  • table1 (str): First table name
  • table2 (str): Second table name
  • catalog1 (str, optional): Catalog for table1
  • schema1 (str, optional): Schema for table1
  • catalog2 (str, optional): Catalog for table2
  • schema2 (str, optional): Schema for table2

VS Code MCP Integration

Add this configuration to your VS Code settings (mcp.json):

<details> <summary><strong>Click to expand VS Code configuration</strong></summary>

{
    "inputs": [
        {
            "type": "promptString",
            "id": "databricks_server_hostname",
            "description": "Databricks Server Hostname"
        },
        {
            "type": "promptString",
            "id": "databricks_http_path",
            "description": "Databricks HTTP Path"
        },
        {
            "type": "promptString",
            "id": "databricks_access_token",
            "description": "Databricks Access Token",
            "password": true
        },
        {
            "type": "promptString",
            "id": "databricks_catalog",
            "description": "Databricks Catalog (default: main)"
        },
        {
            "type": "promptString",
            "id": "databricks_schema",
            "description": "Databricks Schema (default: default)"
        }
    ],
    "servers": {
        "databricks": {
            "command": "python",
            "args": [
                "${workspaceFolder}/databricks_server.py"
            ],
            "env": {
                "PYTHONUNBUFFERED": "1",
                "DATABRICKS_SERVER_HOSTNAME": "${input:databricks_server_hostname}",
                "DATABRICKS_HTTP_PATH": "${input:databricks_http_path}",
                "DATABRICKS_ACCESS_TOKEN": "${input:databricks_access_token}",
                "DATABRICKS_CATALOG": "${input:databricks_catalog}",
                "DATABRICKS_SCHEMA": "${input:databricks_schema}"
            },
            "workingDirectory": "${workspaceFolder}"
        }
    }
}

</details>


<div align="center">

License

This project is licensed under the MIT License.

Made with ❤️ for the Databricks community

</div>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选