Skip to content

Add MCP controls for screenshots, scrolling, mirroring and viewports - #1565

Merged
manojVivek merged 1 commit into
mainfrom
feat/mcp-agent-controls
Nov 22, 2026
Merged

manojVivek merged 1 commit into
mainfrom
feat/mcp-agent-controls

Conversation

@manojVivek

Copy link
Copy Markdown
Collaborator

Stacked on #1564 (MCP file:// limits). Review that first; this PR's base will move to main once it merges.

Makes the MCP server easier for an agent to drive the app with.

New and extended tools

Tool What's new
screenshot fullPage captures the whole document without changing the preview's viewport size, so vh-based layouts stay intact. originalResolution returns an unscaled PNG. Defaults are unchanged (compact JPEG, max 1000px wide). Reported sizes are actual output pixels, including on Retina.
scroll_to (new) Scrolls to a unique CSS selector, visible text (case-insensitive and whitespace-normalized, or exact), or absolute x/y. Supports block alignment and nested scroll containers. Ambiguous matches return an error so the agent can refine its target.
set_mirroring (new) Turns event mirroring on or off for one device or all active previews. The state is shared with the device toolbar's Event mirroring control and survives reloads. A disabled preview neither sends nor receives mirrored clicks, typing or scrolling.
set_device_options (new) Session-only width, height, orientation and colorScheme overrides per preview, plus reset. Frame sizing, the canvas layout and screenshot labels follow the effective viewport, and get_app_state reports it. Saved presets are not modified.

Usage examples are in responsively-mcp/README.md.

Supporting changes

  • Debugger lease (main/debugger-lease.ts): temporary CDP work (full-page capture, media emulation) and the element inspector no longer detach each other.
  • Mirroring state moves from local component state into Redux (event-mirroring slice), so the UI and MCP share it. It is applied to the BrowserSync socket per preview.
  • Navigation from a preview with mirroring off no longer drives every device through the shared address bar.
  • Canvas drag-and-drop reads the latest drag position from a ref, so a fast drop can't lose it when the last move hasn't re-rendered yet.
  • The new tools follow Limit MCP file:// access to local .html/.htm files #1564's rule: scroll_to and full-page screenshots refuse a preview showing a local file that isn't .html/.htm.

Overlap with #1553

#1553 also fixes full-page screenshots with vh units (for the toolbar capture). Here, full-page capture for MCP uses CDP Page.captureScreenshot with captureBeyondViewport and leaves the toolbar capture untouched.

Testing

  • Unit: 378/378 (new tests for scroll, screenshots, full-page capture, debugger lease, color scheme, mirroring, device-manager overrides, the MCP bridge commands and navigation).
  • E2E (Linux/Xvfb): 248 passed, including the new MCP tests (scroll, full-page/original-resolution screenshots, mirroring, viewport options, file-URL limits). Five failed, and the same five fail on main in the same environment: four canvas/present-mode pointer tests under Xvfb, and scroll to top button resets scroll in webview, which is flaky on main (2/4 locally). macOS CI is the reference.
  • Typecheck and lint clean.

🤖 Generated with Claude Code

Make the MCP server easier for an agent to drive the app with:

- screenshot: `fullPage` captures the whole document without changing
  the preview's viewport size (so vh-based layouts stay intact), and
  `originalResolution` returns an unscaled PNG. Defaults stay compact
  JPEGs; reported sizes are actual output pixels, including on Retina.
- scroll_to: scroll a preview to a unique CSS selector, visible text
  (case-insensitive, normalized, or `exact`), or absolute x/y, with
  `block` alignment and nested scroll containers. Ambiguous matches
  return an error so the agent can refine its target.
- set_mirroring: enable or disable event mirroring for one device or
  all active previews. Mirroring state moves into Redux so the device
  toolbar and MCP share it; a disabled preview neither sends nor
  receives mirrored clicks, typing or scrolling, across reloads.
- set_device_options: session-only width, height, orientation and
  color scheme overrides per preview, plus `reset`. Frame sizing,
  canvas layout and screenshot labels follow the effective viewport;
  get_app_state reports it. Saved presets are not modified.

Supporting changes: a debugger lease so temporary CDP work (full-page
capture, media emulation) and the element inspector don't detach each
other; navigation from an isolated preview no longer drives every
device through the shared address bar; canvas drag-and-drop reads the
latest drag position from a ref so a fast drop isn't lost.

The new tools follow the local file rule from #1559: scroll_to and
full-page screenshots refuse previews showing a non-.html/.htm file.

Co-authored-by: Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@manojVivek
manojVivek changed the base branch from fix/mcp-file-url-html-only to main November 22, 2026 08:10
An error occurred while trying to automatically change base from fix/mcp-file-url-html-only to main November 22, 2026 08:10
@manojVivek manojVivek closed this Nov 22, 2026
@manojVivek manojVivek reopened this Nov 22, 2026
@manojVivek
manojVivek merged commit 79a62b8 into main Nov 22, 2026
6 checks passed
@manojVivek
manojVivek deleted the feat/mcp-agent-controls branch November 22, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant