Skip to content

Commit 5a67491

Browse files
committed
minor fixes
1 parent b4f49dc commit 5a67491

File tree

3 files changed

+69
-38
lines changed

3 files changed

+69
-38
lines changed

internal/mcp/init/claude_code.go

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os/exec"
88

99
"github.com/spf13/afero"
10+
"github.com/supabase/cli/internal/utils"
1011
)
1112

1213
// claudeCodeClient implements the Client interface for Claude Code
@@ -31,19 +32,47 @@ func (c *claudeCodeClient) Configure(ctx context.Context, fsys afero.Fs) error {
3132
fmt.Println("Configuring Claude Code...")
3233
fmt.Println()
3334

34-
// Run the 'claude mcp add' command
35-
cmd := exec.CommandContext(ctx, "claude", "mcp", "add", "--transport", "http", "supabase", "http://localhost:54321/mcp")
35+
// Use utils.PromptChoice for dropdown
36+
choice, err := utils.PromptChoice(ctx, "Where would you like to add the Claude Code MCP server?", []utils.PromptItem{
37+
{Summary: "local", Details: "Local (only for you in this project)"},
38+
{Summary: "project", Details: "Project (shared via .mcp.json in project root)"},
39+
{Summary: "user", Details: "User (available across all projects for your user)"},
40+
})
41+
if err != nil {
42+
fmt.Printf("⚠️ Warning: failed to select scope for Claude Code MCP server: %v\n", err)
43+
fmt.Println("Defaulting to local scope.")
44+
choice = utils.PromptItem{Summary: "local"}
45+
}
46+
47+
cmdArgs := []string{"mcp", "add", "--transport", "http", "supabase", "http://localhost:54321/mcp"}
48+
if choice.Summary != "local" {
49+
cmdArgs = append(cmdArgs, "--scope", choice.Summary)
50+
}
51+
cmd := exec.CommandContext(ctx, "claude", cmdArgs...)
3652

3753
cmd.Stdout = os.Stdout
3854
cmd.Stderr = os.Stderr
3955

40-
if err := cmd.Run(); err != nil {
41-
return fmt.Errorf("failed to configure Claude Code: %w", err)
56+
// Build command string for display
57+
cmdStr := "claude " + fmt.Sprintf("%v", cmdArgs)
58+
// Clean up the array format
59+
cmdStr = "claude"
60+
for _, arg := range cmdArgs {
61+
cmdStr += " " + arg
4262
}
4363

44-
fmt.Println()
45-
fmt.Println("✓ Successfully added Supabase MCP server to Claude Code!")
46-
fmt.Println()
47-
fmt.Println("The server is now available in your Claude Code environment.")
64+
err = cmd.Run()
65+
if err != nil {
66+
fmt.Println()
67+
fmt.Printf("⚠️ Warning: failed to configure Claude Code MCP server: %v\n", err)
68+
fmt.Println("You may need to configure it manually.")
69+
} else {
70+
fmt.Println()
71+
fmt.Println("✓ Successfully added Supabase MCP server to Claude Code!")
72+
fmt.Println()
73+
fmt.Printf("Command executed: %s\n", cmdStr)
74+
fmt.Println()
75+
fmt.Println("The server is now available in your Claude Code environment.")
76+
}
4877
return nil
4978
}

internal/mcp/init/cursor.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99

1010
"github.com/spf13/afero"
11+
"github.com/supabase/cli/internal/utils"
1112
)
1213

1314
// cursorClient implements the Client interface for Cursor
@@ -32,22 +33,16 @@ func (c *cursorClient) Configure(ctx context.Context, fsys afero.Fs) error {
3233
fmt.Println("Configuring Cursor...")
3334
fmt.Println()
3435

35-
// Prompt for config scope
36-
fmt.Println("Where would you like to add the configuration?")
37-
fmt.Println(" 1. Project-local (in .cursor/mcp.json)")
38-
fmt.Println(" 2. Global (in your home directory)")
39-
fmt.Print("Choice [1]: ")
40-
41-
var choice string
42-
if _, err := fmt.Scanln(&choice); err != nil && err.Error() != "unexpected newline" {
43-
return fmt.Errorf("failed to read choice: %w", err)
44-
}
45-
if choice == "" {
46-
choice = "1"
36+
choice, err := utils.PromptChoice(ctx, "Where would you like to add the configuration?", []utils.PromptItem{
37+
{Summary: "project", Details: "Project-local (in .cursor/mcp.json)"},
38+
{Summary: "global", Details: "Global (in your home directory)"},
39+
})
40+
if err != nil {
41+
return err
4742
}
4843

4944
var configPath string
50-
if choice == "2" {
45+
if choice.Summary == "global" {
5146
// Global config
5247
homeDir, _ := os.UserHomeDir()
5348
configPath = filepath.Join(homeDir, ".cursor", "mcp.json")
@@ -59,7 +54,8 @@ func (c *cursorClient) Configure(ctx context.Context, fsys afero.Fs) error {
5954

6055
// Prepare the Supabase MCP server config
6156
supabaseConfig := map[string]interface{}{
62-
"url": "http://localhost:54321/mcp",
57+
"type": "http",
58+
"url": "http://localhost:54321/mcp",
6359
}
6460

6561
// Read existing config if it exists
@@ -100,18 +96,24 @@ func (c *cursorClient) Configure(ctx context.Context, fsys afero.Fs) error {
10096
return fmt.Errorf("failed to write config file: %w", err)
10197
}
10298

99+
// Generate example for display
100+
configExample, _ := json.MarshalIndent(map[string]interface{}{
101+
"mcpServers": map[string]interface{}{
102+
"supabase": supabaseConfig,
103+
},
104+
}, "", " ")
105+
103106
fmt.Println()
104107
fmt.Printf("✓ Successfully configured Cursor at: %s\n", configPath)
105108
fmt.Println()
106109
fmt.Println("Configuration added:")
107-
fmt.Println(`{
108-
"mcpServers": {
109-
"supabase": {
110-
"url": "http://localhost:54321/mcp"
111-
}
112-
}
113-
}`)
110+
fmt.Println(string(configExample))
111+
fmt.Println()
112+
fmt.Println("Next steps:")
113+
fmt.Println(" 1. Open Cursor")
114+
fmt.Println(" 2. Navigate to Cursor Settings > Tools & MCP")
115+
fmt.Println(" 3. Enable the 'supabase' MCP server")
114116
fmt.Println()
115-
fmt.Println("The Supabase MCP server is now available in Cursor!")
117+
fmt.Println("The Supabase MCP server will then be available in Cursor!")
116118
return nil
117119
}

internal/mcp/init/vscode.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,18 @@ func (c *vscodeClient) Configure(ctx context.Context, fsys afero.Fs) error {
106106
return fmt.Errorf("failed to write config file: %w", err)
107107
}
108108

109+
// Generate example for display
110+
configExample, _ := json.MarshalIndent(map[string]interface{}{
111+
"servers": map[string]interface{}{
112+
"supabase": supabaseConfig,
113+
},
114+
}, "", " ")
115+
109116
fmt.Println()
110117
fmt.Printf("✓ Successfully configured VS Code at: %s\n", configPath)
111118
fmt.Println()
112119
fmt.Println("Configuration added:")
113-
fmt.Println(`{
114-
"servers": {
115-
"supabase": {
116-
"type": "http",
117-
"url": "http://localhost:54321/mcp"
118-
}
119-
}
120-
}`)
120+
fmt.Println(string(configExample))
121121
fmt.Println()
122122
fmt.Println("The Supabase MCP server is now available in VS Code!")
123123
return nil

0 commit comments

Comments
 (0)