MCPcopy Create free account
hub / github.com/IBM/mcp-cli / _interactive_command

Function _interactive_command

src/mcp_cli/main.py:736–854  ·  view source on GitHub ↗

Start interactive command mode.

(
    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, "-v", "--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 (default, dark, light, minimal, terminal)"
    ),
    confirm_mode: str = typer.Option(
        None,
        "--confirm-mode",
        help="Tool confirmation mode: always, never, or smart (risk-based)",
    ),
    init_timeout: float = typer.Option(
        120.0,
        "--init-timeout",
        help="Server initialization timeout in seconds",
    ),
)

Source from the content-addressed store, hash-verified

734
735@app.command("interactive", help="Start interactive command mode.")
736def _interactive_command(
737 config_file: str = typer.Option(
738 "server_config.json", help="Configuration file path"
739 ),
740 server: str | None = typer.Option(None, help="Server to connect to"),
741 provider: str | None = typer.Option(None, help="LLM provider name"),
742 model: str | None = typer.Option(None, help="Model name"),
743 api_base: str | None = typer.Option(None, "--api-base", help="API base URL"),
744 api_key: str | None = typer.Option(None, "--api-key", help="API key"),
745 disable_filesystem: bool = typer.Option(False, help="Disable filesystem access"),
746 quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"),
747 verbose: bool = typer.Option(
748 False, "-v", "--verbose", help="Enable verbose logging"
749 ),
750 log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"),
751 theme: str = typer.Option(
752 "default", "--theme", help="UI theme (default, dark, light, minimal, terminal)"
753 ),
754 confirm_mode: str = typer.Option(
755 None,
756 "--confirm-mode",
757 help="Tool confirmation mode: always, never, or smart (risk-based)",
758 ),
759 init_timeout: float = typer.Option(
760 120.0,
761 "--init-timeout",
762 help="Server initialization timeout in seconds",
763 ),
764) -> None:
765 """Start interactive command mode."""
766 # Re-configure logging based on user options
767 setup_logging(level=log_level, quiet=quiet, verbose=verbose)
768
769 # Set confirmation mode if specified
770 if confirm_mode:
771 from mcp_cli.utils.preferences import get_preference_manager
772
773 pref_manager = get_preference_manager()
774 if confirm_mode.lower() in ["always", "never", "smart"]:
775 pref_manager.set_tool_confirmation_mode(confirm_mode.lower())
776 else:
777 output.print(f"[red]Invalid confirmation mode: {confirm_mode}[/red]")
778 output.print("[dim]Valid modes: always, never, smart[/dim]")
779 raise typer.Exit(1)
780
781 # Set UI theme - use preference if not specified
782 from mcp_cli.utils.preferences import get_preference_manager
783
784 pref_manager = get_preference_manager()
785
786 if theme and theme != "default":
787 # User specified theme via command line
788 set_theme(theme)
789 pref_manager.set_theme(theme) # Save it as preference
790 else:
791 # Use saved preference
792 saved_theme = pref_manager.get_theme()
793 set_theme(saved_theme)

Callers

nothing calls this directly

Calls 11

get_default_modelMethod · 0.95
get_active_providerMethod · 0.95
get_active_modelMethod · 0.95
setup_loggingFunction · 0.90
get_preference_managerFunction · 0.90
ModelManagerClass · 0.90
process_optionsFunction · 0.90
run_command_syncFunction · 0.90
set_themeMethod · 0.80
get_themeMethod · 0.80

Tested by

no test coverage detected