Skip to content

Commit 06eb53a

Browse files
fix(backup): support different config filenames in backup listing
Root cause: Backup listing pattern was hardcoded to 'mcp.json.{hostname}.*', but different hosts use different config filenames (Gemini uses settings.json, Codex uses config.toml). When backups were created with format '{original_filename}.{hostname}.{timestamp}', they couldn't be found by list_backups() method, leading to 'No backups found' error despite backups being created successfully. Solution: Updated backup listing pattern from hardcoded 'mcp.json.{hostname}.*' to flexible '*.{hostname}.*' pattern that matches any config filename. Also updated test expectations to reflect original filename preservation. Fixes #2 of 2: Backup listing not finding settings.json backups # Conflicts: # tests/test_mcp_host_config_backup.py
1 parent 5ccb7f9 commit 06eb53a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hatch/mcp_host_config/backup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,12 @@ def list_backups(self, hostname: str) -> List[BackupInfo]:
355355

356356
backups = []
357357

358-
# Search for both correct format and legacy incorrect format for backward compatibility
358+
# Search for backups with flexible filename matching
359+
# Different hosts use different config filenames (mcp.json, settings.json, config.toml)
360+
# Backup format: {original_filename}.{hostname}.{timestamp}
359361
patterns = [
360-
f"mcp.json.{hostname}.*", # Correct format: mcp.json.gemini.*
361-
f"mcp.json.MCPHostType.{hostname.upper()}.*" # Legacy incorrect format: mcp.json.MCPHostType.GEMINI.*
362+
f"*.{hostname}.*", # Flexible: settings.json.gemini.*, mcp.json.claude-desktop.*, etc.
363+
f"mcp.json.MCPHostType.{hostname.upper()}.*" # Legacy incorrect format for backward compatibility
362364
]
363365

364366
for pattern in patterns:

0 commit comments

Comments
 (0)