Databricks MCP Server
Provides access to Databricks functionality including cluster management, job management, notebook operations, file system operations (DBFS and Unity Catalog volumes), and SQL execution capabilities.
Supports notebook operations with Jupyter, allowing export of Databricks notebooks in Jupyter format as well as other formats.
Enables interaction with Python notebooks in Databricks, supporting operations like creating and exporting notebooks with Python content.
Integrates with Unity Catalog, providing tools for volume operations such as uploading files to Unity Catalog volumes and listing files in volumes with detailed metadata.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Databricks MCP Server list all running clusters and show their status"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Databricks MCP Server - Working Version
A fixed version of the Databricks MCP Server that properly works with Claude Code and other MCP clients.
π§ What Was Fixed
This is a working fork of the original Databricks MCP server that fixes critical issues preventing it from working with Claude Code and other MCP clients.
Original Repository: https://github.com/JustTryAI/databricks-mcp-server
The Problems
Asyncio event loop conflict: Original server used
asyncio.run()inside MCP tool functions, causingasyncio.run() cannot be called from a running event looperrors when used with Claude Code (which already runs in an async context)Command spawning issues: Claude Code's MCP client can only spawn single executables, not commands with arguments like
databricks-mcp startSQL API issues: Byte limit too high (100MB vs 25MB max), no API endpoint fallback for different Databricks workspace configurations
The Solutions
Fixed async patterns: Created
simple_databricks_mcp_server.pythat follows the working iPython MCP pattern - changed all tools to useasync defwithawaitinstead ofasyncio.run()Simplified CLI: Modified the CLI to default to starting the server when no command is provided, eliminating the need for wrapper scripts
SQL API improvements:
Reduced byte_limit from 100MB to 25MB (Databricks maximum allowed)
Added API endpoint fallback: tries
/statementsfirst, then/statements/executeBetter error logging when SQL APIs fail
Related MCP server: Databricks MCP Server
π Quick Start for Claude Code Users
Install directly from GitHub:
uv tool install git+https://github.com/samhavens/databricks-mcp-server.gitOr clone and install locally:
git clone https://github.com/samhavens/databricks-mcp-server.git
cd databricks-mcp-server
uv tool install --editable .Configure credentials:
cp .env.example .env
# Edit .env with your Databricks host and tokenAdd to Claude Code:
claude mcp add databricks "databricks-mcp"Test it works:
> list all databricks clustersWhy no arguments needed?
The CLI now defaults to starting the server when no command is provided, making it compatible with Claude Code's MCP client (which can only spawn single executables without arguments).
About This MCP Server
A Model Completion Protocol (MCP) server for Databricks that provides access to Databricks functionality via the MCP protocol. This allows LLM-powered tools to interact with Databricks clusters, jobs, notebooks, and more.
Features
MCP Protocol Support: Implements the MCP protocol to allow LLMs to interact with Databricks
Databricks API Integration: Provides access to Databricks REST API functionality
Tool Registration: Exposes Databricks functionality as MCP tools
Async Support: Built with asyncio for efficient operation
Available Tools
The Databricks MCP Server exposes 20 comprehensive tools across all major Databricks functionality areas:
Cluster Management (5 tools)
list_clusters: List all Databricks clusters with status and configuration details
create_cluster: Create a new Databricks cluster with specified configuration
terminate_cluster: Terminate a Databricks cluster
get_cluster: Get detailed information about a specific Databricks cluster
start_cluster: Start a terminated Databricks cluster
Job Management (4 tools)
list_jobs: List Databricks jobs with advanced pagination, creator filtering, and run status tracking
list_job_runs: List recent job runs with detailed execution status, duration, and result information
run_job: Execute a Databricks job with optional parameters
create_job: Create a new job to run a notebook (supports serverless compute by default)
Notebook Management (3 tools)
list_notebooks: List notebooks in a workspace directory with metadata
export_notebook: Export a notebook from the workspace in various formats (Jupyter, Python, etc.)
create_notebook: Create a new notebook in the workspace with specified content and language
File System (4 tools)
list_files: List files and directories in DBFS paths with size and modification details
upload_file_to_volume: Upload files to Unity Catalog volumes with progress tracking and large file support
upload_file_to_dbfs: Upload files to DBFS with chunked upload for large files
list_volume_files: List files and directories in Unity Catalog volumes with detailed metadata
SQL Execution (3 tools)
execute_sql: Execute SQL statement and wait for completion (blocking) - perfect for quick queries
execute_sql_nonblocking: Start SQL execution and return immediately with statement_id for long-running queries
get_sql_status: Monitor and retrieve results of non-blocking SQL executions by statement_id
Enhanced Features
Advanced Job Management
Pagination support:
list_jobsincludes pagination with configurable limits and offsetsCreator filtering: Filter jobs by creator email (case-insensitive)
Run status integration: Automatically includes latest run status and execution duration
Duration calculations: Real-time tracking of job execution times
Unity Catalog Integration
Volume operations: Full support for Unity Catalog volumes using Databricks SDK
Large file handling: Optimized upload with progress tracking for multi-GB files
Path validation: Automatic validation of volume paths and permissions
Non-blocking SQL Execution
Asynchronous execution: Start long-running SQL queries without blocking
Status monitoring: Real-time status tracking with detailed error reporting
Result retrieval: Fetch results when queries complete successfully
Key Features
Serverless Compute Support
The create_job tool supports serverless compute by default, eliminating the need for cluster management:
# Serverless execution (default - no cluster needed)
mcp__databricks__create_job(
job_name="My Data Pipeline",
notebook_path="/Users/your.email@company.com/MyNotebook",
timeout_seconds=3600,
parameters={"param1": "value1"}
)
# Or explicitly specify serverless
mcp__databricks__create_job(
job_name="My Pipeline",
notebook_path="/path/to/notebook",
use_serverless=True # Default
)
# Still supports cluster-based execution
mcp__databricks__create_job(
job_name="My Pipeline",
notebook_path="/path/to/notebook",
use_serverless=False,
cluster_id="your-cluster-id"
)Benefits of serverless:
No cluster creation permissions required
Auto-scaling compute resources
Cost-efficient - pay only for execution time
Faster job startup
Installation
Prerequisites
Python 3.10 or higher
uvpackage manager (recommended for MCP servers)
Setup
Install
uvif you don't have it already:# MacOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows (in PowerShell) irm https://astral.sh/uv/install.ps1 | iexRestart your terminal after installation.
Clone the repository:
git clone https://github.com/samhavens/databricks-mcp-server.git cd databricks-mcp-serverSet up the project with
uv:# Create and activate virtual environment uv venv # On Windows .\.venv\Scripts\activate # On Linux/Mac source .venv/bin/activate # Install dependencies in development mode uv pip install -e . # Install development dependencies uv pip install -e ".[dev]"Set up environment variables:
# Windows set DATABRICKS_HOST=https://your-databricks-instance.azuredatabricks.net set DATABRICKS_TOKEN=your-personal-access-token # Linux/Mac export DATABRICKS_HOST=https://your-databricks-instance.azuredatabricks.net export DATABRICKS_TOKEN=your-personal-access-tokenYou can also create an
.envfile based on the.env.exampletemplate.
Usage with Claude Code
The MCP server is automatically started by Claude Code when needed. No manual server startup is required.
After installation and configuration:
Start using Databricks tools in Claude Code:
> list all databricks clusters > create a job to run my notebook > execute SQL: SHOW CATALOGSCheck available tools:
databricks-mcp list-tools
Querying Databricks Resources
You can test the MCP server tools directly or use them through Claude Code once installed.
Project Structure
databricks-mcp-server/
βββ src/ # Source code
β βββ __init__.py # Makes src a package
β βββ __main__.py # Main entry point for the package
β βββ api/ # Databricks API clients
β β βββ clusters.py # Cluster management APIs
β β βββ dbfs.py # DBFS file system APIs
β β βββ jobs.py # Job management APIs
β β βββ notebooks.py # Notebook workspace APIs
β β βββ sql.py # SQL execution APIs
β βββ core/ # Core functionality
β β βββ config.py # Configuration management
β β βββ auth.py # Authentication
β β βββ utils.py # Utility functions
β βββ server/ # Server implementation
β β βββ simple_databricks_mcp_server.py # Main MCP server
β βββ cli/ # Command-line interface
β βββ commands.py # CLI commands
βββ tests/ # Test directory
β βββ test_clusters.py # Unit tests for API functions
β βββ test_direct.py # Integration tests
β βββ test_tools.py # MCP tool tests
β βββ test_validation.py # Import/schema validation tests
βββ pyproject.toml # Project configurationDevelopment
Linting
The project includes optional linting tools for code quality:
# Run linters (if installed in dev dependencies)
uv run pylint src/ tests/
uv run flake8 src/ tests/
uv run mypy src/Testing
The project uses pytest for testing with async support. Tests are automatically configured to run with pytest-asyncio.
# Run all tests
uv run pytest tests/ -v
# Run specific test files
uv run pytest tests/test_clusters.py -v
uv run pytest tests/test_direct.py -v
uv run pytest tests/test_tools.py -v
# Run with coverage report (if coverage is installed)
uv run pytest --cov=src tests/ --cov-report=term-missingTest Status: β 12 passed, 5 skipped (intentionally disabled)
Test Types:
Unit tests (
test_clusters.py): Test API functions with mocksIntegration tests (
test_direct.py,test_tools.py): Test MCP tools directly (requires Databricks credentials)Validation tests (
test_validation.py): Test import and schema validation
Note: Integration tests will show errors if Databricks credentials are not configured, but this is expected behavior.
Documentation
API documentation is generated using Sphinx and can be found in the
docs/apidirectoryAll code includes Google-style docstrings
See the
examples/directory for usage examples
Examples
Volume Upload Operations
Upload a local file to Unity Catalog volume:
# Upload dataset to Unity Catalog volume
mcp__databricks__upload_file_to_volume(
local_file_path='./data/large_dataset.json',
volume_path='/Volumes/catalog/schema/volume/large_dataset.json',
overwrite=True
)
# List files in the volume to verify
mcp__databricks__list_volume_files(
volume_path='/Volumes/catalog/schema/volume/'
)Upload to DBFS for temporary processing:
# Upload script to DBFS
mcp__databricks__upload_file_to_dbfs(
local_file_path='./scripts/analysis.py',
dbfs_path='/tmp/analysis.py',
overwrite=True
)Non-blocking SQL Execution
Start long-running query and monitor progress:
# Start a long-running query (non-blocking)
statement_result = mcp__databricks__execute_sql_nonblocking(
statement="SELECT COUNT(*) FROM large_table GROUP BY category",
warehouse_id="your-warehouse-id"
)
statement_id = statement_result['statement_id']
# Check status periodically
status = mcp__databricks__get_sql_status(statement_id=statement_id)
print(f"Status: {status['state']}") # PENDING, RUNNING, SUCCEEDED, FAILED
# When complete, retrieve results
if status['state'] == 'SUCCEEDED':
results = status['result']Advanced Job Management
List jobs with filtering and pagination:
# List jobs created by specific user with pagination
jobs = mcp__databricks__list_jobs(
limit=25,
offset=0,
created_by='user@company.com',
include_run_status=True # Include latest run info
)
# Get detailed run history for a specific job
runs = mcp__databricks__list_job_runs(
job_id=12345,
limit=10
)For more examples, check the examples/ directory:
# Run example scripts with uv
uv run examples/direct_usage.py
uv run examples/mcp_client_usage.pyContributing
Contributions are welcome! Please feel free to submit a Pull Request.
Ensure your code follows the project's coding standards
Add tests for any new functionality
Update documentation as necessary
Verify all tests pass before submitting
π Technical Details
The key fix was changing from:
@mcp.tool()
def list_clusters() -> str:
result = asyncio.run(clusters.list_clusters()) # β Breaks in async context
return json.dumps(result)To:
@mcp.tool()
async def list_clusters() -> str:
result = await clusters.list_clusters() # β
Works in async context
return json.dumps(result)This pattern was applied to all 20 MCP tools in the server.
ποΈ Implementation Architecture
SDK vs REST API Approach
The MCP server uses a hybrid implementation approach optimized for reliability and performance:
Databricks SDK (Preferred)
Used for: Volume operations, authentication, and core workspace interactions
Benefits: Automatic authentication, better error handling, type safety
Tools using SDK:
upload_file_to_volume,list_volume_files, authentication layerAuthentication: Automatically discovers credentials from environment, CLI config, or instance metadata
REST API (Legacy)
Used for: SQL execution, some job operations
Benefits: Direct control over API calls, established patterns
Tools using REST:
execute_sql,execute_sql_nonblocking,get_sql_statusAuthentication: Uses manual token-based authentication
Migration Status
β Volume operations: Migrated to SDK (fixes 404 errors from REST)
π In progress: Additional tools being evaluated for SDK migration
π Future: Plan to migrate remaining tools for consistency
Recommendation: New tools should use the Databricks SDK for better maintainability and error handling.
π Original Repository
Based on: https://github.com/JustTryAI/databricks-mcp-server
π Issues Fixed
β
asyncio.run() cannot be called from a running event loopβ
spawn databricks-mcp start ENOENT(command with arguments not supported)β MCP server connection failures with Claude Code
β Proper async/await patterns for MCP tools
β SQL execution byte limit issues (100MB β 25MB)
β SQL API endpoint compatibility across different Databricks workspaces
β Better error handling and logging for SQL operations
License
This project is licensed under the MIT License - see the LICENSE file for details.
Available Tools
19 toolscreate_clusterC
Create a new Databricks cluster
Inputs: cluster_name (required), spark_version (required), node_type_id (required), num_workers.
create_jobB
Create a new Databricks job to run a notebook (uses serverless by default)
Inputs: job_name (required), notebook_path (required), timeout_seconds, parameters, +2 more.
create_notebookC
Create a new notebook in the Databricks workspace
Inputs: path (required), content (required), language, overwrite.
execute_sqlB
Execute a SQL statement and wait for completion (blocking)
Inputs: statement (required), warehouse_id (required), catalog, schema_name.
execute_sql_nonblockingB
Start SQL statement execution and return immediately with statement_id (non-blocking)
Inputs: statement (required), warehouse_id (required), catalog, schema_name.
export_notebookC
Export a notebook from the workspace
Inputs: path (required), format.
get_clusterC
Get information about a specific Databricks cluster
Inputs: cluster_id (required).
get_sql_statusC
Get the status and results of a SQL statement by statement_id
Inputs: statement_id (required).
list_clustersB
List all Databricks clusters
Inputs: no named parameters.
list_filesC
List files and directories in DBFS
Inputs: dbfs_path.
list_job_runsA
List recent job runs with detailed status and duration information.
Args:
job_id: Specific job ID to list runs for (optional, omit to see runs across all jobs)
limit: Number of runs to return (default: 10, most recent first)
Returns:
JSON with runs array. Each run includes state (RUNNING/SUCCESS/FAILED), result_state,
duration_minutes for completed runs, current_duration_minutes for running jobs.
Inputs: job_id, limit.
list_jobsA
List Databricks jobs with pagination and filtering.
Args:
limit: Number of jobs to return (default: 25, keeps response under token limits)
offset: Starting position for pagination (default: 0, use pagination_info.next_offset for next page)
created_by: Filter by creator email (e.g. 'user@company.com'), case-insensitive, optional
include_run_status: Include latest run status and duration (default: true, set false for faster response)
Returns:
JSON with jobs array and pagination_info. Each job includes latest_run with state, duration_minutes, etc.
Use pagination_info.next_offset for next page. Total jobs shown in pagination_info.total_jobs.
Inputs: limit, offset, created_by, include_run_status.
list_notebooksC
List notebooks in a workspace directory
Inputs: path (required).
list_volume_filesA
List files and directories in a Unity Catalog volume.
Args:
volume_path: Volume path to list (e.g. '/Volumes/catalog/schema/volume/directory')
Returns:
JSON with directory listing including file names, sizes, and modification times.
Example:
# List files in volume directory
files = list_volume_files('/Volumes/kbqa/stark_mas_eval/stark_raw_data/')
Note: Returns detailed file information including sizes for managing large datasets.
Inputs: volume_path (required).
run_jobD
Run a Databricks job
Inputs: job_id (required), notebook_params.
start_clusterB
Start a terminated Databricks cluster
Inputs: cluster_id (required).
terminate_clusterC
Terminate a Databricks cluster
Inputs: cluster_id (required).
upload_file_to_dbfsA
Upload a local file to Databricks File System (DBFS).
Args:
local_file_path: Path to local file (e.g. './data/notebook.py')
dbfs_path: DBFS path (e.g. '/tmp/uploaded/notebook.py')
overwrite: Whether to overwrite existing file (default: True)
Returns:
JSON with upload results including success status, file size, and upload time.
Example:
# Upload script to DBFS
result = upload_file_to_dbfs(
local_file_path='./scripts/analysis.py',
dbfs_path='/tmp/analysis.py',
overwrite=True
)
Note: For large files (>10MB), uses chunked upload with proper retry logic.
DBFS is good for temporary files, scripts, and smaller datasets.
Inputs: local_file_path (required), dbfs_path (required), overwrite.
upload_file_to_volumeA
Upload a local file to a Databricks Unity Catalog volume.
Args:
local_file_path: Path to local file (e.g. './data/products.json')
volume_path: Full volume path (e.g. '/Volumes/catalog/schema/volume/file.json')
overwrite: Whether to overwrite existing file (default: False)
Returns:
JSON with upload results including success status, file size in MB, and upload time.
Example:
# Upload large dataset to volume
result = upload_file_to_volume(
local_file_path='./stark_export/products_full.json',
volume_path='/Volumes/kbqa/stark_mas_eval/stark_raw_data/products_full.json',
overwrite=True
)
Note: Handles large files (multi-GB) with progress tracking and proper error handling.
Perfect for uploading extracted datasets to Unity Catalog volumes for processing.
Inputs: local_file_path (required), volume_path (required), overwrite.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 19 tools
Every tool has a clearly distinct purpose targeting specific Databricks resources and actions. There is no ambiguity: create_* tools create resources, list_* tools list resources, execute_sql vs execute_sql_nonblocking handle different execution modes, and upload_file_to_dbfs vs upload_file_to_volume target different storage systems. The descriptions reinforce these distinctions.
All tool names follow a consistent verb_noun pattern with snake_case throughout. Verbs like create, list, get, execute, run, start, terminate, export, and upload are used predictably with appropriate nouns (cluster, job, notebook, sql, files, etc.). There are no deviations in naming conventions.
With 19 tools, the count is slightly high but reasonable for a comprehensive Databricks interface covering clusters, jobs, notebooks, SQL execution, and file management. It includes core operations for each domain without being excessive, though some tools like list_job_runs and list_jobs could potentially be consolidated to reduce count.
The tool surface provides complete CRUD/lifecycle coverage for Databricks domains: clusters (create/get/list/start/terminate), jobs (create/list/run with detailed run tracking), notebooks (create/list/export), SQL execution (blocking/non-blocking with status check), and file management (list/upload for both DBFS and Unity Catalog volumes). There are no obvious gaps that would cause agent failures.
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted BigQuery MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact with Databricks workspaces through natural language, allowing SQL query execution and job management operations.50-
- AlicenseBqualityDmaintenanceA server that implements the Model Completion Protocol (MCP) to allow LLMs to interact with Databricks resources including clusters, jobs, notebooks, and SQL execution through natural language.1150MIT
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants like Claude to interact with Databricks workspaces through secure OAuth authentication. Supports custom prompts, tools for workspace management, and SQL query execution via a deployable MCP server on Databricks Apps.-
- AlicenseCqualityDmaintenanceA read-only MCP server that enables users to query Databricks SQL, browse metadata, and monitor Delta Lake tables. It also supports tracking Databricks Jobs, DLT Pipelines, and cluster metrics through natural language interfaces.254MIT