How to Use an MCP Browser Tool to Capture a Webpage After Dismissing a Cookie Banner
Use Playwright MCP to inspect a cookie banner, choose the intended consent option, and capture a viewport, element, or full page.
To capture a webpage after dismissing its cookie banner with an MCP browser tool, navigate to the page, inspect its accessibility snapshot, click the consent control that matches the user’s instruction, take a fresh snapshot if the page changes, then call the screenshot tool. The example below uses Playwright MCP; other browser MCP servers may expose different tool names and configuration.
1. Connect Playwright MCP
Playwright MCP lets a compatible MCP client control a browser. Its getting-started guide lists Node.js 20 or newer and an MCP client as prerequisites, and documents configuring @playwright/mcp@latest. Follow the current Playwright MCP setup guide for your client and browser configuration.
Playwright MCP supports Chrome, Firefox, WebKit, and Microsoft Edge. Its profile modes include persistent, isolated, and browser-extension modes. Persistent mode is the default and preserves browser state such as cookies; isolated mode starts fresh and can load storage state. Choose based on whether the capture should use an existing session or a clean browser state. A fresh profile does not guarantee a particular banner or consent flow.
2. Navigate and inspect the banner
In your MCP client, ask the assistant to open the target URL using the browser navigation tool, then read or take an accessibility snapshot. The snapshot exposes accessible roles, text, and refs, which can reveal the banner’s buttons and available choices. Inspect the actual page: labels and options vary by site, and there is no universal cookie-consent selector.
Choose only the visible option that matches the user’s instruction, such as rejecting optional cookies, allowing necessary cookies only, or accepting cookies if that is what the user requested and the page offers it. Do not infer consent from a button’s position or dismiss the banner without knowing which action the control performs.
3. Click the current consent control
Use the current snapshot’s ref for the intended button. Refs are tied to a snapshot and can become invalid after a page change. If navigation or the click changes the page, take a fresh snapshot before using another ref. For a large snapshot, Playwright MCP’s browser_find can locate matching text and return its surrounding subtree.
If the tool reports a browser dialog, handle that dialog separately before continuing. A browser dialog is different from an in-page cookie banner. Cookie and local or session storage management are also separate: deleting or editing cookies is not equivalent to responding to the page’s consent interface.
4. Capture the requested view
Call browser_take_screenshot after the intended banner control has been activated. The tool supports a viewport screenshot, a target element, or a full-page screenshot. Viewport capture is the default. Set fullPage: true to include the full scrollable page; full-page capture cannot be combined with an element target. Supported formats are PNG, JPEG, and WebP. Without a filename, the image is returned inline and saved under a generated name. See the official Playwright MCP screenshot tool documentation.
| Goal | Capture mode | Use it for |
|---|---|---|
| Show what is currently visible | Viewport (default) | Quick review of the page’s current visual state |
| Capture one component | Target element ref or selector | A card, chart, or other specific region |
| Include below-the-fold content | fullPage: true |
A long page or whole-page record |
Snapshots and screenshots serve different purposes: use the accessibility snapshot to find and act on controls; use the image to inspect or document the visual result, including visual content such as charts or canvas elements. Consult the official snapshot documentation for snapshot behavior.
5. Runbook for an MCP client
- Open the requested page in the configured browser.
- Read the accessibility snapshot and identify the cookie banner and its visible consent controls.
- Choose only the option that matches the user’s instruction.
- Click that control using its current snapshot ref.
- Take a fresh snapshot after the click or any navigation; do not reuse a stale ref.
- Capture the viewport, a target element, or the full page as requested.
- Check the returned image to confirm the banner is gone and the expected content is visible.
If the banner’s controls do not appear in the accessibility tree, the cited Playwright documentation does not establish a universal fallback selector. Inspect the page and use only a method that identifies the intended control reliably. Playwright documents browser evaluation and code execution capabilities, but its getting-started guide warns that browser_run_code_unsafe executes arbitrary JavaScript and is equivalent to remote code execution. Enable it only with trusted MCP clients.
6. Troubleshooting
| Problem | Likely cause | What to do |
|---|---|---|
| The consent button cannot be found | Its accessible name differs, the banner has not appeared yet, or its controls are not exposed in the snapshot. | Read a fresh snapshot and inspect the visible banner text and roles. Do not assume a site-wide selector or click an ambiguous control. |
| A click fails with a stale or invalid ref | The ref came from a snapshot that was invalidated by navigation or a page update. | Take a new snapshot, identify the intended control again, and click its new ref. |
| The banner remains after clicking | The click may not have targeted the intended action, or the page may have updated asynchronously. | Take a fresh snapshot and inspect the resulting state. If the banner remains, identify the current control and make the intended choice. |
| The screenshot includes only the top of the page | Viewport capture is the default. | Request fullPage: true when the full scrollable page is needed. |
| An element screenshot conflicts with full-page capture | Those modes cannot be combined. | Choose either a target element or full-page capture for that call. |
| The screenshot file is not named as expected | No filename was supplied, so the tool used a generated name and returned the image inline. | Set a filename using the screenshot tool’s documented arguments when a specific output name is needed. |
| The page shows a modal that is not part of its HTML | It may be a browser dialog rather than an in-page banner. | Handle the reported browser dialog first, then inspect the page again. |
7. Reliability, speed, and cost considerations
The workflow depends on the page exposing a usable consent control and the browser session reaching the expected page state. Cookie persistence, profile mode, site behavior, and timing can change what appears, so inspect the current snapshot rather than assuming the same banner state on every run. Take a fresh snapshot after changes and verify the resulting screenshot.
Viewport capture is usually the simplest choice when only the visible state matters. Full-page capture includes more content and may take longer on long pages; element capture limits the result to one target. The cited Playwright MCP sources do not specify a universal cost, speed benchmark, or timing guarantee. Browser setup and maintenance are part of the self-hosted workflow.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return a PNG, JPEG, WebP, or PDF. Its clean-shot flow accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for API options and MCP setup. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers report the page verdict and whether it was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up free for 1,000 screenshots a month, with no card required.
FAQ
Does dismissing a banner mean I should accept cookies?
No. Choose the consent option that matches the user’s instruction and the choices actually shown on the page.
Can I use the same workflow with another MCP browser server?
The general sequence—navigate, inspect, make the intended choice, and capture—applies broadly, but tool names and configuration vary. The detailed tool names here are for Playwright MCP.
Should I delete cookies to remove the banner?
Cookie storage management and an in-page consent choice are separate operations. Use the visible consent interface when the task is to respond to the banner.


