@@ -136,13 +136,28 @@ func (s *Syncer) CopyToRepo() error {
136136 if _ , err := os .Stat (authSrc ); err == nil {
137137 authDst := filepath .Join (s .paths .SyncRepoDir (), "auth.json.age" )
138138
139- // Encrypt auth.json before copying
140139 if err := s .encryption .EncryptFile (authSrc , authDst ); err != nil {
141140 return fmt .Errorf ("failed to encrypt auth.json: %w" , err )
142141 }
143142 }
144143 }
145144
145+ // Handle mcp-auth.json if enabled
146+ if s .cfg .Sync .IncludeMcpAuth {
147+ if s .encryption == nil {
148+ return fmt .Errorf ("includeMcpAuth requires encryption to be enabled" )
149+ }
150+
151+ mcpAuthSrc := s .paths .OpenCodeMcpAuthFile ()
152+ if _ , err := os .Stat (mcpAuthSrc ); err == nil {
153+ mcpAuthDst := filepath .Join (s .paths .SyncRepoDir (), "mcp-auth.json.age" )
154+
155+ if err := s .encryption .EncryptFile (mcpAuthSrc , mcpAuthDst ); err != nil {
156+ return fmt .Errorf ("failed to encrypt mcp-auth.json: %w" , err )
157+ }
158+ }
159+ }
160+
146161 return nil
147162}
148163
@@ -187,13 +202,26 @@ func (s *Syncer) CopyFromRepo() error {
187202
188203 dstPath = s .paths .OpenCodeAuthFile ()
189204
190- // Decrypt auth.json
191205 if err := s .encryption .DecryptFile (path , dstPath ); err != nil {
192206 return fmt .Errorf ("failed to decrypt auth.json: %w" , err )
193207 }
194208 return nil
195209 }
196210
211+ // Handle encrypted mcp-auth.json
212+ if relPath == "mcp-auth.json.age" && s .cfg .Sync .IncludeMcpAuth {
213+ if s .encryption == nil {
214+ return fmt .Errorf ("found encrypted mcp-auth.json but encryption is not enabled" )
215+ }
216+
217+ dstPath = s .paths .OpenCodeMcpAuthFile ()
218+
219+ if err := s .encryption .DecryptFile (path , dstPath ); err != nil {
220+ return fmt .Errorf ("failed to decrypt mcp-auth.json: %w" , err )
221+ }
222+ return nil
223+ }
224+
197225 // Copy file
198226 if err := s .copyFile (path , dstPath ); err != nil {
199227 return fmt .Errorf ("failed to copy %s: %w" , relPath , err )
0 commit comments