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

Function cli_entry

src/mcp_cli/run_command.py:303–345  ·  view source on GitHub ↗

Thin wrapper so `uv run mcp-cli chat` (or `interactive`) is minimal.

(
    mode: str = typer.Argument("chat", help="chat | interactive"),
    config_file: str = typer.Option(
        "server_config.json", "--config", "-c", help="Server config file"
    ),
    server: list[str] = typer.Option(
        ["sqlite"], "--server", "-s", help="Server(s) to connect"
    ),
    provider: str = typer.Option("openai", help="LLM provider name"),
    model: str = typer.Option("gpt-4o-mini", help="LLM model name"),
    init_timeout: float = typer.Option(
        120.0, "--init-timeout", help="Server initialization timeout in seconds"
    ),
)

Source from the content-addressed store, hash-verified

301
302@app.command("run")
303def cli_entry(
304 mode: str = typer.Argument("chat", help="chat | interactive"),
305 config_file: str = typer.Option(
306 "server_config.json", "--config", "-c", help="Server config file"
307 ),
308 server: list[str] = typer.Option(
309 ["sqlite"], "--server", "-s", help="Server(s) to connect"
310 ),
311 provider: str = typer.Option("openai", help="LLM provider name"),
312 model: str = typer.Option("gpt-4o-mini", help="LLM model name"),
313 init_timeout: float = typer.Option(
314 120.0, "--init-timeout", help="Server initialization timeout in seconds"
315 ),
316) -> None:
317 """
318 Thin wrapper so `uv run mcp-cli chat` (or `interactive`) is minimal.
319 """
320
321 async def _inner() -> None:
322 if mode not in {"chat", "interactive"}:
323 raise typer.BadParameter("mode must be 'chat' or 'interactive'")
324
325 tm = await _init_tool_manager(
326 config_file, server, initialization_timeout=init_timeout
327 )
328
329 try:
330 if mode == "chat":
331 ok = await _enter_chat_mode(tm, provider=provider, model=model)
332 else:
333 ok = await _enter_interactive_mode(tm, provider=provider, model=model)
334
335 if not ok:
336 raise RuntimeError("Command returned non-zero status")
337
338 finally:
339 await _safe_close(tm)
340
341 try:
342 asyncio.run(_inner())
343 except Exception as exc: # noqa: BLE001 – show nicely then exit
344 output.print(Panel(str(exc), title="Fatal Error", style="bold red"))
345 sys.exit(1)

Calls 2

_innerFunction · 0.85
runMethod · 0.80