Skip to content

Commit 33a4cd7

Browse files
authored
feat(mcp): Add CLI commands to configure AI tool integration
Co-authored-by: null <>
1 parent d7a6ec8 commit 33a4cd7

File tree

4 files changed

+540
-1
lines changed

4 files changed

+540
-1
lines changed

cmd/mcp/install.go

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package mcp
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/pterm/pterm"
8+
"github.com/spf13/cobra"
9+
)
10+
11+
var installCmd = &cobra.Command{
12+
Use: "install",
13+
Short: "Install Kernel MCP server configuration for an AI tool",
14+
Long: `Install Kernel MCP server configuration for a supported AI development tool.
15+
16+
This command modifies the configuration file for the specified target to add
17+
the Kernel MCP server, enabling browser automation capabilities in your AI tool.
18+
19+
Supported targets:
20+
cursor - Cursor editor
21+
claude - Claude Desktop app
22+
claude-code - Claude Code CLI
23+
windsurf - Windsurf editor
24+
vscode - Visual Studio Code
25+
goose - Goose AI
26+
zed - Zed editor
27+
28+
Examples:
29+
# Install for Cursor
30+
kernel mcp install --target cursor
31+
32+
# Install for Claude Desktop
33+
kernel mcp install --target claude
34+
35+
# Install for VS Code
36+
kernel mcp install --target vscode`,
37+
RunE: runInstall,
38+
}
39+
40+
func init() {
41+
MCPCmd.AddCommand(installCmd)
42+
43+
// Build target list for help text
44+
targets := AllTargets()
45+
targetStrs := make([]string, len(targets))
46+
for i, t := range targets {
47+
targetStrs[i] = string(t)
48+
}
49+
50+
installCmd.Flags().String("target", "", fmt.Sprintf("Target AI tool (%s)", strings.Join(targetStrs, ", ")))
51+
_ = installCmd.MarkFlagRequired("target")
52+
}
53+
54+
func runInstall(cmd *cobra.Command, args []string) error {
55+
targetStr, _ := cmd.Flags().GetString("target")
56+
target := Target(strings.ToLower(targetStr))
57+
58+
// Validate target
59+
validTarget := false
60+
for _, t := range AllTargets() {
61+
if target == t {
62+
validTarget = true
63+
break
64+
}
65+
}
66+
67+
if !validTarget {
68+
targets := AllTargets()
69+
targetStrs := make([]string, len(targets))
70+
for i, t := range targets {
71+
targetStrs[i] = string(t)
72+
}
73+
return fmt.Errorf("invalid target '%s'. Supported targets: %s", targetStr, strings.Join(targetStrs, ", "))
74+
}
75+
76+
// Get the config path for display
77+
configPath, err := GetConfigPath(target)
78+
if err != nil {
79+
return fmt.Errorf("failed to determine config path: %w", err)
80+
}
81+
82+
// Install the MCP configuration
83+
if err := Install(target); err != nil {
84+
return fmt.Errorf("failed to install MCP configuration: %w", err)
85+
}
86+
87+
// For Goose, the install function already printed instructions
88+
if target == TargetGoose {
89+
return nil
90+
}
91+
92+
pterm.Success.Printf("MCP server successfully configured for %s at %s\n", target, configPath)
93+
94+
// Print post-install instructions based on target
95+
printPostInstallInstructions(target)
96+
97+
return nil
98+
}
99+
100+
func printPostInstallInstructions(target Target) {
101+
pterm.Println()
102+
103+
switch target {
104+
case TargetCursor:
105+
pterm.Info.Println("Next steps:")
106+
pterm.Println(" 1. Restart Cursor or reload the window")
107+
pterm.Println(" 2. The Kernel MCP server will appear in your tools")
108+
pterm.Println(" 3. You'll be prompted to authenticate when first using Kernel tools")
109+
110+
case TargetClaude:
111+
pterm.Info.Println("Next steps:")
112+
pterm.Println(" 1. Restart Claude Desktop")
113+
pterm.Println(" 2. The Kernel tools will be available in your conversations")
114+
pterm.Println(" 3. You'll be prompted to authenticate when first using Kernel tools")
115+
116+
case TargetClaudeCode:
117+
pterm.Info.Println("Next steps:")
118+
pterm.Println(" 1. Run '/mcp' in the Claude Code REPL to authenticate")
119+
pterm.Println(" 2. The Kernel tools will then be available")
120+
121+
case TargetWindsurf:
122+
pterm.Info.Println("Next steps:")
123+
pterm.Println(" 1. Open Windsurf settings and navigate to MCP servers")
124+
pterm.Println(" 2. Click 'Refresh' to load the Kernel MCP server")
125+
pterm.Println(" 3. You'll be prompted to authenticate when first using Kernel tools")
126+
127+
case TargetVSCode:
128+
pterm.Info.Println("Next steps:")
129+
pterm.Println(" 1. Restart VS Code or reload the window")
130+
pterm.Println(" 2. The Kernel MCP server will be available")
131+
pterm.Println(" 3. You'll be prompted to authenticate when first using Kernel tools")
132+
133+
case TargetZed:
134+
pterm.Info.Println("Next steps:")
135+
pterm.Println(" 1. Restart Zed")
136+
pterm.Println(" 2. The Kernel context server will be available")
137+
pterm.Println(" 3. You'll be prompted to authenticate when first using Kernel tools")
138+
}
139+
}

0 commit comments

Comments
 (0)