Skip to main content
Glama

vs_toggle

Destructive

Enable or disable a Virtual Service to control traffic flow. Disabling stops all traffic and requires confirmation for safety.

Instructions

[WRITE] Enable or disable a Virtual Service. Disabling stops all traffic to this VS.

Use vs_status first to check current state.

SAFETY: When enable=False, requires confirmed=True to execute. Default False returns a preview message describing the intended action. Enabling a VS is always safe and does not require confirmation.

Args: name: Exact Virtual Service name. enable: true to enable, false to disable. confirmed: Must be True when enable=False to actually disable the VS. Default False returns a preview-only message. Ignored when enable=True.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
enableYes
confirmedNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool 'vs_toggle' — the primary handler that implements the tool logic. Decorated with @mcp.tool (destructiveHint=True) and @vmware_tool(risk_level='high'). Accepts name, enable, and confirmed params. Returns a preview message if confirmed=False when disabling; otherwise delegates to toggle_vs via _capture_output.
    @mcp.tool(annotations={"readOnlyHint": False, "destructiveHint": True, "idempotentHint": False, "openWorldHint": True})
    @vmware_tool(risk_level="high")
    def vs_toggle(name: str, enable: bool, confirmed: bool = False) -> str:
        """[WRITE] Enable or disable a Virtual Service. Disabling stops all traffic to this VS.
    
        Use vs_status first to check current state.
    
        SAFETY: When enable=False, requires confirmed=True to execute. Default False returns
        a preview message describing the intended action. Enabling a VS is always safe and
        does not require confirmation.
    
        Args:
            name: Exact Virtual Service name.
            enable: true to enable, false to disable.
            confirmed: Must be True when enable=False to actually disable the VS.
                Default False returns a preview-only message. Ignored when enable=True.
        """
        from vmware_avi.ops.vs_mgmt import toggle_vs
        if not enable and not confirmed:
            return (
                f"[preview] Would disable Virtual Service '{name}', stopping all traffic to this VS. "
                "Re-invoke with confirmed=True to execute."
            )
        return _capture_output(toggle_vs, name, enable=enable, skip_prompt=True)
  • toggle_vs — the low-level AVI API operation that actually enables/disables a VS. Loads config, connects via AviConnectionManager, finds the VS by name, sets enabled flag, and PUTs the update. Handles the double_confirm safety check when skip_prompt=False.
    def toggle_vs(name: str, *, enable: bool, skip_prompt: bool = False) -> None:
        """Enable or disable a Virtual Service.
    
        Args:
            name: Virtual Service name.
            enable: True to enable, False to disable.
            skip_prompt: When True, bypass the interactive double-confirm prompt.
                Used by MCP callers that enforce confirmation via the ``confirmed``
                parameter before reaching this function.
        """
        action = "enable" if enable else "disable"
    
        if not enable and not skip_prompt:
            from vmware_avi._safety import double_confirm
    
            if not double_confirm(f"Disable Virtual Service '{name}'"):
                console.print("[yellow]Cancelled.[/yellow]")
                return
    
        cfg = load_config()
        mgr = AviConnectionManager(cfg)
        session = mgr.connect()
    
        vs = session.get_object_by_name("virtualservice", name)
        if not vs:
            console.print(f"[red]Virtual Service '{name}' not found.[/red]")
            raise SystemExit(1)
    
        vs["enabled"] = enable
        session.put(f"virtualservice/{vs['uuid']}", data=vs)
        console.print(f"[green]Virtual Service '{name}' {action}d.[/green]")
  • Registration of 'vs_toggle' as an MCP tool via the @mcp.tool decorator on FastMCP instance. The function name vs_toggle becomes the tool name automatically.
    @mcp.tool(annotations={"readOnlyHint": False, "destructiveHint": True, "idempotentHint": False, "openWorldHint": True})
    @vmware_tool(risk_level="high")
    def vs_toggle(name: str, enable: bool, confirmed: bool = False) -> str:
  • _capture_output helper — captures Rich console output from the underlying operation function and returns it as a plain-text string. Used by vs_toggle to capture toggle_vs output.
    def _capture_output(func, *args, **kwargs) -> str:
        """Run a function and capture its Rich console output as plain text."""
        import importlib  # noqa: F401 — used via sys.modules lookup
        import sys
    
        buf = StringIO()
        from rich.console import Console
        capture_console = Console(file=buf, force_terminal=False, width=120)
    
        mod_name = func.__module__
        mod = sys.modules.get(mod_name)
        original_console = getattr(mod, "console", None) if mod else None
    
        if mod and original_console is not None:
            mod.console = capture_console
    
        try:
            func(*args, **kwargs)
        except SystemExit:
            pass
        finally:
            if mod and original_console is not None:
                mod.console = original_console
    
        return buf.getvalue()
  • Input schema for vs_toggle defined via type hints and docstring: name (str), enable (bool), confirmed (bool, default False). The @mcp.tool decorator auto-generates JSON Schema from the function signature.
    Args:
        name: Exact Virtual Service name.
        enable: true to enable, false to disable.
        confirmed: Must be True when enable=False to actually disable the VS.
            Default False returns a preview-only message. Ignored when enable=True.
    """
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses safety behavior beyond annotations: requires confirmed for disabling, preview mode by default, and that enabling is safe. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-organized with sections for purpose, usage, safety, and args. Every sentence adds value. No redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers essential context for usage, parameters, and safety. With output schema present, no need to describe return values. Minor gap: no mention of potential errors or side effects beyond traffic stop.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All three parameters are explained clearly: name (exact name), enable (true/false), confirmed (role and default). Compensates fully for 0% schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it enables or disables a Virtual Service, with a specific verb (toggle) and explicit effect (disabling stops all traffic). Distinguishes from sibling tools like vs_status by focusing on state change.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Recommends using vs_status first, and describes when the confirmed parameter is needed. Lacks explicit 'when not to use' but provides sufficient context for typical use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zw008/VMware-AVI'

If you have feedback or need assistance with the MCP directory API, please join our Discord server