robkisk/dbx_mcp_server_demo
If you are the rightful owner of dbx_mcp_server_demo and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides a structured overview of a custom Model Context Protocol (MCP) server designed to interface with Databricks.
Databricks MCP Server
A production-ready Model Context Protocol (MCP) server for seamless Databricks integration. This server provides comprehensive tools for SQL execution, job management, and Delta Live Table pipeline operations, designed for easy deployment on Databricks Apps.
๐ Features
SQL Operations
- execute_sql: Execute SQL queries against Databricks warehouses
- get_workspace_info: Retrieve current workspace and user information
Job Management
- list_jobs: List all Databricks jobs in the workspace
- get_job_status: Get detailed job status and recent run history
- run_job: Trigger job execution
Pipeline Management
- list_pipelines: List all Delta Live Table pipelines
- get_pipeline_status: Get pipeline status and recent update history
- start_pipeline: Start pipeline updates
Resources
- databricks://jobs/{job_id}: Access detailed job information as MCP resources
๐ Project Structure
databricks-mcp-server/
โโโ src/
โ โโโ mcp_server/
โ โโโ __init__.py
โ โโโ main.py # Entry point for uvicorn
โ โโโ app.py # FastAPI + FastMCP server
โ โโโ config.py # Configuration management
โ โโโ exceptions.py # Custom exceptions
โ โโโ static/
โ โโโ index.html # Web documentation
โโโ app.yaml # Databricks Apps configuration
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
๐ ๏ธ Prerequisites
- Python 3.11+: Required for this project
- UV Package Manager: Install from https://docs.astral.sh/uv/getting-started/installation/
- Databricks CLI: Install from https://docs.databricks.com/dev-tools/cli/install.html
- Databricks Workspace Access: With appropriate permissions for resources you want to manage
๐ฆ Local Development Setup
1. Install Dependencies
# Clone or navigate to project directory
cd databricks-mcp-server
# Install all dependencies
uv sync
2. Configure Environment
Create a .env
file in the project root:
# Required environment variables
DATABRICKS_HOST=https://your-workspace.cloud.databricks.com
DATABRICKS_TOKEN=your_personal_access_token
DATABRICKS_WAREHOUSE_ID=your_warehouse_id # Optional, can be provided per query
3. Local Testing
Test the server locally:
# Run the MCP server locally
uv run mcp-server
The server will start on http://localhost:8000
. You can visit this URL to see the documentation page.
Test with MCP Client:
Add to your Claude Code configuration (~/Library/Application Support/Claude Code/config.json
on macOS):
{
"mcpServers": {
"databricks-local": {
"command": "uv",
"args": ["run", "mcp-server"],
"cwd": "/absolute/path/to/your/databricks-mcp-server"
}
}
}
๐ Databricks Apps Deployment
Step 1: Authenticate with Databricks
# Set up authentication profile
export DATABRICKS_CONFIG_PROFILE=your-profile-name
databricks auth login --profile "$DATABRICKS_CONFIG_PROFILE"
# Verify authentication
databricks current-user me
Step 2: Create Databricks App
# Create a new Databricks App
databricks apps create databricks-mcp-server
Step 3: Sync Code to Workspace
# Get your username
DATABRICKS_USERNAME=$(databricks current-user me | jq -r .userName)
# Sync project files to workspace
databricks sync . "/Users/$DATABRICKS_USERNAME/databricks-mcp-server"
Step 4: Deploy the App
# Deploy the app
databricks apps deploy databricks-mcp-server \
--source-code-path "/Workspace/Users/$DATABRICKS_USERNAME/databricks-mcp-server"
Step 5: Get App URL
# List apps to get the URL
databricks apps list | grep databricks-mcp-server
The output will show your app URL, typically in the format:
https://your-app-name.apps.your-workspace.databricksapps.com
๐ Connecting to Deployed Server
For Claude Code
Add the deployed server to your MCP configuration:
{
"mcpServers": {
"databricks-deployed": {
"transport": "streamableHttp",
"url": "https://your-app-url.databricksapps.com/",
"headers": {
"Authorization": "Bearer your-databricks-token"
}
}
}
}
For Cursor
Add to your Cursor settings:
{
"mcpServers": {
"databricks-deployed": {
"transport": "streamableHttp",
"url": "https://your-app-url.databricksapps.com/",
"headers": {
"Authorization": "Bearer your-databricks-token"
}
}
}
}
๐งช Testing Your Deployment
1. Test the Web Interface
Visit your app URL in a browser to see the documentation page and verify the server is running.
2. Test MCP Functionality
Use your AI client (Claude Code, Cursor) to test the tools:
# Example prompts to test
"List all jobs in my Databricks workspace"
"Execute this SQL query: SELECT 1 as test"
"Show me information about job ID 123"
"List all Delta Live Table pipelines"
โ๏ธ Configuration Options
Environment Variables
Variable | Required | Description |
---|---|---|
DATABRICKS_HOST | Yes | Your Databricks workspace URL |
DATABRICKS_TOKEN | Yes | Personal access token or service principal token |
DATABRICKS_WAREHOUSE_ID | No | Default SQL warehouse ID for queries |
Server Configuration
The server runs on port 8000 by default. You can modify the configuration in src/mcp_server/main.py
:
def main():
uvicorn.run(
"mcp_server.app:app",
host="0.0.0.0",
port=8000,
reload=True, # Set to False for production
)
๐ Troubleshooting
Common Issues
1. Authentication Errors
- Verify your
DATABRICKS_HOST
andDATABRICKS_TOKEN
are correct - Ensure your token has appropriate permissions
- Check that your workspace URL format is correct
2. Deployment Issues
- Ensure you have the correct Databricks CLI version
- Verify your authentication profile is active
- Check that the source code path exists in the workspace
3. Connection Issues
- Verify the app URL is correct and accessible
- Check that the MCP endpoint ends with
/
- Ensure authentication headers are properly configured
Debugging Commands
# Check app status
databricks apps list
# View app logs (if available)
databricks apps logs databricks-mcp-server
# Test endpoint directly
curl -H "Authorization: Bearer your-token" \
https://your-app-url.databricksapps.com/
# Verify local environment
uv run python -c "from mcp_server.config import DatabricksConfig; print(DatabricksConfig.from_environment().is_configured())"
๐ง Development
Adding New Tools
- Add your tool function to
src/mcp_server/app.py
:
@mcp.tool()
def your_new_tool(param: str) -> Dict[str, Any]:
"""Description of your tool"""
# Your implementation here
return {"status": "success", "result": "your_result"}
-
Update the documentation in
src/mcp_server/static/index.html
-
Test locally, then redeploy:
# Test locally
uv run mcp-server
# Redeploy to Databricks Apps
databricks sync . "/Users/$DATABRICKS_USERNAME/databricks-mcp-server"
databricks apps deploy databricks-mcp-server \
--source-code-path "/Workspace/Users/$DATABRICKS_USERNAME/databricks-mcp-server"
Project Scripts
Available scripts defined in pyproject.toml
:
# Run MCP server
uv run mcp-server
# Other available scripts
uv run add-asset # Add project assets
uv run test # Run tests
uv run validate-setup # Validate environment setup
๐ Additional Resources
- Databricks MCP Documentation
- Model Context Protocol Specification
- Databricks Apps Documentation
- FastMCP Framework
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This server demonstrates how to build production-ready MCP servers for Databricks Apps. Customize the tools and configuration based on your specific use case and security requirements.