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

Function interactive_mode

src/mcp_cli/interactive/shell.py:48–142  ·  view source on GitHub ↗

Launch the interactive mode CLI with slash-menu autocompletion.

(
    stream_manager: Any = None,
    tool_manager: ToolManager | None = None,
    provider: str = DEFAULT_PROVIDER,
    model: str = DEFAULT_MODEL,
    server_names: dict[int, str | None] | None = None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

46
47
48async def interactive_mode(
49 stream_manager: Any = None,
50 tool_manager: ToolManager | None = None,
51 provider: str = DEFAULT_PROVIDER,
52 model: str = DEFAULT_MODEL,
53 server_names: dict[int, str | None] | None = None,
54 **kwargs,
55) -> bool:
56 """
57 Launch the interactive mode CLI with slash-menu autocompletion.
58 """
59
60 # Register unified commands
61 register_unified_commands()
62
63 # Get command names for completion from unified registry
64 from mcp_cli.commands.registry import registry
65
66 cmd_names = registry.get_command_names(include_aliases=True)
67
68 # Intro panel
69 print(
70 Panel(
71 Markdown(
72 # "# Interactive Mode\n\n"
73 "Type commands to interact with the system.\n"
74 "Type 'help' to see available commands.\n"
75 "Type 'exit' or 'quit' to exit.\n"
76 "Type '/' to bring up the slash-menu."
77 ),
78 title="MCP Interactive Mode",
79 style="bold cyan",
80 )
81 )
82
83 # Initial help listing - use unified command
84 await InteractiveCommandAdapter.handle_command("help")
85
86 # Create a PromptSession with our completer
87 session: PromptSession = PromptSession(
88 completer=SlashCompleter(cmd_names),
89 complete_while_typing=True,
90 )
91
92 # Main loop
93 while True:
94 try:
95 raw = await asyncio.to_thread(session.prompt, "> ")
96 line = raw.strip()
97
98 # Skip empty
99 if not line:
100 continue
101
102 # If user types a slash command exactly
103 if line.startswith("/"):
104 # strip leading slash and dispatch
105 cmd_line = line[1:]

Calls 3

SlashCompleterClass · 0.85
get_command_namesMethod · 0.80
handle_commandMethod · 0.45