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.
Install the required dependencies using pip:
pip install -r requirements.txt
Or if you prefer using uv
:
uv pip install -r requirements.txt
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.
Ensure the following permissions are properly configured:
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.
To use this server with Cursor:
mkdir -p ~/.cursor
touch ~/.cursor/mcp.json
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"
]
}
}
}
The server provides four main tools:
Execute SQL Query
execute_sql_query(sql: str) -> str
List Schemas
list_schemas(catalog: str) -> str
List Tables
list_tables(schema: str) -> str
Describe Table
describe_table(table_name: str) -> str
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")
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.
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.
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"
]
}
}
}
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.
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.