|
15 | 15 | console = Console() |
16 | 16 |
|
17 | 17 | @click.command() |
18 | | -@click.option("--edit", is_flag=True, help="Open the active client's config in default editor") |
19 | | -@click.option("--create", is_flag=True, help="Create a basic config file if it doesn't exist") |
20 | | -def edit(edit, create): |
| 18 | +def edit(): |
21 | 19 | """View or edit the active MCP client's configuration file. |
22 | 20 | |
23 | 21 | The edit command operates on the currently active MCP client (set via 'mcpm client'). |
24 | 22 | By default, this is Claude Desktop, but can be changed to other supported clients. |
25 | 23 | |
| 24 | + The command will automatically display the config file content when it exists, |
| 25 | + and offer to create it when it doesn't exist. You'll also be prompted if you |
| 26 | + want to open the file in your default editor. |
| 27 | + |
26 | 28 | Examples: |
27 | | - mcpm edit # Show current client's config file location and content |
28 | | - mcpm edit --edit # Open the config file in your default editor |
29 | | - mcpm edit --create # Create a basic config file if it doesn't exist |
| 29 | + mcpm edit # Show current client's config file and offer to edit it |
30 | 30 | """ |
31 | 31 | # Get the active client manager and related information |
32 | 32 | client_manager = ClientRegistry.get_active_client_manager() |
@@ -55,8 +55,8 @@ def edit(edit, create): |
55 | 55 | console.print(f"[bold]{client_name} config file:[/] {config_path}") |
56 | 56 | console.print(f"[bold]Status:[/] {'[green]Exists[/]' if config_exists else '[yellow]Does not exist[/]'}\n") |
57 | 57 |
|
58 | | - # Create config file if requested and it doesn't exist |
59 | | - if not config_exists and create: |
| 58 | + # Create config file if it doesn't exist and user confirms |
| 59 | + if not config_exists: |
60 | 60 | console.print(f"[bold yellow]Creating new {client_name} config file...[/]") |
61 | 61 |
|
62 | 62 | # Create a basic config template |
@@ -136,31 +136,10 @@ def edit(edit, create): |
136 | 136 | except Exception as e: |
137 | 137 | console.print(f"[bold red]Error reading config file:[/] {str(e)}") |
138 | 138 |
|
139 | | - # Prompt to edit if file exists, or if we need to create it |
140 | | - should_edit = edit |
141 | | - if not should_edit and config_exists: |
| 139 | + # Prompt to edit if file exists |
| 140 | + should_edit = False |
| 141 | + if config_exists: |
142 | 142 | should_edit = Confirm.ask("Would you like to open this file in your default editor?") |
143 | | - elif not config_exists and not create: |
144 | | - should_create = Confirm.ask("Config file doesn't exist. Would you like to create it?") |
145 | | - if should_create: |
146 | | - # Create a basic config template |
147 | | - basic_config = { |
148 | | - "mcpServers": {} |
149 | | - } |
150 | | - |
151 | | - # Create the directory if it doesn't exist |
152 | | - os.makedirs(os.path.dirname(config_path), exist_ok=True) |
153 | | - |
154 | | - # Write the template to file |
155 | | - try: |
156 | | - with open(config_path, 'w') as f: |
157 | | - json.dump(basic_config, f, indent=2) |
158 | | - console.print("[green]Successfully created config file![/]") |
159 | | - should_edit = Confirm.ask("Would you like to open it in your default editor?") |
160 | | - config_exists = True |
161 | | - except Exception as e: |
162 | | - console.print(f"[bold red]Error creating config file:[/] {str(e)}") |
163 | | - return |
164 | 143 |
|
165 | 144 | # Open in default editor if requested |
166 | 145 | if should_edit and config_exists: |
|
0 commit comments