()
| 67 | } |
| 68 | |
| 69 | func (*RootCmd) mcpConfigureClaudeDesktop() *serpent.Command { |
| 70 | cmd := &serpent.Command{ |
| 71 | Use: "claude-desktop", |
| 72 | Short: "Configure the Claude Desktop server.", |
| 73 | Handler: func(_ *serpent.Invocation) error { |
| 74 | configPath, err := os.UserConfigDir() |
| 75 | if err != nil { |
| 76 | return err |
| 77 | } |
| 78 | configPath = filepath.Join(configPath, "Claude") |
| 79 | err = os.MkdirAll(configPath, 0o755) |
| 80 | if err != nil { |
| 81 | return err |
| 82 | } |
| 83 | configPath = filepath.Join(configPath, "claude_desktop_config.json") |
| 84 | _, err = os.Stat(configPath) |
| 85 | if err != nil { |
| 86 | if !os.IsNotExist(err) { |
| 87 | return err |
| 88 | } |
| 89 | } |
| 90 | contents := map[string]any{} |
| 91 | data, err := os.ReadFile(configPath) |
| 92 | if err != nil { |
| 93 | if !os.IsNotExist(err) { |
| 94 | return err |
| 95 | } |
| 96 | } else { |
| 97 | err = json.Unmarshal(data, &contents) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | } |
| 102 | binPath, err := os.Executable() |
| 103 | if err != nil { |
| 104 | return err |
| 105 | } |
| 106 | contents["mcpServers"] = map[string]any{ |
| 107 | "coder": map[string]any{"command": binPath, "args": []string{"exp", "mcp", "server"}}, |
| 108 | } |
| 109 | data, err = json.MarshalIndent(contents, "", " ") |
| 110 | if err != nil { |
| 111 | return err |
| 112 | } |
| 113 | err = os.WriteFile(configPath, data, 0o600) |
| 114 | if err != nil { |
| 115 | return err |
| 116 | } |
| 117 | return nil |
| 118 | }, |
| 119 | } |
| 120 | return cmd |
| 121 | } |
| 122 | |
| 123 | func mcpConfigureClaudeCode() *serpent.Command { |
| 124 | var ( |
no test coverage detected