Skip to main content
Glama
sitebay
by sitebay

sitebay_site_shell_command

Execute shell commands on WordPress sites, including WP-CLI operations and system commands, for site management and troubleshooting.

Instructions

Execute a shell command on a WordPress site. Supports WP-CLI commands, system commands, etc.

Args: fqdn: The fully qualified domain name of the site command: The shell command to execute (e.g., "wp plugin list", "ls -la", "wp search-replace")

Returns: Command output and execution details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fqdnYes
commandYes
cwdNo
auto_track_dirNo

Implementation Reference

  • Core handler function that executes the shell command on the SiteBay site via the client and formats the markdown response with output or error.
    async def sitebay_site_shell_command(
        client: SiteBayClient,
        fqdn: str,
        command: str,
        cwd: Optional[str] = None,
        auto_track_dir: Optional[bool] = None,
    ) -> str:
        """
        Execute a shell command on a WordPress site (including WP-CLI commands).
        
        Args:
            fqdn: The fully qualified domain name of the site
            command: The shell command to execute (e.g., "wp plugin list")
        
        Returns:
            Command output or error message
        """
        try:
            result = await client.execute_shell_command(
                fqdn, cmd=command, cwd=cwd, auto_track_dir=auto_track_dir
            )
            
            # Handle different response formats
            if isinstance(result, dict):
                if 'output' in result:
                    output = result['output']
                elif 'result' in result:
                    output = result['result']
                else:
                    output = str(result)
            else:
                output = str(result)
            
            response = f"**Command executed on {fqdn}:**\n"
            response += f"```bash\n{command}\n```\n\n"
            if cwd is not None:
                response += f"Working dir: {cwd}\n\n"
            response += f"**Output:**\n```\n{output}\n```"
            
            return response
            
        except SiteBayError as e:
            return f"Error executing command on {fqdn}: {str(e)}"
  • MCP tool registration with @mcp.tool decorator. This wrapper initializes the client and delegates to the core handler in operations.
    @mcp.tool
    async def sitebay_site_shell_command(
        fqdn: str,
        command: str,
        cwd: Optional[str] = None,
        auto_track_dir: Optional[bool] = None,
    ) -> str:
        """
        Execute a shell command on a WordPress site. Supports WP-CLI commands, system commands, etc.
        
        Args:
            fqdn: The fully qualified domain name of the site
            command: The shell command to execute (e.g., "wp plugin list", "ls -la", "wp search-replace")
        
        Returns:
            Command output and execution details
        """
        client = await initialize_client()
        return await operations.sitebay_site_shell_command(
            client, fqdn, command, cwd=cwd, auto_track_dir=auto_track_dir
        )

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/sitebay/sitebay-mcp'

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