Skip to main content
Glama

Extract a visual contract

extract_contract

Extracts a visual contract from a reference URL and saves it as JSON, providing the baseline needed for implementation checks or pixel diffs.

Instructions

Extracts a visual contract from a reference URL and saves it as JSON at outputPath. Call this once per reference design, before check_implementation or diff_pixels can be used, since both need a saved contract to compare against. Pass screenshotDir to also capture reference screenshots, which diff_pixels requires later. Returns a summary: the element count per viewport, any extraction warnings, and the path the contract was written to.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe reference URL to extract a visual contract from.
waitNoExtra settle time in milliseconds after navigation. Defaults to 2000.
masksNoCSS selectors to exclude from the walk, for example ads or timestamps.
timeoutNoNavigation timeout in milliseconds. Defaults to 30000.
fullPageNoCapture the full scrollable page instead of only the viewport. Defaults to true.
headlessNoRun the browser headless. Defaults to true.
selectorNoCSS selector to scope the walk to. Defaults to the document body.
maxStatesNoMaximum interactive elements to probe for hover and focus. Defaults to 120.
viewportsNoViewports to capture. Defaults to desktop 1440x900, tablet 768x1024, mobile 390x844.
outputPathYesFilesystem path to write the contract JSON to, for example ./contracts/home.json.
maxElementsNoMaximum elements to walk, 0 means unbounded. Defaults to 600.
screenshotDirNoDirectory to save reference screenshots to. Required later for diff_pixels to work.
freezeAnimationsNoFreeze CSS animations before measuring. Defaults to true.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations declare readOnlyHint=false and openWorldHint=true; the description is consistent with that, disclosing the file write to outputPath, the optional screenshot capture, and the shape of the returned summary (element count per viewport, warnings, written path). It stops short of permissions, overwrite behavior, or runtime cost for a browser-driven extraction, which is the remaining gap.

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?

Four sentences, front-loaded with the action and side effect before the workflow constraints. Every sentence contributes routing or dependency information; only the return-summary sentence could arguably be trimmed if an output schema existed.

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?

For a 13-parameter, no-output-schema tool, the description covers purpose, ordering relative to all three siblings, the downstream screenshot dependency, and the return summary. What remains thin is handling of the many extraction-tuning parameters, though the schema documents them fully.

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?

Schema description coverage is 100%, so the baseline is 3, but the description adds workflow meaning beyond the schema for two parameters: outputPath is where the contract JSON lands, and screenshotDir is a downstream dependency for diff_pixels rather than merely a directory. The other eleven parameters are only covered by 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?

States a specific verb and resource ('Extracts a visual contract from a reference URL') plus the persistence side effect ('saves it as JSON at outputPath'). It names the siblings it precedes (check_implementation, diff_pixels), so an agent can place it in the workflow without opening any schema.

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

Usage Guidelines5/5

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

Explicit ordering rule: 'Call this once per reference design, before check_implementation or diff_pixels can be used.' It also gives conditional guidance for a specific parameter ('Pass screenshotDir to also capture reference screenshots, which diff_pixels requires later'), which is exactly the when/when-not information an agent needs.

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