From a1d52c8ccd1c18754b4898d8e14180c0b5410c26 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Mon, 5 Jan 2026 10:28:16 +0100 Subject: [PATCH 1/4] Add non-interactive mode for MCP install in AI agents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detect when running inside Claude Code (CLAUDECODE env var) or Cursor (CURSOR_AGENT env var) in non-interactive mode and automatically install for the detected agent without prompting. This enables AI agents to install the MCP server without user interaction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- experimental/aitools/cmd/install.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/experimental/aitools/cmd/install.go b/experimental/aitools/cmd/install.go index 55ac7c29e2..d2cd885825 100644 --- a/experimental/aitools/cmd/install.go +++ b/experimental/aitools/cmd/install.go @@ -9,6 +9,7 @@ import ( "github.com/databricks/cli/experimental/aitools/lib/agents" "github.com/databricks/cli/libs/cmdio" "github.com/fatih/color" + "github.com/mattn/go-isatty" "github.com/spf13/cobra" ) @@ -26,6 +27,27 @@ func newInstallCmd() *cobra.Command { } func runInstall(ctx context.Context) error { + // Check for non-interactive mode with agent detection + // If running in an AI agent, install automatically without prompts + if !isatty.IsTerminal(os.Stdin.Fd()) { + if os.Getenv("CLAUDECODE") != "" { + if err := agents.InstallClaude(); err != nil { + return fmt.Errorf("failed to install for Claude Code: %w", err) + } + cmdio.LogString(ctx, color.GreenString("✓ Installed Databricks MCP server for Claude Code")) + cmdio.LogString(ctx, color.YellowString("⚠️ Please restart Claude Code for changes to take effect")) + return nil + } + if os.Getenv("CURSOR_AGENT") != "" { + if err := agents.InstallCursor(); err != nil { + return fmt.Errorf("failed to install for Cursor: %w", err) + } + cmdio.LogString(ctx, color.GreenString("✓ Installed Databricks MCP server for Cursor")) + cmdio.LogString(ctx, color.YellowString("⚠️ Please restart Cursor for changes to take effect")) + return nil + } + } + cmdio.LogString(ctx, "") green := color.New(color.FgGreen).SprintFunc() cmdio.LogString(ctx, " "+green("[")+"████████"+green("]")+" Experimental Databricks AI Tools MCP server") From d1b0d3f820fac94139fd9be2e183ebbb602a50e1 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Tue, 6 Jan 2026 10:42:20 +0100 Subject: [PATCH 2/4] Use cmdio.IsTTY for terminal detection instead of go-isatty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids introducing go-isatty as a new dependency by using the existing cmdio.IsTTY helper, which also provides better Windows Git Bash support through IsCygwinTerminal checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- experimental/aitools/cmd/install.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/experimental/aitools/cmd/install.go b/experimental/aitools/cmd/install.go index d2cd885825..2950b9b9f5 100644 --- a/experimental/aitools/cmd/install.go +++ b/experimental/aitools/cmd/install.go @@ -9,7 +9,6 @@ import ( "github.com/databricks/cli/experimental/aitools/lib/agents" "github.com/databricks/cli/libs/cmdio" "github.com/fatih/color" - "github.com/mattn/go-isatty" "github.com/spf13/cobra" ) @@ -29,7 +28,7 @@ func newInstallCmd() *cobra.Command { func runInstall(ctx context.Context) error { // Check for non-interactive mode with agent detection // If running in an AI agent, install automatically without prompts - if !isatty.IsTerminal(os.Stdin.Fd()) { + if !cmdio.IsTTY(os.Stdin) { if os.Getenv("CLAUDECODE") != "" { if err := agents.InstallClaude(); err != nil { return fmt.Errorf("failed to install for Claude Code: %w", err) From e4f9bd0d011a651a360397046addd9c24cc76734 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Sun, 11 Jan 2026 17:25:28 +0100 Subject: [PATCH 3/4] cleanup --- experimental/aitools/cmd/install.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/experimental/aitools/cmd/install.go b/experimental/aitools/cmd/install.go index 2950b9b9f5..c84e7e8f0c 100644 --- a/experimental/aitools/cmd/install.go +++ b/experimental/aitools/cmd/install.go @@ -31,7 +31,7 @@ func runInstall(ctx context.Context) error { if !cmdio.IsTTY(os.Stdin) { if os.Getenv("CLAUDECODE") != "" { if err := agents.InstallClaude(); err != nil { - return fmt.Errorf("failed to install for Claude Code: %w", err) + return err } cmdio.LogString(ctx, color.GreenString("✓ Installed Databricks MCP server for Claude Code")) cmdio.LogString(ctx, color.YellowString("⚠️ Please restart Claude Code for changes to take effect")) @@ -39,7 +39,7 @@ func runInstall(ctx context.Context) error { } if os.Getenv("CURSOR_AGENT") != "" { if err := agents.InstallCursor(); err != nil { - return fmt.Errorf("failed to install for Cursor: %w", err) + return err } cmdio.LogString(ctx, color.GreenString("✓ Installed Databricks MCP server for Cursor")) cmdio.LogString(ctx, color.YellowString("⚠️ Please restart Cursor for changes to take effect")) @@ -55,9 +55,9 @@ func runInstall(ctx context.Context) error { cmdio.LogString(ctx, "") yellow := color.New(color.FgYellow).SprintFunc() - cmdio.LogString(ctx, yellow("╔════════════════════════════════════════════════════════════════╗")) - cmdio.LogString(ctx, yellow("║ ⚠️ EXPERIMENTAL: This command may change in future versions ║")) - cmdio.LogString(ctx, yellow("╚════════════════════════════════════════════════════════════════╝")) + cmdio.LogString(ctx, yellow("════════════════════════════════════════════════════════════════")) + cmdio.LogString(ctx, yellow(" ⚠️ EXPERIMENTAL: This command may change in future versions ")) + cmdio.LogString(ctx, yellow("════════════════════════════════════════════════════════════════")) cmdio.LogString(ctx, "") cmdio.LogString(ctx, "Which coding agents would you like to install the MCP server for?") From 51f2be3a27df1a0a13a3a5e53df9aea2153ba210 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Sun, 11 Jan 2026 17:38:47 +0100 Subject: [PATCH 4/4] Show manual instructions for unknown agents in non-interactive mode --- experimental/aitools/cmd/install.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/experimental/aitools/cmd/install.go b/experimental/aitools/cmd/install.go index c84e7e8f0c..60a98290b9 100644 --- a/experimental/aitools/cmd/install.go +++ b/experimental/aitools/cmd/install.go @@ -45,6 +45,8 @@ func runInstall(ctx context.Context) error { cmdio.LogString(ctx, color.YellowString("⚠️ Please restart Cursor for changes to take effect")) return nil } + // Unknown agent in non-interactive mode - show manual instructions + return agents.ShowCustomInstructions(ctx) } cmdio.LogString(ctx, "")