Skip to content

Commit 5aa1486

Browse files
Add kernel mcp commands (#57)
## Summary - Introduced a new `mcp` command group to the `kernel` CLI. - Added `kernel mcp install` command to configure the Kernel MCP server for various AI tools, including Cursor, Claude, VS Code, Windsurf, Goose, and Zed. - Added `kernel mcp server` command to display information about the remote Kernel MCP server, including connection details and quick install examples. - Integrated `mcp` commands into the root command and made them exempt from authentication. <br /> > Want me to make any changes? Add a review or comment with `@tembo` and i'll get back to work! [![tembo.io](https://internal.tembo.io/static/view/tembo.svg?v=4)](https://app.tembo.io/tasks/7d9085e8-6524-4b28-8b48-a0979d33fe48) [![linear.app](https://internal.tembo.io/static/view/linear.svg?v=4)](https://linear.app/onkernel/issue/KERNEL-723/add-kernel-cli-mcp-install-command-similar-to-pscale) [![app.tembo.io](https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-4-5?v=1)](https://app.tembo.io/settings/agents) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds `kernel mcp` with `install` and `server` to configure/use the remote Kernel MCP server across multiple tools, integrated into root and exempt from auth. > > - **CLI**: > - **New `mcp` command group**: > - `install`: configures MCP for `cursor`, `claude`, `claude-code`, `windsurf`, `vscode`, `goose`, `zed`; uses per-target transports (HTTP or stdio via `npx mcp-remote`); prints post-install steps. > - `server`: shows connection details (`HTTP` and `stdio`), quick install examples, and docs link. > - Integrated `mcp` into root (`cmd/root.go`) and added to auth-exempt commands. > - **Config handling**: > - OS-aware `getConfigPath` for each target. > - JSON helpers: comment stripping, read/write utilities. > - Target-specific installers (e.g., VS Code `mcp.servers`, Zed `context_servers`, Goose YAML instructions). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f14da89. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com> Co-authored-by: Mason Williams <[email protected]>
1 parent d7a6ec8 commit 5aa1486

File tree

4 files changed

+624
-1
lines changed

4 files changed

+624
-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)