• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 19194338182

08 Nov 2025 02:29PM UTC coverage: 53.056% (-1.6%) from 54.689%
19194338182

Pull #4383

github

web-flow
Merge a898faa1b into af2b11bea
Pull Request #4383: feat(mcp): add `supabase mcp init` command to configure MCP clients

0 of 355 new or added lines in 9 files covered. (0.0%)

5 existing lines in 1 file now uncovered.

6388 of 12040 relevant lines covered (53.06%)

5.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/mcp/init/init.go
1
package mcpinit
2

3
import (
4
        "context"
5
        "fmt"
6

7
        tea "github.com/charmbracelet/bubbletea"
8
        "github.com/spf13/afero"
9
        "github.com/supabase/cli/internal/utils"
10
)
11

12
// clientRegistry holds all supported clients
13
var clientRegistry = []Client{
14
        newClaudeCodeClient(),
15
        newCursorClient(),
16
        newVSCodeClient(),
17
}
18

19
// PromptMCPClient prompts the user to select an MCP client from the available options
NEW
20
func PromptMCPClient(ctx context.Context, opts ...tea.ProgramOption) (string, error) {
×
NEW
21
        // Add all clients plus "Other" option
×
NEW
22
        items := make([]utils.PromptItem, len(clientRegistry)+1)
×
NEW
23
        for i, client := range clientRegistry {
×
NEW
24
                items[i] = utils.PromptItem{
×
NEW
25
                        Summary: client.Name(),
×
NEW
26
                        Details: client.DisplayName(),
×
NEW
27
                }
×
NEW
28
        }
×
29
        // Add "Other" option at the end
NEW
30
        items[len(clientRegistry)] = utils.PromptItem{
×
NEW
31
                Summary: "other",
×
NEW
32
                Details: "Configure it manually",
×
NEW
33
        }
×
NEW
34

×
NEW
35
        choice, err := utils.PromptChoice(ctx, "Which client do you want to configure?", items, opts...)
×
NEW
36
        if err != nil {
×
NEW
37
                return "", err
×
NEW
38
        }
×
39

NEW
40
        return choice.Summary, nil
×
41
}
42

NEW
43
func Run(ctx context.Context, fsys afero.Fs, clientFlag string) error {
×
NEW
44
        // If a specific client is requested
×
NEW
45
        if clientFlag != "" {
×
NEW
46
                return configureSpecificClient(ctx, fsys, clientFlag)
×
NEW
47
        }
×
48

49
        // Find installed clients
NEW
50
        var installedClients []Client
×
NEW
51
        for _, client := range clientRegistry {
×
NEW
52
                if client.IsInstalled() {
×
NEW
53
                        installedClients = append(installedClients, client)
×
NEW
54
                }
×
55
        }
56

57
        // If no clients installed, show available options
NEW
58
        if len(installedClients) == 0 {
×
NEW
59
                fmt.Println("No MCP clients detected on this system.")
×
NEW
60
                fmt.Println()
×
NEW
61
                fmt.Println("Available clients:")
×
NEW
62
                for _, client := range clientRegistry {
×
NEW
63
                        fmt.Printf("  • %s\n", client.DisplayName())
×
NEW
64
                        fmt.Printf("    Install: %s\n", client.InstallInstructions())
×
NEW
65
                        fmt.Println()
×
NEW
66
                }
×
NEW
67
                fmt.Println("After installing a client, run this command again.")
×
NEW
68
                return nil
×
69
        }
70

71
        // If only one client is installed, configure it directly
NEW
72
        if len(installedClients) == 1 {
×
NEW
73
                client := installedClients[0]
×
NEW
74
                fmt.Printf("Detected %s\n", client.DisplayName())
×
NEW
75
                fmt.Println()
×
NEW
76
                return client.Configure(ctx, fsys)
×
NEW
77
        }
×
78

79
        // Multiple clients installed - show options
NEW
80
        fmt.Println("Multiple MCP clients detected:")
×
NEW
81
        for i, client := range installedClients {
×
NEW
82
                fmt.Printf("  %d. %s\n", i+1, client.DisplayName())
×
NEW
83
        }
×
NEW
84
        fmt.Println()
×
NEW
85
        fmt.Println("Use the --client flag to configure a specific client:")
×
NEW
86
        for _, client := range installedClients {
×
NEW
87
                fmt.Printf("  supabase mcp init --client %s\n", client.Name())
×
NEW
88
        }
×
89

NEW
90
        return nil
×
91
}
92

NEW
93
func configureSpecificClient(ctx context.Context, fsys afero.Fs, clientName string) error {
×
NEW
94
        // Find the requested client
×
NEW
95
        var targetClient Client
×
NEW
96
        for _, client := range clientRegistry {
×
NEW
97
                if client.Name() == clientName {
×
NEW
98
                        targetClient = client
×
NEW
99
                        break
×
100
                }
101
        }
102

NEW
103
        if targetClient == nil {
×
NEW
104
                fmt.Printf("❌ Unknown client: %s\n\n", clientName)
×
NEW
105
                fmt.Println("Supported clients:")
×
NEW
106
                for _, client := range clientRegistry {
×
NEW
107
                        fmt.Printf("  • %s\n", client.Name())
×
NEW
108
                }
×
NEW
109
                return fmt.Errorf("unknown client: %s", clientName)
×
110
        }
111

112
        // Check if installed
NEW
113
        if !targetClient.IsInstalled() {
×
NEW
114
                fmt.Printf("❌ %s is not installed on this system.\n\n", targetClient.DisplayName())
×
NEW
115
                fmt.Println("To install:")
×
NEW
116
                fmt.Printf("  %s\n", targetClient.InstallInstructions())
×
NEW
117
                return nil
×
NEW
118
        }
×
119

120
        // Configure
NEW
121
        fmt.Printf("Configuring %s...\n\n", targetClient.DisplayName())
×
NEW
122
        return targetClient.Configure(ctx, fsys)
×
123
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc