Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
acd63f6
feat(039): connect clients API + hub dashboard redesign
claude Mar 29, 2026
2b81d02
fix: pre-release QA fixes — security, UX, macOS tray app
claude Mar 30, 2026
a78e80f
feat(040): Add/Edit Server UX improvements — PATCH endpoint, editable…
claude Mar 30, 2026
5ab9be5
fix(040): Cmd+N from Dashboard + Add Server tab selection fixes
claude Mar 30, 2026
10760a2
fix(040): show server logs in Add Server error instead of generic tim…
claude Mar 30, 2026
192f26c
fix(040): TCP fallback for Add Server when socket POST times out
claude Mar 30, 2026
bdac295
fix(040): root cause fix for socket POST timeout — read httpBodyStream
claude Mar 30, 2026
ef7ee5b
fix(040): socket POST body, quarantine as success, default Manual tab
claude Mar 30, 2026
f85894d
feat(040): quarantined servers auto-connect for tool review + docker …
claude Mar 30, 2026
bd52127
fix(040): proper connection status polling + handle 409 on retry
claude Mar 30, 2026
dce5fd1
fix(040): Retry deletes old server before re-adding with updated params
claude Mar 30, 2026
716e10a
fix(040): approve tools, duplicate name, approve button, tray menu na…
claude Mar 30, 2026
ca05bf7
fix(040): crash fix — MainActor.run for UI operations in handleAttent…
claude Mar 30, 2026
b268164
fix(040): socket fd double-close crash + tool loading debug + reload …
claude Mar 30, 2026
76d1841
fix(040): visual refresh after approve/quarantine + re-quarantine button
claude Mar 30, 2026
3cb9a4f
chore: regenerate OpenAPI spec after PATCH endpoint addition
claude Mar 30, 2026
1172ef7
chore: remove QA report HTML from repo
claude Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 280 additions & 0 deletions cmd/mcpproxy/connect_cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
package main

import (
"fmt"
"strings"

"github.com/spf13/cobra"

clioutput "github.com/smart-mcp-proxy/mcpproxy-go/internal/cli/output"
"github.com/smart-mcp-proxy/mcpproxy-go/internal/config"
"github.com/smart-mcp-proxy/mcpproxy-go/internal/connect"
)

var (
connectList bool
connectAll bool
connectForce bool
connectServerName string
)

// GetConnectCommand returns the connect parent command.
func GetConnectCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "connect [client]",
Short: "Register MCPProxy in a client's MCP configuration",
Long: `Register MCPProxy as an MCP server in the configuration file of supported
AI coding clients. This modifies the client's config file to add an HTTP/SSE
entry pointing to the running MCPProxy instance.

Supported clients: claude-code, cursor, windsurf, vscode, codex, gemini

A backup of the original config file is created before any modification.

Examples:
mcpproxy connect --list # Show all clients and their status
mcpproxy connect claude-code # Register in Claude Code
mcpproxy connect cursor --force # Overwrite existing entry
mcpproxy connect codex --name my-proxy # Custom server name
mcpproxy connect --all # Register in all supported clients`,
Args: cobra.MaximumNArgs(1),
RunE: runConnect,
}

cmd.Flags().BoolVar(&connectList, "list", false, "List all clients and their connection status")
cmd.Flags().BoolVar(&connectAll, "all", false, "Connect to all supported clients")
cmd.Flags().BoolVar(&connectForce, "force", false, "Overwrite existing entry")
cmd.Flags().StringVar(&connectServerName, "name", "", "Server name in client config (default: mcpproxy)")

return cmd
}

// GetDisconnectCommand returns the disconnect command.
func GetDisconnectCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "disconnect <client>",
Short: "Remove MCPProxy from a client's MCP configuration",
Long: `Remove the MCPProxy entry from the specified client's configuration file.
A backup of the original config file is created before any modification.

Examples:
mcpproxy disconnect claude-code
mcpproxy disconnect cursor --name my-proxy`,
Args: cobra.ExactArgs(1),
RunE: runDisconnect,
}

cmd.Flags().StringVar(&connectServerName, "name", "", "Server name to remove (default: mcpproxy)")

return cmd
}

func runConnect(cmd *cobra.Command, args []string) error {
cfg, err := loadConnectConfig()
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
}

svc := connect.NewService(cfg.Listen, cfg.APIKey)

format := clioutput.ResolveFormat(globalOutputFormat, globalJSONOutput)
formatter, err := clioutput.NewFormatter(format)
if err != nil {
return err
}

// --list mode
if connectList {
return printConnectStatus(svc, formatter, format)
}

// --all mode
if connectAll {
return connectAllClients(svc, formatter, format)
}

// Single client mode
if len(args) == 0 {
return fmt.Errorf("client ID is required (or use --list / --all)")
}

clientID := args[0]
result, err := svc.Connect(clientID, connectServerName, connectForce)
if err != nil {
return err
}

return printConnectResult(result, formatter, format)
}

func runDisconnect(cmd *cobra.Command, args []string) error {
cfg, err := loadConnectConfig()
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
}

svc := connect.NewService(cfg.Listen, cfg.APIKey)

format := clioutput.ResolveFormat(globalOutputFormat, globalJSONOutput)
formatter, err := clioutput.NewFormatter(format)
if err != nil {
return err
}

clientID := args[0]
result, err := svc.Disconnect(clientID, connectServerName)
if err != nil {
return err
}

return printConnectResult(result, formatter, format)
}

func printConnectStatus(svc *connect.Service, formatter clioutput.OutputFormatter, format string) error {
statuses := svc.GetAllStatus()

if format == "table" {
headers := []string{"CLIENT", "STATUS", "CONFIG PATH", "CONNECTED"}
var rows [][]string
for _, s := range statuses {
status := "supported"
if !s.Supported {
status = "unsupported"
}

connected := "-"
if s.Supported {
if s.Connected {
connected = "yes"
} else if s.Exists {
connected = "no"
} else {
connected = "no (no config)"
}
}

cfgPath := s.ConfigPath
if len(cfgPath) > 50 {
cfgPath = "..." + cfgPath[len(cfgPath)-47:]
}

rows = append(rows, []string{s.Name, status, cfgPath, connected})
}
out, err := formatter.FormatTable(headers, rows)
if err != nil {
return err
}
fmt.Print(out)
return nil
}

// JSON or YAML
out, err := formatter.Format(statuses)
if err != nil {
return err
}
fmt.Println(out)
return nil
}

func connectAllClients(svc *connect.Service, formatter clioutput.OutputFormatter, format string) error {
clients := connect.GetAllClients()
var results []*connect.ConnectResult
var errors []string

for _, c := range clients {
if !c.Supported {
continue
}
result, err := svc.Connect(c.ID, connectServerName, connectForce)
if err != nil {
errors = append(errors, fmt.Sprintf("%s: %v", c.Name, err))
continue
}
results = append(results, result)
}

if format == "table" {
headers := []string{"CLIENT", "ACTION", "MESSAGE"}
var rows [][]string
for _, r := range results {
client := connect.FindClient(r.Client)
name := r.Client
if client != nil {
name = client.Name
}
rows = append(rows, []string{name, r.Action, r.Message})
}
for _, e := range errors {
parts := strings.SplitN(e, ": ", 2)
msg := e
clientName := "unknown"
if len(parts) == 2 {
clientName = parts[0]
msg = parts[1]
}
rows = append(rows, []string{clientName, "error", msg})
}
out, err := formatter.FormatTable(headers, rows)
if err != nil {
return err
}
fmt.Print(out)
return nil
}

// JSON/YAML output
out, err := formatter.Format(map[string]interface{}{
"results": results,
"errors": errors,
})
if err != nil {
return err
}
fmt.Println(out)
return nil
}

func printConnectResult(result *connect.ConnectResult, formatter clioutput.OutputFormatter, format string) error {
if format == "table" {
if result.Success {
fmt.Printf("%s\n", result.Message)
if result.BackupPath != "" {
fmt.Printf("Backup: %s\n", result.BackupPath)
}
fmt.Printf("Config: %s\n", result.ConfigPath)
} else {
fmt.Printf("Failed: %s\n", result.Message)
}
return nil
}

// JSON/YAML
out, err := formatter.Format(result)
if err != nil {
return err
}
fmt.Println(out)
return nil
}

func loadConnectConfig() (*config.Config, error) {
if configFile != "" {
cfg, err := config.LoadFromFile(configFile)
if err != nil {
return nil, err
}
if dataDir != "" {
cfg.DataDir = dataDir
}
return cfg, nil
}
cfg, err := config.Load()
if err != nil {
return nil, err
}
if dataDir != "" {
cfg.DataDir = dataDir
}
return cfg, nil
}
6 changes: 6 additions & 0 deletions cmd/mcpproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ func main() {
// Add feedback command (Spec 036)
feedbackCmd := GetFeedbackCommand()

// Add connect/disconnect commands
connectCmd := GetConnectCommand()
disconnectCmd := GetDisconnectCommand()

// Add commands to root
rootCmd.AddCommand(serverCmd)
rootCmd.AddCommand(searchCmd)
Expand All @@ -195,6 +199,8 @@ func main() {
rootCmd.AddCommand(tokenCmd)
rootCmd.AddCommand(telemetryCmd)
rootCmd.AddCommand(feedbackCmd)
rootCmd.AddCommand(connectCmd)
rootCmd.AddCommand(disconnectCmd)

// Setup --help-json for machine-readable help discovery
// This must be called AFTER all commands are added
Expand Down
24 changes: 2 additions & 22 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

<!-- Page content -->
<main class="overflow-y-auto p-6">
<router-view v-slot="{ Component }">
<transition name="page" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
<router-view />
</main>
</div>

Expand Down Expand Up @@ -125,20 +121,4 @@ onUnmounted(() => {
})
</script>

<style scoped>
/* Page transitions */
.page-enter-active,
.page-leave-active {
transition: all 0.3s ease;
}

.page-enter-from {
opacity: 0;
transform: translateX(10px);
}

.page-leave-to {
opacity: 0;
transform: translateX(-10px);
}
</style>
<!-- Page transitions removed: caused CSS transition deadlock blocking SPA navigation (QA 2026-03-29) -->
Loading
Loading