|
| 1 | +# Direct MCP Management Commands |
| 2 | + |
| 3 | +This article covers the direct MCP management commands for removing servers and host configurations: |
| 4 | + |
| 5 | +- Server removal from specific hosts |
| 6 | +- Complete host configuration removal |
| 7 | +- Multi-host operations and batch processing |
| 8 | +- Dry-run functionality for safe testing |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +The direct MCP management commands provide precise control over MCP server configurations across different hosts. These commands follow the object-action pattern for clarity and consistency. |
| 13 | + |
| 14 | +## Server Removal |
| 15 | + |
| 16 | +### Remove Server from Specific Hosts |
| 17 | + |
| 18 | +Remove an MCP server from one or more hosts while preserving other servers: |
| 19 | + |
| 20 | +```bash |
| 21 | +# Remove from single host |
| 22 | +hatch mcp remove server <server-name> --host <host-name> |
| 23 | + |
| 24 | +# Remove from multiple hosts |
| 25 | +hatch mcp remove server <server-name> --host <host1>,<host2>,<host3> |
| 26 | + |
| 27 | +# Remove from all configured hosts |
| 28 | +hatch mcp remove server <server-name> --host all |
| 29 | +``` |
| 30 | + |
| 31 | +### Examples |
| 32 | + |
| 33 | +```bash |
| 34 | +# Remove 'filesystem-server' from Claude Desktop |
| 35 | +hatch mcp remove server filesystem-server --host claude-desktop |
| 36 | + |
| 37 | +# Remove 'database-server' from multiple hosts |
| 38 | +hatch mcp remove server database-server --host claude-desktop,cursor |
| 39 | + |
| 40 | +# Remove 'old-server' from all hosts |
| 41 | +hatch mcp remove server old-server --host all |
| 42 | +``` |
| 43 | + |
| 44 | +### Options |
| 45 | + |
| 46 | +- `--host <hosts>`: Comma-separated list of host names or 'all' |
| 47 | +- `--no-backup`: Skip backup creation before removal |
| 48 | +- `--dry-run`: Preview changes without executing them |
| 49 | +- `--auto-approve`: Skip confirmation prompts |
| 50 | + |
| 51 | +## Host Configuration Removal |
| 52 | + |
| 53 | +### Remove Complete Host Configuration |
| 54 | + |
| 55 | +Remove all MCP servers and configuration for a specific host: |
| 56 | + |
| 57 | +```bash |
| 58 | +hatch mcp remove host <host-name> |
| 59 | +``` |
| 60 | + |
| 61 | +This command removes the entire configuration file for the specified host, effectively removing all MCP servers configured for that host. |
| 62 | + |
| 63 | +### Examples |
| 64 | + |
| 65 | +```bash |
| 66 | +# Remove all MCP configuration for Claude Desktop |
| 67 | +hatch mcp remove host claude-desktop |
| 68 | + |
| 69 | +# Remove Cursor configuration with automatic approval |
| 70 | +hatch mcp remove host cursor --auto-approve |
| 71 | +``` |
| 72 | + |
| 73 | +### Options |
| 74 | + |
| 75 | +- `--no-backup`: Skip backup creation before removal |
| 76 | +- `--dry-run`: Preview changes without executing them |
| 77 | +- `--auto-approve`: Skip confirmation prompts |
| 78 | + |
| 79 | +## Multi-Host Operations |
| 80 | + |
| 81 | +### Host Specification |
| 82 | + |
| 83 | +The `--host` parameter accepts several formats: |
| 84 | + |
| 85 | +- **Single host**: `claude-desktop` |
| 86 | +- **Multiple hosts**: `claude-desktop,cursor,vscode` |
| 87 | +- **All hosts**: `all` (targets all detected hosts) |
| 88 | + |
| 89 | +### Host Validation |
| 90 | + |
| 91 | +The system validates host names against available MCP host types: |
| 92 | +- `claude-desktop` |
| 93 | +- `cursor` |
| 94 | +- `vscode` |
| 95 | +- Additional hosts as configured |
| 96 | + |
| 97 | +Invalid host names will result in an error with available options listed. |
| 98 | + |
| 99 | +## Safety Features |
| 100 | + |
| 101 | +### Backup Creation |
| 102 | + |
| 103 | +By default, all removal operations create backups before making changes: |
| 104 | + |
| 105 | +```bash |
| 106 | +# Backup created automatically |
| 107 | +hatch mcp remove server test-server --host claude-desktop |
| 108 | +# Output: Backup created: ~/.hatch/mcp_backups/claude-desktop_20231201_143022.json |
| 109 | +``` |
| 110 | + |
| 111 | +Skip backup creation with `--no-backup`: |
| 112 | + |
| 113 | +```bash |
| 114 | +hatch mcp remove server test-server --host claude-desktop --no-backup |
| 115 | +``` |
| 116 | + |
| 117 | +### Dry-Run Mode |
| 118 | + |
| 119 | +Test commands safely with `--dry-run`: |
| 120 | + |
| 121 | +```bash |
| 122 | +# Preview server removal |
| 123 | +hatch mcp remove server test-server --host claude-desktop --dry-run |
| 124 | +# Output: [DRY RUN] Would remove MCP server 'test-server' from hosts: claude-desktop |
| 125 | + |
| 126 | +# Preview host removal |
| 127 | +hatch mcp remove host claude-desktop --dry-run |
| 128 | +# Output: [DRY RUN] Would remove entire host configuration for 'claude-desktop' |
| 129 | +``` |
| 130 | + |
| 131 | +### Confirmation Prompts |
| 132 | + |
| 133 | +Interactive confirmation for destructive operations: |
| 134 | + |
| 135 | +```bash |
| 136 | +hatch mcp remove host claude-desktop |
| 137 | +# Output: This will remove ALL MCP servers from 'claude-desktop'. Continue? [y/N] |
| 138 | +``` |
| 139 | + |
| 140 | +Skip prompts with `--auto-approve`: |
| 141 | + |
| 142 | +```bash |
| 143 | +hatch mcp remove host claude-desktop --auto-approve |
| 144 | +``` |
| 145 | + |
| 146 | +## Error Handling |
| 147 | + |
| 148 | +### Server Not Found |
| 149 | + |
| 150 | +When attempting to remove a non-existent server: |
| 151 | + |
| 152 | +```bash |
| 153 | +hatch mcp remove server nonexistent-server --host claude-desktop |
| 154 | +# Output: [ERROR] Failed to remove 'nonexistent-server' from 'claude-desktop': Server not found |
| 155 | +``` |
| 156 | + |
| 157 | +### Invalid Host |
| 158 | + |
| 159 | +When specifying an invalid host: |
| 160 | + |
| 161 | +```bash |
| 162 | +hatch mcp remove server test-server --host invalid-host |
| 163 | +# Output: Error: Invalid host 'invalid-host'. Available: claude-desktop, cursor, vscode |
| 164 | +``` |
| 165 | + |
| 166 | +### Missing Configuration |
| 167 | + |
| 168 | +When no configuration exists for a host: |
| 169 | + |
| 170 | +```bash |
| 171 | +hatch mcp remove host unconfigured-host |
| 172 | +# Output: No configuration file to remove for 'unconfigured-host' |
| 173 | +``` |
| 174 | + |
| 175 | +## Best Practices |
| 176 | + |
| 177 | +### Before Removal |
| 178 | + |
| 179 | +1. **List current configuration**: Use `hatch mcp list servers` to see what's configured |
| 180 | +2. **Test with dry-run**: Always test with `--dry-run` first |
| 181 | +3. **Verify host names**: Ensure correct host specification |
| 182 | + |
| 183 | +### During Removal |
| 184 | + |
| 185 | +1. **Use specific hosts**: Prefer explicit host names over 'all' for precision |
| 186 | +2. **Keep backups**: Only use `--no-backup` when certain |
| 187 | +3. **Batch operations**: Remove from multiple hosts in single command when appropriate |
| 188 | + |
| 189 | +### After Removal |
| 190 | + |
| 191 | +1. **Verify removal**: Check configuration with `hatch mcp list servers` |
| 192 | +2. **Test functionality**: Ensure remaining servers work correctly |
| 193 | +3. **Clean up backups**: Manage backup files as needed |
| 194 | + |
| 195 | +## Related Commands |
| 196 | + |
| 197 | +- [`hatch mcp list`](./listing_commands.md): View current MCP configurations |
| 198 | +- [`hatch mcp configure`](./configuration_commands.md): Add or modify MCP servers |
| 199 | +- [`hatch mcp backup`](./backup_commands.md): Manage configuration backups |
| 200 | + |
| 201 | +## Troubleshooting |
| 202 | + |
| 203 | +### Permission Issues |
| 204 | + |
| 205 | +Ensure proper file permissions for configuration directories and backup locations. |
| 206 | + |
| 207 | +### Configuration Corruption |
| 208 | + |
| 209 | +If configuration becomes corrupted, use backup restoration: |
| 210 | + |
| 211 | +```bash |
| 212 | +hatch mcp backup restore <backup-file> --host <host-name> |
| 213 | +``` |
| 214 | + |
| 215 | +### Multiple Host Failures |
| 216 | + |
| 217 | +When removing from multiple hosts, check individual host status if some operations fail. |
0 commit comments