|
3 | 3 | """
|
4 | 4 |
|
5 | 5 | import os
|
| 6 | +import shlex |
6 | 7 | import subprocess
|
7 | 8 | import sys
|
8 | 9 | from typing import Any, Dict, Optional
|
@@ -80,7 +81,7 @@ def edit(server_name, new, editor):
|
80 | 81 |
|
81 | 82 | if isinstance(server_config, STDIOServerConfig):
|
82 | 83 | table.add_row("Command", server_config.command)
|
83 |
| - table.add_row("Arguments", ", ".join(server_config.args) if server_config.args else "[dim]None[/]") |
| 84 | + table.add_row("Arguments", " ".join(server_config.args) if server_config.args else "[dim]None[/]") |
84 | 85 | table.add_row(
|
85 | 86 | "Environment",
|
86 | 87 | ", ".join(f"{k}={v}" for k, v in server_config.env.items()) if server_config.env else "[dim]None[/]",
|
@@ -187,12 +188,12 @@ def interactive_server_edit(server_config) -> Optional[Dict[str, Any]]:
|
187 | 188 | keybindings={"interrupt": [{"key": "escape"}]},
|
188 | 189 | ).execute()
|
189 | 190 |
|
190 |
| - # Arguments as comma-separated string |
191 |
| - current_args = ", ".join(server_config.args) if server_config.args else "" |
| 191 | + # Arguments as space-separated string |
| 192 | + current_args = " ".join(server_config.args) if server_config.args else "" |
192 | 193 | answers["args"] = inquirer.text(
|
193 |
| - message="Arguments (comma-separated):", |
| 194 | + message="Arguments (space-separated, quotes supported):", |
194 | 195 | default=current_args,
|
195 |
| - instruction="(Leave empty for no arguments)", |
| 196 | + instruction="(Leave empty for no arguments, use quotes for args with spaces)", |
196 | 197 | keybindings={"interrupt": [{"key": "escape"}]},
|
197 | 198 | ).execute()
|
198 | 199 |
|
@@ -237,7 +238,7 @@ def interactive_server_edit(server_config) -> Optional[Dict[str, Any]]:
|
237 | 238 |
|
238 | 239 | if isinstance(server_config, STDIOServerConfig):
|
239 | 240 | console.print(f"Command: [cyan]{server_config.command}[/] → [cyan]{answers['command']}[/]")
|
240 |
| - new_args = [arg.strip() for arg in answers["args"].split(",") if arg.strip()] if answers["args"] else [] |
| 241 | + new_args = shlex.split(answers["args"]) if answers["args"] else [] |
241 | 242 | console.print(f"Arguments: [cyan]{server_config.args}[/] → [cyan]{new_args}[/]")
|
242 | 243 |
|
243 | 244 | new_env = {}
|
@@ -298,7 +299,7 @@ def apply_interactive_changes(server_config, interactive_result):
|
298 | 299 |
|
299 | 300 | # Parse arguments
|
300 | 301 | if answers["args"].strip():
|
301 |
| - server_config.args = [arg.strip() for arg in answers["args"].split(",") if arg.strip()] |
| 302 | + server_config.args = shlex.split(answers["args"]) |
302 | 303 | else:
|
303 | 304 | server_config.args = []
|
304 | 305 |
|
@@ -381,9 +382,7 @@ def _create_new_server():
|
381 | 382 | server_config = STDIOServerConfig(
|
382 | 383 | name=server_name,
|
383 | 384 | command=result["answers"]["command"],
|
384 |
| - args=[arg.strip() for arg in result["answers"]["args"].split(",") if arg.strip()] |
385 |
| - if result["answers"]["args"] |
386 |
| - else [], |
| 385 | + args=shlex.split(result["answers"]["args"]) if result["answers"]["args"] else [], |
387 | 386 | env={},
|
388 | 387 | )
|
389 | 388 |
|
@@ -462,8 +461,8 @@ def _interactive_new_server_form() -> Optional[Dict[str, Any]]:
|
462 | 461 | ).execute()
|
463 | 462 |
|
464 | 463 | answers["args"] = inquirer.text(
|
465 |
| - message="Arguments (comma-separated):", |
466 |
| - instruction="(Leave empty for no arguments)", |
| 464 | + message="Arguments (space-separated, quotes supported):", |
| 465 | + instruction="(Leave empty for no arguments, use quotes for args with spaces)", |
467 | 466 | keybindings={"interrupt": [{"key": "escape"}]},
|
468 | 467 | ).execute()
|
469 | 468 |
|
@@ -497,7 +496,7 @@ def _interactive_new_server_form() -> Optional[Dict[str, Any]]:
|
497 | 496 |
|
498 | 497 | if answers["type"] == "stdio":
|
499 | 498 | console.print(f"Command: [cyan]{answers['command']}[/]")
|
500 |
| - new_args = [arg.strip() for arg in answers["args"].split(",") if arg.strip()] if answers["args"] else [] |
| 499 | + new_args = shlex.split(answers["args"]) if answers["args"] else [] |
501 | 500 | console.print(f"Arguments: [cyan]{new_args}[/]")
|
502 | 501 |
|
503 | 502 | new_env = {}
|
|
0 commit comments