Skip to main content
Glama

Detect UI elements in a screenshot

riv_ui_detect

Detect rectangles, text runs, and images in a UI screenshot, design comp, or SVG; return a nested element tree with geometry, fills, and a numbered overlay for UI reconstruction and prototyping.

Instructions

Find the rectangles, text runs and images in a UI screenshot or design comp. Returns a nested element tree with rects, corner radii and fill colours, plus a numbered overlay PNG. Coordinates are in source pixels (accurate to about 1-2 px); corner radii to about 1 px. Each element carries renderMode ("vector-panel" | "raster" — how it would be reconstructed; flat fills are test-rendered and turned into crops when more than 2% of their visible pixels would differ, the measured share is returned as renderRisk) and semanticHint ("panel" | "text" | "image" | "line" — what it looks like) as independent fields. Next, give each element a role and pass the result to riv_ui_prototype. This is geometry only: it does not know a button from a card. If you have the vector source, pass svgPath instead of imagePath: nothing is estimated, the element tree is the SVG's own group nesting, non-rectangular artwork comes through as "vector-shape" with its real bezier vertices, becomes "vector-text" (editable Rive text — the bundled Inter is substituted unless you pass fonts, and a run whose glyphs are missing is baked as a picture instead, always with a warning), embedded data comes through as its own pixels, and Figma layer names arrive as roleHint.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "riv_ui_detect"
  }
}

Input Schema

NameRequiredDescriptionDefault
fontsNoFonts for the SVG's <text>. svgPath only — pass the same list to riv_ui_prototype
minAreaNoIgnore regions smaller than this many pixels (default 576). imagePath only
svgPathNoVector source instead of a screenshot (Figma/Illustrator SVG export). Nothing is estimated: rects, fills, corner radii and nesting come straight from the file
figmaUrlNoA Figma link to one frame (Copy link to selection), fetched as SVG through the Figma REST API. Off unless FIGMA_TOKEN is set in the server's environment; without it this errors and nothing is requested. Everything else works offline
imagePathNoScreenshot or design comp (PNG/JPEG)
maxElementsNoKeep at most this many elements, largest first (default 120, or 300 for svgPath)
overlayPathNoWhere to write the numbered overlay PNG

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.6.1

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so well: it discloses the return shape, coordinate accuracy, renderMode semantics, renderRisk behavior, SVG handling, font substitution and bake-with-warning behavior, Figma token requirements, and that it writes an overlay PNG. These are substantial behavioral details beyond the schema.

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 purpose is front-loaded and the text is dense but mostly earns its place by explaining complex output and mode behavior. It is a long single paragraph with several parentheticals, so it is not maximally concise, but the length is justified for a tool with this much behavioral nuance.

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?

There is no output schema and no annotations, so the description must carry the return-value and behavioral contract. It explains the nested element tree, overlay PNG, accuracy, independent renderMode and semanticHint fields, vector-source behavior, and font warnings, leaving no major ambiguity for invocation.

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. The description adds meaningful selection and behavior semantics for svgPath, fonts, and the vector-vs-screenshot mode, though it does not add much beyond the schema for minArea, maxElements, or overlayPath.

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 opens with a specific verb and resource: find rectangles, text runs and images in a UI screenshot or design comp. It clearly distinguishes the tool from downstream tools by stating it is geometry only and does not know a button from a card, and it names riv_ui_prototype as the next step.

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?

It gives explicit selection guidance: use svgPath instead of imagePath when a vector source exists, with different behavior clearly described. It also names the downstream tool riv_ui_prototype and explains that this tool only extracts geometry, so the agent knows when to use it and when to hand off.

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