Skip to main content
Glama
gjenkins20

webmin-mcp-server

get_mysql_status

Retrieve MySQL server status including version, uptime, current connections, and query statistics to monitor database health and performance.

Instructions

Get MySQL server status including version, uptime, connections, and query statistics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverNoServer alias (e.g., 'pi1', 'web-server'). Uses default server if not specified.

Implementation Reference

  • The async function `get_mysql_status(client: WebminClient) -> ToolResult` that implements the tool logic. It checks if MySQL is running via XML-RPC, returns version/config if running, or graceful error messages if not.
    async def get_mysql_status(client: WebminClient) -> ToolResult:
        """Get MySQL server status.
    
        Returns MySQL server status variables and connection info.
    
        Args:
            client: Authenticated WebminClient instance.
    
        Returns:
            ToolResult with MySQL status.
        """
        try:
            # Check if MySQL is running first
            running_check = await client.call("mysql", "is_mysql_running")
    
            is_running = False
            error_message = None
    
            if isinstance(running_check, list) and len(running_check) > 0:
                status_code = running_check[0]
                is_running = status_code == 1
                if not is_running and len(running_check) > 1:
                    error_message = str(running_check[1])[:200]
            elif isinstance(running_check, (int, bool)):
                is_running = bool(running_check)
    
            if not is_running:
                # Get version info even if not running
                version = await client.call("mysql", "get_mysql_version")
                return ToolResult.ok({
                    "running": False,
                    "installed": bool(version),
                    "version": version if version else None,
                    "error": error_message,
                })
    
            # Try to get detailed status
            try:
                version = await client.call("mysql", "get_mysql_version")
                config = await client.call("mysql", "get_mysql_config")
    
                return ToolResult.ok({
                    "running": True,
                    "version": version if version else None,
                    "config_files": len(config) if isinstance(config, list) else 0,
                })
            except Exception:
                return ToolResult.ok({
                    "running": True,
                    "message": "MySQL is running but detailed status not available via XML-RPC",
                })
    
        except Exception as e:
            error_str = str(e).lower()
            if "connect" in error_str or "running" in error_str or "socket" in error_str:
                return ToolResult.ok({
                    "running": False,
                    "error": str(e)[:200],
                })
            return ToolResult.fail(
                code="MYSQL_STATUS_ERROR",
                message=f"Failed to get MySQL status: {e}",
            )
  • Tool definition registration with name 'get_mysql_status', description, and inputSchema (only optional 'server' param).
    Tool(
        name="get_mysql_status",
        description=(
            "Get MySQL server status including version, uptime, "
            "connections, and query statistics."
        ),
        inputSchema={
            "type": "object",
            "properties": {**SERVER_PARAM},
            "required": [],
        },
    ),
  • Dispatch routing that maps the tool name 'get_mysql_status' to `database.get_mysql_status(client)`.
    if name == "get_mysql_status":
        return await database.get_mysql_status(client)
  • Test class `TestGetMysqlStatus` with 5 test cases covering running, not running, not installed, connection error, and other error scenarios.
    class TestGetMysqlStatus:
        """Tests for get_mysql_status tool."""
    
        async def test_get_status_running(self, mock_client: AsyncMock) -> None:
            """Test when MySQL is running."""
            mock_client.call.side_effect = [
                [1, ""],  # is_mysql_running
                "8.0.35",  # get_mysql_version
                [{"name": "mysql", "file": "/etc/mysql/my.cnf"}],  # get_mysql_config
            ]
    
            result = await database.get_mysql_status(mock_client)
    
            assert result.success
            assert result.data["running"] is True
            assert result.data["version"] == "8.0.35"
    
        async def test_get_status_not_running(self, mock_client: AsyncMock) -> None:
            """Test when MySQL is not running."""
            mock_client.call.side_effect = [
                [0, "Can't connect to MySQL server through socket"],  # is_mysql_running
                "8.0.35",  # get_mysql_version still works
            ]
    
            result = await database.get_mysql_status(mock_client)
    
            assert result.success
            assert result.data["running"] is False
            assert result.data["version"] == "8.0.35"
    
        async def test_get_status_not_installed(self, mock_client: AsyncMock) -> None:
            """Test when MySQL is not installed."""
            mock_client.call.side_effect = [
                [0, "MySQL not installed"],  # is_mysql_running
                "",  # get_mysql_version - empty
            ]
    
            result = await database.get_mysql_status(mock_client)
    
            assert result.success
            assert result.data["running"] is False
            assert result.data["installed"] is False
    
        async def test_get_status_connection_error(self, mock_client: AsyncMock) -> None:
            """Test connection error is handled gracefully."""
            mock_client.call.side_effect = Exception("Can't connect to socket")
    
            result = await database.get_mysql_status(mock_client)
    
            assert result.success
            assert result.data["running"] is False
    
        async def test_get_status_other_error(self, mock_client: AsyncMock) -> None:
            """Test other errors are reported."""
            mock_client.call.side_effect = Exception("Permission denied")
    
            result = await database.get_mysql_status(mock_client)
    
            assert not result.success
            assert result.error.code == "MYSQL_STATUS_ERROR"
Behavior3/5

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

Description accurately portrays the tool as a read operation but does not explicitly state it is non-destructive or safe. No annotations exist, so the description carries the transparency burden but offers minimal behavioral detail.

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

Conciseness4/5

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

Single sentence efficiently conveys purpose and return data. Could be slightly more structured but is adequately concise without verbosity.

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?

Despite no output schema, the description enumerates key fields (version, uptime, connections, query statistics), giving the agent a reasonable understanding of the return format. Simple tool scope makes this sufficient.

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

Parameters3/5

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

Input schema has 100% coverage with a clear description of the optional 'server' parameter. The tool description adds no additional parameter semantics beyond the schema; it only describes the return content.

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?

Description clearly states the verb 'Get', the resource 'MySQL server status', and lists specific data fields (version, uptime, connections, query statistics). This distinguishes it from sibling tools like list_mysql_databases and get_service_status.

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

Usage Guidelines3/5

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

Description implies usage for retrieving MySQL status but provides no explicit guidance on when to prefer this tool over siblings like test_server_connection or get_service_status. Lacks exclusions or alternative tool mentions.

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/gjenkins20/webmin-mcp-server'

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