Skip to main content
Glama
Xuzan9396

YST KPI Daily Report Collector

by Xuzan9396

check_playwright_installation

Verify Playwright browser automation driver installation status to ensure the YST KPI Daily Report Collector can automate data collection from KPI systems.

Instructions

检查 Playwright 浏览器驱动安装状态

Returns: 安装状态信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the check_playwright_installation tool. It verifies Playwright installation and Chromium browser drivers using subprocess checks and provides installation guidance if needed.
    @mcp.tool()
    async def check_playwright_installation() -> str:
        """
        检查 Playwright 浏览器驱动安装状态
    
        Returns:
            安装状态信息
        """
        import subprocess
        import sys
    
        try:
            logger.info("检查 Playwright 安装状态")
    
            # 检查 Playwright 模块
            try:
                import playwright
                playwright_version = playwright.__version__
                logger.info(f"Playwright 模块已安装,版本: {playwright_version}")
            except ImportError:
                return safe_text(
                    "❌ Playwright 模块未安装\n\n"
                    "请运行以下命令安装:\n"
                    "pip install playwright\n"
                    "playwright install chromium"
                )
    
            # 检查浏览器驱动
            result_text = safe_text(f"✓ Playwright 模块已安装 (v{playwright_version})\n\n")
    
            # 尝试检查浏览器安装
            try:
                # 运行 playwright install --dry-run 检查浏览器状态
                result = subprocess.run(
                    [sys.executable, "-m", "playwright", "install", "--dry-run", "chromium"],
                    capture_output=True,
                    text=True,
                    timeout=10
                )
    
                logger.debug(f"playwright install --dry-run 输出: {result.stdout}")
    
                if "is already installed" in result.stdout or "Skipping" in result.stdout:
                    result_text += safe_text("✓ Chromium 浏览器驱动已安装\n\n")
                    result_text += "系统状态:正常\n"
                    result_text += "\n如果浏览器仍无法弹出,请检查:\n"
                    result_text += "1. 防火墙/杀毒软件是否阻止\n"
                    result_text += "2. 查看详细日志文件"
                else:
                    result_text += safe_text("⚠ Chromium 浏览器驱动可能未安装\n\n")
                    result_text += "请运行以下命令安装:\n"
                    result_text += "playwright install chromium\n\n"
                    result_text += "或在 Windows PowerShell 中:\n"
                    result_text += "python -m playwright install chromium"
    
            except subprocess.TimeoutExpired:
                logger.warning("playwright install 命令超时")
                result_text += safe_text("⚠ 无法检查浏览器驱动状态(命令超时)\n\n")
                result_text += "建议手动运行:playwright install chromium"
            except Exception as e:
                logger.error(f"检查浏览器驱动失败: {e}")
                result_text += safe_text(f"⚠ 无法检查浏览器驱动: {str(e)}\n\n")
                result_text += "建议手动运行:playwright install chromium"
    
            return result_text
    
        except Exception as e:
            logger.exception("检查 Playwright 安装状态出错:")
            return safe_text(f"❌ 检查失败: {str(e)}")
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool returns installation status information, but doesn't disclose behavioral traits such as whether this is a read-only operation (implied but not explicit), potential side effects (e.g., triggering installation if missing), error handling, or performance characteristics. The description is minimal and lacks operational context.

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?

The description is concise and front-loaded: the first line states the purpose clearly. The second line ('Returns: 安装状态信息') is somewhat redundant but adds minimal value by hinting at output. Overall, it's efficient with two short sentences, though the second sentence could be integrated more smoothly.

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

Completeness3/5

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

Given the tool's low complexity (0 parameters, simple status check) and the presence of an output schema (which handles return values), the description is somewhat complete but lacks depth. It covers the basic purpose but misses usage context and behavioral details. For a tool with no annotations, more information on what the status entails (e.g., installed/not installed, version details) would improve completeness.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100% (empty schema). The description doesn't need to add parameter semantics, so it meets the baseline of 4 for no parameters. It appropriately avoids discussing parameters that don't exist.

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

Purpose4/5

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

The description clearly states the tool's purpose: '检查 Playwright 浏览器驱动安装状态' (Check Playwright browser driver installation status). It uses a specific verb ('检查' - check) and resource ('Playwright 浏览器驱动安装状态' - Playwright browser driver installation status). However, it doesn't explicitly differentiate from sibling tools like 'check_login_status' which checks a different status, though the resource distinction is implicit.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether Playwright needs to be configured first), nor does it suggest when this check is needed (e.g., before running browser operations). With siblings like 'browser_login' and 'check_login_status', some context on usage timing would be helpful.

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/Xuzan9396/yst_mcp'

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