Skip to content

[apps-mcp] Fix token-based authentication for default profile - #4195

Merged
fjakobs merged 1 commit into
mainfrom
apps-mcp-fix-auth
Jan 5, 2026
Merged

[apps-mcp] Fix token-based authentication for default profile#4195
fjakobs merged 1 commit into
mainfrom
apps-mcp-fix-auth

Conversation

@lennartkats-db

Copy link
Copy Markdown
Contributor

[apps-mcp] Fix token-based authentication for default profile

Changes

Fix authentication in apps-mcp for the DEFAULT profile.

Why

When InvokeDatabricksCLI runs a subprocess, it sets DATABRICKS_HOST explicitly. This prevents the SDK from falling back to the DEFAULT profile in ~/.databrickscfg, causing auth failures.

The old code tried to pass DATABRICKS_CONFIG_PROFILE, but GetDatabricksProfile() always returned empty because the profile was never stored in the session during auto-authentication.

Passing the token directly works for all auth methods (OAuth, PAT, profile-based).

Tests

Manual testing via MCP server:

# Without fix: auth error
agent -p 'invoke databricks cli with "current-user me"'## With fix: succeeds 
agent -p 'invoke databricks cli with "current-user me"'#

Root cause confirmed by reproducing SDK behavior directly:

# SDK falls back to DEFAULT profile when no host is set
./cli current-user me ## SDK fails when DATABRICKS_HOST is set without credentials
DATABRICKS_HOST=https://... ./cli current-user me #

OAuth-based auth also works since Config.Token is populated with the OAuth access token after authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

Commit: 4df311d

Run: 20709963258

Env🟨​KNOWN💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
🟨​aws linux98238166125:34
🟨​aws windows143238365919:38
🟨​aws-ucws linux512253253828:17
🟨​aws-ucws windows107253453632:31
🟨​azure linux210338166022:39
🟨​azure windows75338365823:30
🟨​azure-ucws linux210352853729:44
🟨​azure-ucws windows75353053531:34
🟨​gcp linux210337066623:03
🟨​gcp windows75337266421:20
19 interesting tests: 14 KNOWN, 4 RECOVERED, 1 SKIP
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
🟨​TestAccept🟨​K🟨​K🟨​K🟨​K💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/deployment/bind/alert🙈​S🙈​S🙈​S🙈​S💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions🟨​K🟨​K🟨​K🟨​K🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions🟨​K🟨​K💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestExport🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K
🟨​TestExportWithFileFlag🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K
🟨​TestImportDir💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportDirDoesNotOverwrite💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportDirWithOverwriteFlag💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportFileFormatAuto💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportFileFormatSource💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
Top 33 slowest tests (at least 2 minutes):
durationenvtestname
6:44azure-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
6:40azure-ucws windowsTestSecretsPutSecretStringValue
6:36aws-ucws linuxTestAccept/bundle/resources/synced_database_tables/basic
6:27aws-ucws windowsTestAccept/bundle/resources/synced_database_tables/basic
6:16azure-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
6:05aws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:49gcp linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:45aws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:20aws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:19gcp windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:19aws-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:19gcp windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:10azure-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:08azure-ucws windowsTestAccept/ssh/connection
5:04gcp linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
4:39azure-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
4:17azure-ucws linuxTestAccept/ssh/connection
4:04azure windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
3:59azure linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
3:33azure windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
3:23azure linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
3:04azure-ucws windowsTestAccept/bundle/resources/synced_database_tables/basic
2:34azure-ucws linuxTestSecretsPutSecretStringValue
2:33azure-ucws linuxTestAccept/bundle/resources/synced_database_tables/basic
2:25azure-ucws linuxTestAccept
2:22aws-ucws windowsTestAccept/ssh/connection
2:19gcp windowsTestSecretsPutSecretStringValue
2:18gcp linuxTestAccept
2:18aws-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
2:17aws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
2:17aws-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
2:16azure linuxTestAccept
2:03aws-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct

