|
12 | 12 | console = Console() |
13 | 13 |
|
14 | 14 | @click.command(name="list") |
15 | | -@click.option("--available", is_flag=True, help="List all available MCP servers") |
16 | | -@click.option("--outdated", is_flag=True, help="List installed servers with updates available") |
17 | | -def list(available, outdated): |
| 15 | +def list(): |
18 | 16 | """List all installed MCP servers. |
19 | 17 | |
20 | 18 | Examples: |
21 | 19 | mcpm list |
22 | | - mcpm list --available |
23 | | - mcpm list --outdated |
24 | 20 | """ |
25 | | - if available: |
26 | | - console.print("[bold green]Available MCP servers:[/]") |
27 | | - |
28 | | - # Show available servers that can be installed |
29 | | - table = Table(show_header=True, header_style="bold") |
30 | | - table.add_column("Name") |
31 | | - table.add_column("Description") |
32 | | - table.add_column("Latest Version") |
33 | | - |
34 | | - # Example available servers (in a full implementation, this would come from a repository) |
35 | | - available_servers = [ |
36 | | - ("filesystem", "Access local files and directories", "1.0.0"), |
37 | | - ("browser", "Access web content through Claude", "0.9.2"), |
38 | | - ("code-interpreter", "Execute and interpret code", "0.7.1"), |
39 | | - ("shell", "Run shell commands from Claude", "0.8.5") |
40 | | - ] |
41 | | - |
42 | | - for name, desc, version in available_servers: |
43 | | - table.add_row(name, desc, version) |
44 | | - |
45 | | - console.print(table) |
46 | | - |
47 | | - elif outdated: |
48 | | - console.print("[bold yellow]Checking for outdated MCP servers...[/]") |
49 | | - |
50 | | - # Get the active client manager and information |
51 | | - client_manager = ClientRegistry.get_active_client_manager() |
52 | | - client = ClientRegistry.get_active_client() |
53 | | - client_info = ClientRegistry.get_client_info(client) |
54 | | - client_name = client_info.get("name", client) |
55 | | - |
56 | | - # Check if client is supported |
57 | | - if client_manager is None: |
58 | | - console.print("[bold red]Error:[/] Unsupported active client") |
59 | | - console.print("Please switch to a supported client using 'mcpm client <client-name>'") |
60 | | - return |
61 | | - |
62 | | - # Get servers from active client |
63 | | - servers = client_manager.get_servers() |
64 | | - |
65 | | - if not servers: |
66 | | - console.print(f"[yellow]No MCP servers found in {client_name}.[/]") |
67 | | - return |
68 | | - |
69 | | - # In a full implementation, this would check the repository for newer versions |
70 | | - # For now, just show installed servers with mock version information |
71 | | - |
72 | | - # Mock repository versions (would be fetched from a real repository in production) |
73 | | - repo_versions = { |
74 | | - "filesystem": "1.1.0", # Newer than installed |
75 | | - "browser": "0.9.2", # Same as installed |
76 | | - "shell": "0.8.5", # Same as installed |
77 | | - } |
78 | | - |
79 | | - # Check for outdated servers |
80 | | - outdated_servers = [] |
81 | | - for server_name in servers: |
82 | | - # Mock: filesystem has newer version available |
83 | | - if server_name == "filesystem": |
84 | | - outdated_servers.append({ |
85 | | - "name": server_name, |
86 | | - "installed": "1.0.0", |
87 | | - "latest": repo_versions.get(server_name, "unknown") |
88 | | - }) |
89 | | - |
90 | | - if outdated_servers: |
91 | | - table = Table(show_header=True, header_style="bold") |
92 | | - table.add_column("Name") |
93 | | - table.add_column("Installed Version") |
94 | | - table.add_column("Latest Version") |
95 | | - table.add_column("Status") |
96 | | - |
97 | | - for server in outdated_servers: |
98 | | - table.add_row( |
99 | | - server["name"], |
100 | | - server["installed"], |
101 | | - server["latest"], |
102 | | - "[yellow]Update available[/]" |
103 | | - ) |
| 21 | + # Get the active client manager and information |
| 22 | + client_manager = ClientRegistry.get_active_client_manager() |
| 23 | + client = ClientRegistry.get_active_client() |
| 24 | + client_info = ClientRegistry.get_client_info(client) |
| 25 | + client_name = client_info.get("name", client) |
| 26 | + |
| 27 | + # Check if client is supported |
| 28 | + if client_manager is None: |
| 29 | + console.print("[bold red]Error:[/] Unsupported active client") |
| 30 | + console.print("Please switch to a supported client using 'mcpm client <client-name>'") |
| 31 | + return |
| 32 | + |
| 33 | + console.print(f"[bold green]MCP servers installed in {client_name}:[/]") |
| 34 | + |
| 35 | + # Get all servers from active client config |
| 36 | + servers = client_manager.get_servers() |
| 37 | + |
| 38 | + if not servers: |
| 39 | + console.print(f"[yellow]No MCP servers found in {client_name}.[/]") |
| 40 | + console.print("Use 'mcpm add <server>' to add a server.") |
| 41 | + return |
| 42 | + |
| 43 | + # Count the configured servers |
| 44 | + server_count = len(servers) |
| 45 | + console.print(f"[bold]Configured servers:[/] {server_count}\n") |
| 46 | + |
| 47 | + # Display detailed information for each server |
| 48 | + for server_name, server_info in servers.items(): |
| 49 | + # Server name and command |
| 50 | + console.print(f"[bold cyan]{server_name}[/]") |
| 51 | + command = server_info.get("command", "N/A") |
| 52 | + console.print(f" Command: [green]{command}[/]") |
| 53 | + |
| 54 | + # Display arguments |
| 55 | + args = server_info.get("args", []) |
| 56 | + if args: |
| 57 | + console.print(" Arguments:") |
| 58 | + for i, arg in enumerate(args): |
| 59 | + console.print(f" {i}: [yellow]{escape(arg)}[/]") |
104 | 60 |
|
105 | | - console.print(table) |
| 61 | + # Get package name (usually the second argument) |
| 62 | + if len(args) > 1: |
| 63 | + console.print(f" Package: [magenta]{args[1]}[/]") |
| 64 | + |
| 65 | + # Display environment variables |
| 66 | + env_vars = server_info.get("env", {}) |
| 67 | + if env_vars: |
| 68 | + console.print(" Environment Variables:") |
| 69 | + for key, value in env_vars.items(): |
| 70 | + console.print(f" [bold blue]{key}[/] = [green]\"{value}\"[/]") |
106 | 71 | else: |
107 | | - console.print("[green]All MCP servers are up to date.[/]") |
108 | | - |
109 | | - else: |
110 | | - # Get the active client manager and information |
111 | | - client_manager = ClientRegistry.get_active_client_manager() |
112 | | - client = ClientRegistry.get_active_client() |
113 | | - client_info = ClientRegistry.get_client_info(client) |
114 | | - client_name = client_info.get("name", client) |
115 | | - |
116 | | - # Check if client is supported |
117 | | - if client_manager is None: |
118 | | - console.print("[bold red]Error:[/] Unsupported active client") |
119 | | - console.print("Please switch to a supported client using 'mcpm client <client-name>'") |
120 | | - return |
| 72 | + console.print(" Environment Variables: [italic]None[/]") |
121 | 73 |
|
122 | | - console.print(f"[bold green]MCP servers installed in {client_name}:[/]") |
123 | | - |
124 | | - # Get all servers from active client config |
125 | | - servers = client_manager.get_servers() |
126 | | - |
127 | | - if not servers: |
128 | | - console.print(f"[yellow]No MCP servers found in {client_name}.[/]") |
129 | | - console.print("Use 'mcpm add <server>' to add a server.") |
130 | | - return |
131 | | - |
132 | | - # Count the configured servers |
133 | | - server_count = len(servers) |
134 | | - console.print(f"[bold]Configured servers:[/] {server_count}\n") |
135 | | - |
136 | | - # Display detailed information for each server |
137 | | - for server_name, server_info in servers.items(): |
138 | | - # Server name and command |
139 | | - console.print(f"[bold cyan]{server_name}[/]") |
140 | | - command = server_info.get("command", "N/A") |
141 | | - console.print(f" Command: [green]{command}[/]") |
142 | | - |
143 | | - # Display arguments |
144 | | - args = server_info.get("args", []) |
145 | | - if args: |
146 | | - console.print(" Arguments:") |
147 | | - for i, arg in enumerate(args): |
148 | | - console.print(f" {i}: [yellow]{escape(arg)}[/]") |
149 | | - |
150 | | - # Get package name (usually the second argument) |
151 | | - if len(args) > 1: |
152 | | - console.print(f" Package: [magenta]{args[1]}[/]") |
153 | | - |
154 | | - # Display environment variables |
155 | | - env_vars = server_info.get("env", {}) |
156 | | - if env_vars: |
157 | | - console.print(" Environment Variables:") |
158 | | - for key, value in env_vars.items(): |
159 | | - console.print(f" [bold blue]{key}[/] = [green]\"{value}\"[/]") |
160 | | - else: |
161 | | - console.print(" Environment Variables: [italic]None[/]") |
162 | | - |
163 | | - # Add a separator line between servers |
164 | | - console.print(" " + "-" * 50) |
| 74 | + # Add a separator line between servers |
| 75 | + console.print(" " + "-" * 50) |
0 commit comments