Skip to main content
Glama

measure_text

Predict text layout dimensions and overflow risk for UI containers without a browser. Validate if text fits fixed-height containers and detect breakpoint overflow.

Instructions

Predict text layout dimensions — height, line count, overflow risk, and breakpoint behavior — without a browser or Figma connection.

Prerequisites: None — runs entirely in Node.js using canvas-based text measurement. No Figma or AI dependencies.

Returns on success: Result object with { height: number (px), lineCount: number, lines: string[] (wrapped line strings) }. If containerHeight is provided, adds { overflow: { overflows: boolean, excessHeight: number } }. If checkBreakpoints is true, adds { breakpoints: { mobile: {...}, tablet: {...}, desktop: {...} } } each with the same height/lineCount/overflow shape.

Error behavior: Never throws — returns 0 height and 1 line if the font string is unparseable.

Use this tool: to validate that a UI label or body text will fit inside a fixed-height container before generating Figma designs or code, to detect which breakpoints cause overflow for responsive layouts, or to size containers accurately without a live browser. Particularly useful when a spec defines a maxLines constraint and you need to verify the real text content respects it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text content to measure. Include all characters including newlines if the source content has them.
maxWidthYesMaximum container width in pixels for line wrapping calculations.
fontNoCSS font shorthand string used for measurement (e.g. '16px Inter', 'bold 14px sans-serif', '500 13px/1.4 system-ui'). Use the same font as your target UI for accurate results.16px sans-serif
lineHeightNoLine height in pixels. Defaults to fontSize × 1.5 if omitted. Provide this to match your Tailwind leading-* or Figma line height setting.
containerHeightNoIf provided, checks whether the measured text fits within this height (in pixels) and reports overflow. Omit if you only need dimensions.
checkBreakpointsNoIf true, also measures text at mobile (375px), tablet (768px), and desktop (1280px) widths in addition to maxWidth. Useful for responsive overflow detection.
Behavior5/5

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

No annotations present, so description fully carries the burden. It explains it runs in Node.js with canvas-based measurement, details the success return object structure, and specifies error behavior: never throws, returns 0 height and 1 line on unparseable font. This is comprehensive.

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?

Well-structured with a one-sentence summary of purpose, then prerequisites, return format, error behavior, and use cases. Every sentence is informative and earns its place. No 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, the description details the return object with shapes and conditions. All 6 parameters are covered with practical guidance. Error handling is explained. Use cases match the tool's complexity (6 params, 2 required). Complete for an AI agent to use correctly.

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%, yet description adds significant value: for text it includes newline advice, for font it suggests matching target UI, for lineHeight it gives default formula and mapping to Tailwind/Figma, for containerHeight and checkBreakpoints it clarifies optional usage and exact breakpoint widths (375, 768, 1280px). Each parameter gains practical context.

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 'predict' and resource 'text layout dimensions' covering height, line count, overflow, and breakpoints. It distinguishes itself from sibling tools by focusing on offline text measurement without browser or Figma, which none of the siblings do.

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?

Provides explicit use cases: validating fit in containers, detecting breakpoint overflow, sizing containers, and verifying maxLines constraints. States no prerequisites. Does not mention when not to use or compare to siblings directly, but context is strong.

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/sarveshsea/memi'

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