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

Function ping_command

src/mcp_cli/main.py:1701–1748  ·  view source on GitHub ↗

Test connectivity to MCP servers.

(
    targets: list[str] = typer.Argument(
        None, help="Server names or indices to ping (omit for all)"
    ),
    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 = typer.Option("openai", help="LLM provider name"),
    model: str | None = typer.Option(None, help="Model name"),
    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"),
)

Source from the content-addressed store, hash-verified

1699# Ping command - test connectivity
1700@app.command("ping", help="Test connectivity to MCP servers")
1701def ping_command(
1702 targets: list[str] = typer.Argument(
1703 None, help="Server names or indices to ping (omit for all)"
1704 ),
1705 config_file: str = typer.Option(
1706 "server_config.json", help="Configuration file path"
1707 ),
1708 server: str | None = typer.Option(None, help="Server to connect to"),
1709 provider: str = typer.Option("openai", help="LLM provider name"),
1710 model: str | None = typer.Option(None, help="Model name"),
1711 disable_filesystem: bool = typer.Option(False, help="Disable filesystem access"),
1712 quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"),
1713 verbose: bool = typer.Option(
1714 False, "-v", "--verbose", help="Enable verbose logging"
1715 ),
1716 log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"),
1717 theme: str = typer.Option("default", "--theme", help="UI theme"),
1718) -> None:
1719 """Test connectivity to MCP servers."""
1720 # Configure logging and theme for this command
1721 _setup_command_logging(quiet, verbose, log_level, theme)
1722
1723 # Process options to get server config and names
1724 servers, _, server_names = process_options(
1725 server, disable_filesystem, provider, model, config_file, quiet=quiet
1726 )
1727
1728 # Use unified command system via CLI adapter
1729 from mcp_cli.adapters.cli import cli_execute
1730
1731 # Wrapper for the async action
1732 async def _ping_wrapper(**params):
1733 return await cli_execute(
1734 "ping",
1735 server_names=params.get("server_names"),
1736 targets=params.get("targets", []),
1737 )
1738
1739 # Execute via run_command_sync
1740 run_command_sync(
1741 _ping_wrapper,
1742 config_file,
1743 servers,
1744 extra_params={
1745 "targets": targets,
1746 "server_names": server_names,
1747 },
1748 )
1749
1750
1751direct_registered.append("ping")

Callers

nothing calls this directly

Calls 3

process_optionsFunction · 0.90
run_command_syncFunction · 0.90
_setup_command_loggingFunction · 0.85

Tested by

no test coverage detected