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
Provider
Rafael Cartenet
Release date
Mar 10, 2025
Language
Python
Stats
6 stars

The Databricks MCP Server provides a seamless interface to execute SQL queries against Databricks using the Statement Execution API. It enables data retrieval through SQL requests and performs exceptionally well in Agent mode for complex tasks, especially when integrated with Unity Catalog Metadata.

Installation

Prerequisites

Installing Dependencies

Install the required dependencies using pip:

pip install -r requirements.txt

Or if you prefer using uv:

uv pip install -r requirements.txt

Environment Configuration

Set up your Databricks credentials using one of these methods:

Option 1: Using a .env file (recommended)

Create a .env file with the following content:

DATABRICKS_HOST=your-databricks-instance.cloud.databricks.com
DATABRICKS_TOKEN=your-databricks-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-access-token"
export DATABRICKS_SQL_WAREHOUSE_ID="your-sql-warehouse-id"

You can find your SQL warehouse ID in the Databricks UI under SQL Warehouses.

Required Permissions

Ensure the following permissions are properly configured:

  • SQL Warehouse Permissions: The token's user must have access to the specified SQL warehouse
  • Token Permissions: Use a dedicated token with minimal necessary permissions (read-only when possible)
  • Data Access Permissions: The token's user must have permission to access the catalogs, schemas, and tables being queried

Running the Server

Standalone Mode

Start the MCP server in standalone mode:

python main.py

This launches the server using stdio transport, compatible with Agent Composer and other MCP clients.

Integration with Cursor

To use this server with Cursor:

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

For Python without uv:

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

Available Tools

SQL Operations

The server provides four main tools:

  1. Execute SQL Query

    execute_sql_query(sql: str) -> str
    
  2. List Schemas

    list_schemas(catalog: str) -> str
    
  3. List Tables

    list_tables(schema: str) -> str
    
  4. Describe Table

    describe_table(table_name: str) -> str
    

Usage Examples

Here are examples of how to use the tools in Agent Composer or other MCP clients:

execute_sql_query("SELECT * FROM my_schema.my_table LIMIT 10")
list_schemas("my_catalog")
list_tables("my_catalog.my_schema")
describe_table("my_catalog.my_schema.my_table")

Long-Running Queries

The server handles long-running queries by polling the Databricks API until completion or timeout. The default timeout is 10 minutes (60 retries with 10-second intervals), which can be adjusted in the dbapi.py file if needed.

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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