Skip to content

Commit 8af2555

Browse files
authored
MCP: Configure user agent for CLI commands from from the MCP server (#4119)
## Changes Configure user agent for CLI commands from from the MCP server ## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> ## Tests <!-- How have you tested the changes? --> <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 348c284 commit 8af2555

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

experimental/apps-mcp/lib/providers/clitools/invoke_databricks_cli.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/databricks/cli/experimental/apps-mcp/lib/common"
1111
"github.com/databricks/cli/experimental/apps-mcp/lib/middlewares"
12+
"github.com/databricks/cli/internal/build"
1213
)
1314

1415
// InvokeDatabricksCLI runs a Databricks CLI command and returns the output.
@@ -23,16 +24,19 @@ func InvokeDatabricksCLI(ctx context.Context, args []string, workingDirectory st
2324
}
2425
host := workspaceClient.Config.Host
2526
profile := middlewares.GetDatabricksProfile(ctx)
26-
27-
// GetCLIPath returns the path to the current CLI executable
2827
cliPath := common.GetCLIPath()
28+
2929
cmd := exec.CommandContext(ctx, cliPath, args...)
3030
cmd.Dir = workingDirectory
31+
3132
env := os.Environ()
3233
env = append(env, "DATABRICKS_HOST="+host)
3334
if profile != "" {
3435
env = append(env, "DATABRICKS_CONFIG_PROFILE="+profile)
3536
}
37+
env = append(env, "DATABRICKS_CLI_UPSTREAM=cli-mcp")
38+
env = append(env, "DATABRICKS_CLI_UPSTREAM_VERSION="+build.GetInfo().Version)
39+
3640
cmd.Env = env
3741

3842
output, err := cmd.CombinedOutput()

0 commit comments

Comments
 (0)