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
| Name | Required | Description | Default |
|---|---|---|---|
| width | No | Viewport width in pixels (custom size) | |
| device | No | Device 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) | |
| height | No | Viewport height in pixels (custom size) | |
| reload | No | 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=...). | |
| observe | No | 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.). | screenshot |
| session_id | Yes | Session ID |