# Configure the Databricks MCP Server

Connect Databricks' managed MCP servers to a Dtwo gateway via OAuth.

## Overview

Databricks hosts managed MCP servers in each workspace: Genie for natural-language analytics, Databricks SQL for running queries against Unity Catalog data, web search, and a code sandbox. Access is authorized through OAuth via a Databricks app connection you register yourself, so each user signs in as themselves and their own Unity Catalog and warehouse permissions apply.

## 1. Configure Databricks

1. If you're connecting Databricks SQL, web search, or sandbox, have an account admin open the account console **Previews** page and turn on **Enhanced Unity Gateway**. Without it, calls fail with "The MCP service is administratively suspended."
2. In the account console, click **Settings**, open the **App connections** tab, and click **Add connection**. Name the connection (for example, "Dtwo Gateway"), add your gateway's OAuth callback URL as a **Redirect URL** (found in the Overview tab for your gateway in the Dtwo UI), grant the `ai-gateway` access scope, and select **Generate a client secret**.
3. Databricks shows the client secret only once, in the confirmation dialog. Keep it open, and in another tab go to **Vault** in the Dtwo UI. Add two entries, selecting **Add entry** for each one. Set **Used by** to the gateway you're connecting Databricks to, or to **All gateways** if you plan to connect more than one gateway to Databricks:
   - Client ID:
     - **Name**: `DATABRICKS_CLIENT_ID`
     - **Value**: paste the **Client ID** from the Databricks dialog
   - Client secret:
     - **Name**: `DATABRICKS_CLIENT_SECRET`
     - **Value**: paste the **Client Secret** from the Databricks dialog
     - Turn on **Encrypted value**.

   Databricks can take up to 30 minutes to apply changes to the OAuth app connection you created in step 2, such as a new redirect URL. If authorization fails right after a change, wait and try again.
4. Make sure the users who'll connect have the **Consumer access** entitlement and permission to call the MCP service.

## 2. Add the MCP servers to your gateway config

Go to your gateway in the Dtwo UI and open **Configuration → Advanced**. In the `mcp_servers` section add an entry for each Databricks MCP server you want to expose. All of them use the same app connection and Vault entries.

### Genie

Natural-language questions across the data your users can access. Generally available.

```yaml
  - name: databricks-genie
    description: "Databricks' managed Genie MCP server for natural-language analytics."
    url: "https://<WORKSPACE_HOSTNAME>/ai-gateway/mcp-services/system.ai.genie_one_mcp"
    transport_type: streamablehttp
    authentication:
      type: oauth
      grant_type: authorization_code
      scopes:
        - ai-gateway
        - offline_access
      client_id: <<DATABRICKS_CLIENT_ID>>
      client_secret: <<DATABRICKS_CLIENT_SECRET>>
      authorization_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/authorize"
      token_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/token"
      redirect_uri: "<CALLBACK_URL>"
      pkce_enabled: true
```

### Databricks SQL

Runs SQL against Unity Catalog data on a SQL warehouse, including statements that write data. Beta — requires the **Enhanced Unity Gateway** preview from step 1.

```yaml
  - name: databricks-sql
    description: "Databricks' managed MCP server for SQL queries over Unity Catalog data."
    url: "https://<WORKSPACE_HOSTNAME>/ai-gateway/mcp-services/system.ai.dbsql"
    transport_type: streamablehttp
    authentication:
      type: oauth
      grant_type: authorization_code
      scopes:
        - ai-gateway
        - offline_access
      client_id: <<DATABRICKS_CLIENT_ID>>
      client_secret: <<DATABRICKS_CLIENT_SECRET>>
      authorization_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/authorize"
      token_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/token"
      redirect_uri: "<CALLBACK_URL>"
      pkce_enabled: true
```

### Web search

Searches the web from Databricks. Beta — requires the **Enhanced Unity Gateway** preview from step 1. Not available to users with only the **Consumer access** entitlement, or in workspaces under a HIPAA BAA.

```yaml
  - name: databricks-web-search
    description: "Databricks' managed MCP server for web search."
    url: "https://<WORKSPACE_HOSTNAME>/ai-gateway/mcp-services/system.ai.web_search"
    transport_type: streamablehttp
    authentication:
      type: oauth
      grant_type: authorization_code
      scopes:
        - ai-gateway
        - offline_access
      client_id: <<DATABRICKS_CLIENT_ID>>
      client_secret: <<DATABRICKS_CLIENT_SECRET>>
      authorization_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/authorize"
      token_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/token"
      redirect_uri: "<CALLBACK_URL>"
      pkce_enabled: true
```

### Sandbox

Runs code in a Databricks-managed sandbox. Beta — requires the **Enhanced Unity Gateway** preview from step 1. Not available to users with only the **Consumer access** entitlement.

```yaml
  - name: databricks-sandbox
    description: "Databricks' managed MCP server for running code in a sandbox."
    url: "https://<WORKSPACE_HOSTNAME>/ai-gateway/mcp-services/system.ai.sandbox"
    transport_type: streamablehttp
    authentication:
      type: oauth
      grant_type: authorization_code
      scopes:
        - ai-gateway
        - offline_access
      client_id: <<DATABRICKS_CLIENT_ID>>
      client_secret: <<DATABRICKS_CLIENT_SECRET>>
      authorization_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/authorize"
      token_url: "https://<WORKSPACE_HOSTNAME>/oidc/v1/token"
      redirect_uri: "<CALLBACK_URL>"
      pkce_enabled: true
```

Replace the placeholder values in each entry:

- `<WORKSPACE_HOSTNAME>` — your Databricks workspace hostname without `https://`, for example `dbc-a1b2345c-d6e7.cloud.databricks.com`. Use the same hostname in all three URLs.
- `<CALLBACK_URL>` — the same Redirect URL you set in step 1, found in the Overview tab for your gateway in the Dtwo UI.

The `<<DATABRICKS_...>>` values pull the client ID and client secret from the Vault entries you added in step 1. If you named the entries something else, use those names instead.

## 3. Deploy and verify

Save the configuration and deploy the gateway.

Then, in your AI client, ask it to authorize Databricks via the gateway. This opens the Databricks sign-in screen — sign in as the user whose permissions the agent should inherit, and approve the consent prompt. Once authorized, confirm each server's tools appear under its name (for example, `databricks-sql-*`) and run a quick call, such as `databricks-sql-execute_sql_read_only` with `SHOW CATALOGS`, to make sure the connection works.

If the tools don't appear after you authorize, refresh the tool list in your AI client — some clients don't pick it up automatically.

---

Having trouble? Email [support@dtwo.ai](mailto:support@dtwo.ai).