evaluate_in_context
Execute arbitrary JavaScript in any browser frame, including iframes and shadow DOM, to inspect app state, styles, or trigger custom logic.
Instructions
Execute arbitrary JavaScript in any frame context, including out-of-process iframes (OOPIFs) and shadow DOM hosts. Uses Target.setAutoAttach to discover all execution contexts automatically.
USE CASES: • Inspect React/Vue/Angular state: evaluate_in_context({ expression: "document.querySelector('#app').vue.$data" }) • Read computed styles: evaluate_in_context({ expression: "getComputedStyle(document.body).backgroundColor" }) • Trigger custom app logic: evaluate_in_context({ expression: "window.myApp.reset()" }) • Execute in an iframe: evaluate_in_context({ expression: "document.title", frameIndex: 1 })
IMPORTANT: This is the tool that replaces framework-specific macros. Instead of using a React-specific sniffer, write the exact JS introspection you need. This keeps the MCP server unopinionated.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeoutMs | No | Evaluation timeout in milliseconds (default: 5000) | |
| expression | No | JavaScript expression to evaluate. The result is returned as JSON. Omit to list available frames. | |
| frameIndex | No | Frame index to evaluate in (0 = main frame). Call with no args to list available frames. |