@fjakobs
fjakobs added this pull request to the merge queueJan 5, 2026
Merged via the queue into main with commit 56fc0dbJan 5, 2026
22 checks passed
@fjakobs
fjakobs deleted the apps-mcp-fix-auth branch January 5, 2026 10:07
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Commit: 56fc0db

Run: 20711977674

Env❌​FAIL🟨​KNOWN🔄​flaky💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
🟨​aws linux928241564757:39
❌​aws windows2143241764553:21
🟨​aws-ucws linux512258651871:49
🟨​aws-ucws windows1027258651673:13
❌​azure linux239341564657:15
🟨​azure windows735341664454:12
🟨​azure-ucws linux210358251765:13
🟨​azure-ucws windows75358451561:39
🟨​gcp linux210339765550:25
🟨​gcp windows75339965346:45
26 interesting tests: 14 KNOWN, 5 flaky, 4 RECOVERED, 2 FAIL, 1 SKIP
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
🟨​TestAccept🟨​K🟨​K🟨​K🟨​K🟨​K💚​R💚​R💚​R💚​R💚​R
🔄​TestAccept/bundle/deploy/mlops-stacks✅​p✅​p✅​p✅​p✅​p🔄​f✅​p✅​p✅​p✅​p
💚​TestAccept/bundle/deployment/bind/alert🙈​S🙈​S🙈​S🙈​S💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
🔄​TestAccept/bundle/resources/clusters/run/spark_python_task✅​p✅​p✅​p✅​p✅​p🔄​f✅​p✅​p✅​p✅​p
🔄​TestAccept/bundle/resources/clusters/run/spark_python_task/DATABRICKS_BUNDLE_ENGINE=direct✅​p✅​p✅​p✅​p✅​p🔄​f✅​p✅​p✅​p✅​p
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions🟨​K🟨​K🟨​K🟨​K🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions🟨​K🟨​K💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
❌​TestAccept/bundle/resources/secret_scopes/permissions✅​p❌​F✅​p🔄​f❌​F✅​p✅​p✅​p🙈​s🙈​s
❌​TestAccept/bundle/resources/secret_scopes/permissions/DATABRICKS_BUNDLE_ENGINE=terraform✅​p❌​F✅​p🔄​f❌​F✅​p✅​p✅​p
🔄​TestAccept/bundle/run/app-with-job🔄​f✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p
🔄​TestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct🔄​f✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p
🟨​TestExport🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K
🟨​TestExportWithFileFlag🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K
🟨​TestImportDir💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportDirDoesNotOverwrite💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportDirWithOverwriteFlag💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportFileFormatAuto💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestImportFileFormatSource💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
Top 50 slowest tests (at least 2 minutes):
durationenvtestname
14:05gcp linuxTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
12:45gcp windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=SINGLE_USER
12:32aws windowsTestAccept/bundle/integration_whl/wrapper_custom_params/DATABRICKS_BUNDLE_ENGINE=terraform
11:42aws linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
11:41aws-ucws windowsTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=direct
11:16aws-ucws windowsTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=terraform
11:04aws-ucws linuxTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=direct
11:01aws-ucws linuxTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
11:01aws-ucws windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=SINGLE_USER
10:52aws windowsTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
10:52aws-ucws linuxTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=terraform
10:48aws-ucws windowsTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
10:32aws linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
10:10gcp linuxTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=SINGLE_USER
10:09aws windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
9:43azure windowsTestAccept/bundle/resources/clusters/run/spark_python_task/DATABRICKS_BUNDLE_ENGINE=terraform
9:21azure-ucws windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
9:10azure linuxTestAccept/bundle/resources/clusters/run/spark_python_task/DATABRICKS_BUNDLE_ENGINE=direct
8:45azure-ucws linuxTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
8:43gcp windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:42azure-ucws linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:40aws windowsTestAccept/bundle/integration_whl/wrapper/DATABRICKS_BUNDLE_ENGINE=terraform
8:40gcp windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
8:40aws windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:33gcp linuxTestAccept/bundle/integration_whl/interactive_cluster/DATABRICKS_BUNDLE_ENGINE=terraform
8:30aws-ucws linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:26aws windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=USER_ISOLATION
8:26azure linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:25aws-ucws windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=USER_ISOLATION
8:19gcp windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=USER_ISOLATION
8:09aws-ucws windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=USER_ISOLATION
8:07azure-ucws windowsTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
8:07azure-ucws windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:06azure windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform
8:02aws windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=SINGLE_USER
8:00aws linuxTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=USER_ISOLATION
7:57azure windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
7:55gcp linuxTestAccept/bundle/integration_whl/interactive_cluster/DATABRICKS_BUNDLE_ENGINE=direct
7:54azure linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
7:52aws linuxTestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform
7:51aws-ucws linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
7:51azure windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
7:49aws windowsTestAccept/bundle/integration_whl/interactive_cluster/DATABRICKS_BUNDLE_ENGINE=direct
7:47aws linuxTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=SINGLE_USER
7:46gcp linuxTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
7:45aws-ucws windowsTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=SINGLE_USER
7:42aws-ucws windowsTestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct
7:41aws-ucws linuxTestAccept/bundle/integration_whl/interactive_cluster/DATABRICKS_BUNDLE_ENGINE=terraform
7:39azure linuxTestAccept/bundle/resources/permissions/factcheck/DATABRICKS_BUNDLE_ENGINE=terraform
7:37gcp linuxTestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=USER_ISOLATION

