Skip to main content
Glama

set_viewport

Resize a session's viewport to a device preset or custom width/height and capture a screenshot, so you can test responsive layouts within an ongoing session.

Instructions

Resize a session's viewport to a device preset or custom width/height, then screenshot. Returns the new size and screenshot. Persists for later actions in the session — use this to test responsive layouts inside an ongoing session (unlike test_responsive, which opens throwaway pages).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "session_id": "<session_id>"
    },
    "name": "set_viewport"
  }
}

Input Schema

NameRequiredDescriptionDefault
widthNoViewport width in pixels (custom size)
deviceNoDevice preset: mobile_sm (320x568 iPhone SE), mobile (375x812 iPhone 12), mobile_lg (428x926 iPhone 14 Pro Max), tablet (768x1024 iPad), tablet_lg (1024x1366 iPad Pro), laptop (1366x768), desktop (1920x1080), desktop_lg (2560x1440)
heightNoViewport height in pixels (custom size)
reloadNoReload after resizing so JS-driven breakpoints (Elementor, sliders) re-evaluate (default: false). For user-agent/touch emulation open a new session with open_session(device=...).
observeNoWhat to return about the resulting page. 'screenshot' (default): full-page image. 'none': structured result only, no image — cheapest, use through setup steps of a flow. 'map': semantic page map (get_page_map — token-light, best for 'what can I do next?'). 'checks': run_checks_on_session output (a11y/seo/perf/etc.).screenshot
session_idYesSession ID

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.12.0
    • addedInput schema / properties / reload
      Added value: +{
      +  "description": "Reload after resizing so JS-driven breakpoints (Elementor, sliders) re-evaluate (default: false). For user-agent/touch emulation open a new session with open_session(device=...).",
      +  "type": [
      +    "boolean",
      +    "string"
      +  ]
      +}
  2. Changed1 schema field changedv0.10.2
    • addedInput schema / properties / observe
      Added value: +{
      +  "default": "screenshot",
      +  "description": "What to return about the resulting page. 'screenshot' (default): full-page image. 'none': structured result only, no image — cheapest, use through setup steps of a flow. 'map': semantic page map (get_page_map — token-light, best for 'what can I do next?'). 'checks': run_checks_on_session output (a11y/seo/perf/etc.).",
      +  "enum": [
      +    "screenshot",
      +    "none",
      +    "map",
      +    "checks"
      +  ],
      +  "type": "string"
      +}
  3. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

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

No annotations exist, so the description carries the full burden, and it discloses key traits: the change persists for later actions in the session, a screenshot is taken, and the new size is returned. It leaves unstated what happens if device and width/height are supplied together, and whether failures require an active session — minor but real gaps for an unannotated mutation tool.

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?

Three sentences, front-loaded with the action and return value, then the persistence rule, then the sibling distinction. No padding, and every sentence earns its place.

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?

No output schema exists, but the description compensates by stating it returns the new size and screenshot, and the observe/reload semantics are documented in the schema. Slightly incomplete regarding precedence between device and width/height and any error conditions.

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

Parameters3/5

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

Schema coverage is 100% and the enum values are fully expanded in the schema, so the description only adds the framing that device is a preset alternative to custom width/height. That is a useful either/or signal but no syntax or precedence detail beyond what the schema already provides, so baseline 3 applies.

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 ('Resize a session's viewport'), the follow-on effect ('then screenshot'), and the return value. It also names the sibling it differs from (test_responsive) and explains why, so an agent can separate the two tools without opening either 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?

Gives an explicit when-to-use ('to test responsive layouts inside an ongoing session') and an explicit alternative with its contrasting behavior ('unlike test_responsive, which opens throwaway pages'). The reload parameter description adds further routing guidance to open_session for user-agent/touch emulation.

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