Skip to main content
Glama

browser_visual_component

Capture a screenshot of a CSS-selected component and compare it against a named baseline to detect visual differences, returning diff pixel count and ratio. Automatically creates a baseline if none exists.

Instructions

Component-level visual diff in one call: capture a screenshot of the CSS-selected component, compare against same-named baseline, return diffPixels/diffRatio/passed. Auto-creates the baseline if missing and returns baseline_created flag.

中文详情:

  • 用途:组件级视觉对比,一次调用完成组件截图 → 与同名基线对比 → 返回差异指标;基线不存在时自动创建并返回 baseline_created 标记

  • 何时使用:组件库视觉回归时;卡片/弹窗/表格等独立组件 UI 验证时;多主题(light/dark)组件对比时;增量 UI 改动只对比受影响组件时

  • 输出:{ ok: boolean, name: string, selector: string, baselinePath: string, actualPath: string, diffPath: string, diffPixels: number, diffRatio: number, passed: boolean, baseline_created: boolean }

  • 参数:

    • name (string, 必填):组件基线名称,不含扩展名

    • selector (string, 必填):CSS 选择器,精确选择要对比的组件

    • maxDiffPixelRatio (number, 可选):允许的最大差异像素比例,默认 0.01

    • sessionName (string, 可选):浏览器会话名称,默认当前活跃会话

  • 错误:selector 无匹配抛出 'element not found';选择器匹配多个元素抛出 'Selector matches multiple elements, refine it'

  • 示例:{"name":"product-card","selector":".product-card","maxDiffPixelRatio":0.005}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes组件基线名称,不含扩展名
selectorYesCSS 选择器,精确选择要对比的组件
sessionNameNo浏览器会话名称,默认当前活跃会话
maxDiffPixelRatioNo允许的最大差异像素比例,默认 0.01
Behavior4/5

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

With no annotations, the description covers behavioral traits: it captures a screenshot, compares to a baseline, auto-creates the baseline if missing, returns diff metrics and flags. It also lists error conditions (no match, multiple matches). It could mention if it modifies browser state, but overall it's transparent.

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?

The description is well-structured: an English summary followed by Chinese details in bullet points. It is front-loaded with the key purpose and output, and every sentence adds necessary information without redundancy.

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

Completeness5/5

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

Despite having no output schema and no annotations, the description fully covers purpose, usage, parameters, output structure (list of fields), errors, and an example. It leaves no significant gaps for an agent to understand the tool.

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?

Schema coverage is 100% and the description adds value: it states the default for maxDiffPixelRatio (0.01) and that sessionName defaults to the current active session. It also provides an example JSON, reinforcing parameter usage beyond the schema.

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?

The description clearly states it performs a component-level visual diff, capturing a screenshot of a CSS-selected component and comparing it against a same-named baseline. The verb 'capture and compare' plus the resource 'component' is specific. It distinguishes from sibling tools like browser_visual (presumably full-page) and browser_visual_check.

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?

The Chinese section explicitly lists when to use: component library visual regression, independent component UI verification, multi-theme comparison, and incremental UI changes. It does not explicitly say when not to use, but the guidance is clear and context-specific.

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/validpilot/ai-verify-mcp'

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