pietern added a commit that referenced this pull request Jan 12, 2026
…moval
The secret scope permissions test fails ~33% of the time when using
the Terraform bundle engine. The root cause is a backend API race
condition where parallel ACL modifications return inconsistent results.
The direct bundle engine already works around this by sequentializing
ACL operations (see #3886):
// Set ACLs. The service returns inconsistent results for parallel
// API calls. That's why we do them sequentially here to maintain
// correctness.
The Terraform provider has a similar workaround for creates via
robustPutACL with retry/verification (terraform-provider-databricks#4885,
issue #4195), but deletions have no such protection.
This change adds a depends_on chain between ACL resources, forcing
Terraform to execute them sequentially:
ACL_0 → depends_on: [scope]
ACL_1 → depends_on: [scope, ACL_0]
ACL_2 → depends_on: [scope, ACL_1]
This avoids triggering the backend race condition without requiring
changes to the Terraform provider.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
denik pushed a commit that referenced this pull request May 20, 2026
# [apps-mcp] Fix token-based authentication for default profile
## Changes
Fix authentication in `apps-mcp` for the `DEFAULT` profile.
## Why
When `InvokeDatabricksCLI` runs a subprocess, it sets `DATABRICKS_HOST`
explicitly. This prevents the SDK from falling back to the DEFAULT
profile in `~/.databrickscfg`, causing auth failures.
The old code tried to pass `DATABRICKS_CONFIG_PROFILE`, but
`GetDatabricksProfile()` always returned empty because the profile was
never stored in the session during auto-authentication.
Passing the token directly works for all auth methods (OAuth, PAT,
profile-based).
## Tests
Manual testing via MCP server:
```bash
# Without fix: auth error
agent -p 'invoke databricks cli with "current-user me"' # ✗
# With fix: succeeds agent -p 'invoke databricks cli with "current-user me"' # ✓
```
Root cause confirmed by reproducing SDK behavior directly:
```bash
# SDK falls back to DEFAULT profile when no host is set
./cli current-user me # ✓
# SDK fails when DATABRICKS_HOST is set without credentials
DATABRICKS_HOST=https://... ./cli current-user me # ✗
```
OAuth-based auth also works since `Config.Token` is populated with the
OAuth access token after authentication.
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@lennartkats-db@eng-dev-ecosystem-bot@fjakobs