Command mode for Unix-friendly automation and scripting.
(
input_file: str | None = typer.Option(
None, "--input", "-i", help="Input file (use - for stdin)"
),
output_file: str | None = typer.Option(
None, "--output", "-o", help="Output file (use - for stdout)"
),
prompt: str | None = typer.Option(None, "--prompt", "-p", help="Prompt text"),
tool: str | None = typer.Option(None, "--tool", "-t", help="Tool name to execute"),
tool_args: str | None = typer.Option(
None, "--tool-args", help="Tool arguments as JSON"
),
system_prompt: str | None = typer.Option(
None, "--system-prompt", help="Custom system prompt"
),
raw: bool = typer.Option(False, "--raw", help="Raw output without formatting"),
single_turn: bool = typer.Option(
False, "--single-turn", help="Disable multi-turn conversation"
),
max_turns: int = typer.Option(
100, "--max-turns", help="Maximum conversation turns"
),
config_file: str = typer.Option(
"server_config.json", help="Configuration file path"
),
server: str | None = typer.Option(None, help="Server to connect to"),
provider: str | None = typer.Option(None, help="LLM provider name"),
model: str | None = typer.Option(None, help="Model name"),
api_base: str | None = typer.Option(None, "--api-base", help="API base URL"),
api_key: str | None = typer.Option(None, "--api-key", help="API key"),
disable_filesystem: bool = typer.Option(False, help="Disable filesystem access"),
quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"),
verbose: bool = typer.Option(False, "--verbose", help="Enable verbose logging"),
log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"),
theme: str = typer.Option("default", "--theme", help="UI theme"),
init_timeout: float = typer.Option(
120.0, "--init-timeout", help="Server initialization timeout in seconds"
),
)
| 1580 | # Cmd command - Unix-friendly automation mode |
| 1581 | @app.command("cmd", help="Command mode for Unix-friendly automation and scripting") |
| 1582 | def cmd_command( |
| 1583 | input_file: str | None = typer.Option( |
| 1584 | None, "--input", "-i", help="Input file (use - for stdin)" |
| 1585 | ), |
| 1586 | output_file: str | None = typer.Option( |
| 1587 | None, "--output", "-o", help="Output file (use - for stdout)" |
| 1588 | ), |
| 1589 | prompt: str | None = typer.Option(None, "--prompt", "-p", help="Prompt text"), |
| 1590 | tool: str | None = typer.Option(None, "--tool", "-t", help="Tool name to execute"), |
| 1591 | tool_args: str | None = typer.Option( |
| 1592 | None, "--tool-args", help="Tool arguments as JSON" |
| 1593 | ), |
| 1594 | system_prompt: str | None = typer.Option( |
| 1595 | None, "--system-prompt", help="Custom system prompt" |
| 1596 | ), |
| 1597 | raw: bool = typer.Option(False, "--raw", help="Raw output without formatting"), |
| 1598 | single_turn: bool = typer.Option( |
| 1599 | False, "--single-turn", help="Disable multi-turn conversation" |
| 1600 | ), |
| 1601 | max_turns: int = typer.Option( |
| 1602 | 100, "--max-turns", help="Maximum conversation turns" |
| 1603 | ), |
| 1604 | config_file: str = typer.Option( |
| 1605 | "server_config.json", help="Configuration file path" |
| 1606 | ), |
| 1607 | server: str | None = typer.Option(None, help="Server to connect to"), |
| 1608 | provider: str | None = typer.Option(None, help="LLM provider name"), |
| 1609 | model: str | None = typer.Option(None, help="Model name"), |
| 1610 | api_base: str | None = typer.Option(None, "--api-base", help="API base URL"), |
| 1611 | api_key: str | None = typer.Option(None, "--api-key", help="API key"), |
| 1612 | disable_filesystem: bool = typer.Option(False, help="Disable filesystem access"), |
| 1613 | quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"), |
| 1614 | verbose: bool = typer.Option(False, "--verbose", help="Enable verbose logging"), |
| 1615 | log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"), |
| 1616 | theme: str = typer.Option("default", "--theme", help="UI theme"), |
| 1617 | init_timeout: float = typer.Option( |
| 1618 | 120.0, "--init-timeout", help="Server initialization timeout in seconds" |
| 1619 | ), |
| 1620 | ) -> None: |
| 1621 | """Command mode for Unix-friendly automation and scripting.""" |
| 1622 | # Configure logging and theme |
| 1623 | _setup_command_logging(quiet, verbose, log_level, theme) |
| 1624 | |
| 1625 | # Use ModelManager to resolve provider/model |
| 1626 | from mcp_cli.model_management import ModelManager |
| 1627 | |
| 1628 | model_manager = ModelManager() |
| 1629 | |
| 1630 | # Smart provider/model resolution |
| 1631 | if provider and model: |
| 1632 | effective_provider = provider |
| 1633 | effective_model = model |
| 1634 | elif provider and not model: |
| 1635 | effective_provider = provider |
| 1636 | effective_model = model_manager.get_default_model(provider) |
| 1637 | elif not provider and model: |
| 1638 | effective_provider = model_manager.get_active_provider() |
| 1639 | effective_model = model |
nothing calls this directly
no test coverage detected