Skip to content

Commit fd2c290

Browse files
refactor(cli): remove legacy mcp show <host> command
1 parent e6df7b4 commit fd2c290

File tree

1 file changed

+0
-140
lines changed

1 file changed

+0
-140
lines changed

hatch/cli/cli_mcp.py

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -493,146 +493,6 @@ def handle_mcp_list_servers(args: Namespace) -> int:
493493
return EXIT_ERROR
494494

495495

496-
def handle_mcp_show(args: Namespace) -> int:
497-
"""Handle 'hatch mcp show' command.
498-
499-
Displays detailed hierarchical view of a specific MCP host configuration.
500-
501-
Args:
502-
args: Parsed command-line arguments containing:
503-
- host: Host platform to show (e.g., claude-desktop, cursor)
504-
505-
Returns:
506-
int: EXIT_SUCCESS (0) on success, EXIT_ERROR (1) on failure
507-
508-
Reference: R02 §2.6 (02-list_output_format_specification_v2.md)
509-
"""
510-
try:
511-
# Import strategies to trigger registration
512-
import hatch.mcp_host_config.strategies
513-
from hatch.mcp_host_config.backup import MCPHostConfigBackupManager
514-
import os
515-
516-
host: str = args.host
517-
518-
# Validate host type
519-
try:
520-
host_type = MCPHostType(host)
521-
except ValueError:
522-
print(
523-
f"Error: Invalid host '{host}'. Supported hosts: {[h.value for h in MCPHostType]}"
524-
)
525-
return EXIT_ERROR
526-
527-
# Get host strategy and configuration
528-
strategy = MCPHostRegistry.get_strategy(host_type)
529-
config_path = strategy.get_config_path()
530-
531-
# Header
532-
print(f"MCP Host: {host}")
533-
print(f" Config Path: {config_path or 'N/A'}")
534-
535-
# Last modified timestamp
536-
if config_path and config_path.exists():
537-
import datetime
538-
mtime = os.path.getmtime(config_path)
539-
last_modified = datetime.datetime.fromtimestamp(mtime).strftime("%Y-%m-%d %H:%M:%S")
540-
print(f" Last Modified: {last_modified}")
541-
else:
542-
print(f" Last Modified: N/A (config not found)")
543-
544-
# Backup info
545-
backup_manager = MCPHostConfigBackupManager()
546-
backups = backup_manager.list_backups(host)
547-
if backups:
548-
print(f" Backup Available: Yes ({len(backups)} backups)")
549-
else:
550-
print(f" Backup Available: No")
551-
print()
552-
553-
# Read current configuration
554-
try:
555-
host_config = strategy.read_configuration()
556-
servers = host_config.servers
557-
except Exception:
558-
servers = {}
559-
560-
# Configured Servers section
561-
server_count = len(servers) if servers else 0
562-
print(f" Configured Servers ({server_count}):")
563-
564-
if servers:
565-
# Get environment manager to check Hatch management status
566-
env_manager: HatchEnvironmentManager = getattr(args, 'env_manager', None)
567-
568-
for server_name, server_config in servers.items():
569-
# Check if Hatch-managed
570-
hatch_env = None
571-
pkg_version = None
572-
last_synced = None
573-
574-
if env_manager:
575-
# Search all environments for this server
576-
for env_name in env_manager.list_environments():
577-
env_data = env_manager.get_environment_data(env_name.get("name", env_name) if isinstance(env_name, dict) else env_name)
578-
for pkg in env_data.get("packages", []):
579-
if pkg.get("name") == server_name:
580-
configured_hosts = pkg.get("configured_hosts", {})
581-
if host in configured_hosts:
582-
hatch_env = env_name.get("name", env_name) if isinstance(env_name, dict) else env_name
583-
pkg_version = pkg.get("version", "unknown")
584-
last_synced = configured_hosts[host].get("configured_at", "N/A")
585-
break
586-
if hatch_env:
587-
break
588-
589-
# Server header
590-
if hatch_env:
591-
print(f" {server_name} (Hatch-managed: {hatch_env})")
592-
else:
593-
print(f" {server_name} (Not Hatch-managed)")
594-
595-
# Command and args
596-
command = getattr(server_config, 'command', None)
597-
if command:
598-
print(f" Command: {command}")
599-
600-
cmd_args = getattr(server_config, 'args', None)
601-
if cmd_args:
602-
print(f" Args: {cmd_args}")
603-
604-
# URL for remote servers
605-
url = getattr(server_config, 'url', None)
606-
if url:
607-
print(f" URL: {url}")
608-
609-
# Environment variables (hide sensitive values)
610-
env_vars = getattr(server_config, 'env', None)
611-
if env_vars:
612-
print(f" Environment Variables:")
613-
for key, value in env_vars.items():
614-
# Hide sensitive values
615-
if any(sensitive in key.upper() for sensitive in ['KEY', 'SECRET', 'TOKEN', 'PASSWORD', 'CREDENTIAL']):
616-
print(f" {key}: ****** (hidden)")
617-
else:
618-
print(f" {key}: {value}")
619-
620-
# Hatch-specific info
621-
if hatch_env:
622-
if last_synced:
623-
print(f" Last Synced: {last_synced}")
624-
if pkg_version:
625-
print(f" Package Version: {pkg_version}")
626-
627-
print()
628-
else:
629-
print(" (none)")
630-
631-
return EXIT_SUCCESS
632-
except Exception as e:
633-
print(f"Error showing host configuration: {e}")
634-
return EXIT_ERROR
635-
636496

637497
def handle_mcp_show_hosts(args: Namespace) -> int:
638498
"""Handle 'hatch mcp show hosts' command.

0 commit comments

Comments
 (0)