Databricks MCP server

Integrates with Databricks to execute SQL queries, list schemas, and describe table structures using the Statement Execution API for data exploration and analysis tasks
Back to servers
Setup instructions
Provider
Rafael Cartenet
Release date
Mar 10, 2025
Language
Python
Stats
15 stars

The Databricks MCP Server provides a powerful interface for Large Language Models (LLMs) to interact with Databricks Unity Catalog metadata and execute SQL queries. This server helps AI agents autonomously explore data assets, understand data structures, analyze lineage, and run queries without human intervention at each step.

Installation and Setup

System Requirements

Installation Steps

  1. Install the required dependencies:
pip install -r requirements.txt

Or with uv:

uv pip install -r requirements.txt
  1. Configure your environment variables using one of these methods:

Option 1: Using a .env file (recommended)

Create a .env file in the project root:

DATABRICKS_HOST="your-databricks-instance.cloud.databricks.com"
DATABRICKS_TOKEN="your-databricks-personal-access-token"
DATABRICKS_SQL_WAREHOUSE_ID="your-sql-warehouse-id"

Option 2: Setting environment variables directly

export DATABRICKS_HOST="your-databricks-instance.cloud.databricks.com"
export DATABRICKS_TOKEN="your-databricks-personal-access-token"
export DATABRICKS_SQL_WAREHOUSE_ID="your-sql-warehouse-id"

Note: You can find your SQL Warehouse ID in the Databricks UI under "SQL Warehouses". The warehouse ID is primarily needed for lineage fetching and SQL query execution.

Required Permissions

Ensure the identity associated with your DATABRICKS_TOKEN has:

  • Unity Catalog Permissions:

    • USE CATALOG on catalogs to be accessed
    • USE SCHEMA on schemas to be accessed
    • SELECT on tables to be queried or described
  • SQL Warehouse Permissions:

    • CAN_USE permission on the SQL Warehouse
  • Token Permissions:

    • Appropriate scopes for workspace access and SQL operations
    • Consider using a service principal with minimal permissions for production

Running the Server

Standalone Mode

Run the server for testing or with Agent Composer:

python main.py

Using with Cursor

To use with Cursor:

  1. Create a .cursor directory and mcp.json file:
mkdir -p ~/.cursor
touch ~/.cursor/mcp.json
  1. Add this configuration to mcp.json:
{
    "mcpServers": {
        "databricks": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/your/mcp-databricks-server",
                "run",
                "main.py"
            ]
        }
    }
}

Alternative configuration using python:

{
    "mcpServers": {
        "databricks": {
            "command": "python",
            "args": [
                "/path/to/your/mcp-databricks-server/main.py"
            ]
        }
    }
}
  1. Restart Cursor to apply changes

Available Tools

Unity Catalog Exploration

  1. List Catalogs:

    list_uc_catalogs() -> str
    

    Lists all available Unity Catalogs with names, descriptions, and types.

  2. Describe Catalog:

    describe_uc_catalog(catalog_name: str) -> str
    

    Provides a summary of a specific catalog, listing all its schemas.

  3. Describe Schema:

    describe_uc_schema(catalog_name: str, schema_name: str, include_columns: Optional[bool] = False) -> str
    

    Returns detailed information about a schema, optionally including column details.

  4. Describe Table:

    describe_uc_table(full_table_name: str, include_lineage: Optional[bool] = False) -> str
    

    Provides detailed information about a table, including structure and optionally comprehensive lineage information.

Query Execution

execute_sql_query(sql: str) -> str

Executes SQL queries using the Databricks SDK and returns formatted results.

Example Usage Workflow

A typical LLM agent workflow might follow this pattern:

  1. Discover available catalogs: list_uc_catalogs()
  2. Explore specific catalog: describe_uc_catalog(catalog_name="prod_catalog")
  3. Explore specific schema: describe_uc_schema(catalog_name="prod_catalog", schema_name="sales_schema")
  4. Get detailed table structure: describe_uc_table(full_table_name="prod_catalog.sales_schema.orders")
  5. Analyze data lineage: describe_uc_table(full_table_name="prod_catalog.sales_schema.orders", include_lineage=True)
  6. Execute a query: execute_sql_query(sql="SELECT * FROM prod_catalog.sales_schema.orders LIMIT 10")

Handling Long-Running Queries

The execute_sql_query tool has a wait_timeout parameter set to '50s'. For very long-running queries, this timeout might be reached, potentially resulting in incomplete results.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "databricks" '{"command":"python","args":["/path/to/your/mcp-databricks-server/main.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "databricks": {
            "command": "python",
            "args": [
                "/path/to/your/mcp-databricks-server/main.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "databricks": {
            "command": "python",
            "args": [
                "/path/to/your/mcp-databricks-server/main.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later