How to Capture a Webpage Screenshot with an MCP Server When Redirects Fail
A redirect does not necessarily stop a screenshot. Check the final URL and response, wait for the right page content, then capture the viewport, an element, or the full page.
A redirect that reaches a valid HTTP response is not automatically a Playwright navigation failure. Navigate to the starting URL, inspect the final URL and response status, wait for the destination content you need, and then take the screenshot. A returned 404 or 500 is still an HTTP response; it is different from a navigation exception caused by an invalid URL, SSL problem, timeout, unreachable server, or main-resource failure.
This guide uses Playwright MCP as a documented example. MCP clients and browser servers can expose different tool names and arguments, so adapt the example sequence to the tools your configured server actually provides.
1. Check what happened before changing the screenshot call
When a navigation follows redirects, Playwright’s page.goto resolves with the first non-redirect response. Check that response and the page’s final URL. The redirect chain itself is not evidence that the screenshot tool failed.
- Navigate to the complete starting URL, including
https://orhttp://. - Inspect the navigation result, final page URL, and page state. Record the response status if one was returned.
- Decide whether the final destination is the page you meant to capture. A redirect may lead to a login page, an error page, or a different canonical URL.
- Wait for a page-specific signal that the content you want is ready.
- Capture the viewport, a referenced element, or the full scrollable page.
Do not treat an HTTP status and a thrown navigation error as the same failure. Playwright documents that a valid HTTP status, including 404 and 500, does not by itself make page.goto throw. If navigation did throw, investigate the URL, SSL, timeout, reachability, or main-resource loading instead.
2. Run a redirect-aware screenshot sequence with Playwright MCP
Use the corresponding tools exposed by your Playwright MCP server. The following is a tool sequence, not JavaScript to paste into a terminal:
browser_navigate({ url: "https://starting-address.example/path" })
// Inspect the returned final page URL, page state, and navigation response or error.
browser_snapshot()
// Wait for the content that confirms the intended destination is ready.
browser_take_screenshot({ fullPage: true, filename: "capture.png" })
The accessibility snapshot helps you understand the page structure and locate content for interaction. Use the screenshot to inspect visual appearance. If the navigation result contains a response, check its status; if it includes a final URL, check that too. When no response is available because navigation threw, use the actual error text to diagnose the navigation failure.
For a viewport screenshot, omit fullPage or set it to false. To capture one element, obtain its reference through the browser tools and pass it using the screenshot tool’s supported target argument. Full-page capture and an element target cannot be combined. The screenshot tool supports PNG, JPEG, and WebP, and a filename can be supplied; without one, it returns the image inline as well as saving it.
3. Choose a readiness condition that fits the destination
A successful navigation does not guarantee that the exact content you want is rendered. Pick a readiness condition based on the page:
commit: the response has been received and the document has started loading. Use this when you need to proceed early and will wait for the content separately.domcontentloaded: the document has been parsed. This can be enough for mostly static pages, but does not guarantee that client-rendered content or images are ready.load: the load event has fired. This can take longer and still may not mean that a single application-specific component is ready.- A page-specific locator or assertion: wait for the heading, element, or other visible content that confirms the destination is ready. This is usually the clearest choice when the screenshot must show particular content.
Playwright discourages using networkidle as a test readiness strategy. Pages can keep network activity open, and network silence does not prove that the specific content you need has appeared. Prefer a meaningful page assertion or locator wait when available.
4. Diagnose the failure by its observable result
| What you observe | What it means | What to do |
|---|---|---|
| A final URL and an HTTP response, including status 404 or 500 | Navigation returned an HTTP response. The status alone is not a navigation exception. | Check whether the destination is expected. If it is an error page, fix the URL, access, or server response before capturing. |
| Navigation throws or times out | The browser did not complete navigation normally. Possible documented causes include an invalid URL, SSL error, timeout, unreachable server, or main-resource failure. | Check the scheme and URL, inspect the exact exception, and verify the target is reachable from the MCP browser’s network context. |
| The final destination is correct, but the image is blank or incomplete | The screenshot may have been taken before the intended content rendered. | Wait for a page-specific locator or assertion, then capture again. Check whether the content is below the fold or loaded lazily. |
| The same URL works in another browser but not through MCP | The MCP browser, connection, or network path may differ. | Check the configured browser, Chromium channel or CDP endpoint, and any proxy settings. |
| The screenshot is the wrong size or region | The tool may be capturing the viewport by default, or the requested target or scale may not match the need. | Choose viewport, element, or full-page capture deliberately; confirm output type and scale. |
A specific root cause cannot be identified from “redirects fail” alone. For a reproducible diagnosis, retain the starting URL, final URL if present, MCP server and client, response status or exact error text, and the screenshot arguments used.
5. Check browser and network configuration
If the destination behaves differently only in the MCP session, compare the browser context with the working environment. Playwright MCP documents supported browser selection and, for Chromium-based connections, a Chrome channel or CDP endpoint. It also documents proxy settings. These are useful environment checks, not universal redirect fixes.
- Confirm the MCP server is connected to the browser you expect.
- For an existing Chromium browser, verify the configured channel or CDP endpoint.
- If a proxy is configured, check that it uses the intended network path and can reach both the starting host and redirect destination.
- Compare the final URL and error behavior in the MCP browser with the browser context where the URL succeeds.
Avoid enabling an unsafe browser-code tool just to take a screenshot. The Playwright MCP getting-started documentation warns that its unsafe browser code tool executes arbitrary JavaScript in the server process and is equivalent to remote code execution. Ordinary navigation and screenshot calls do not require that tool.
6. Select the right screenshot output
| Need | Capture choice | Consider |
|---|---|---|
| What a visitor sees in the current browser window | Viewport | Default capture; check viewport dimensions and scale. |
| A particular card, chart, or page region | Element target | Use a reference to the intended element. Do not combine with full-page capture. |
| The entire scrollable document | Full page | Use fullPage: true. Wait for content and images that load as the page scrolls. |
| A particular file format | PNG, JPEG, or WebP | Set the supported output type and filename for the workflow. |
| A particular output scale | Scale option | Choose CSS-pixel or device-pixel scale according to the downstream use. |
7. Keep captures reliable and efficient
- Wait only for what you need. A content-specific wait can avoid both premature captures and long waits for unrelated requests.
- Make the destination check explicit. Record or inspect the final URL so a login page or unexpected redirect does not silently become the captured result.
- Use the smallest capture that answers the question. A viewport or element capture can be easier to inspect than a full-page image when only one region matters.
- Keep failure details with the result. Save the starting URL, final URL, status or exception, output format, and capture mode alongside the image when diagnosing intermittent failures.
- Do not infer cost or speed from the redirect alone. The cited Playwright documentation provides behavior and configuration details, not a benchmark or a universal timing guarantee. Actual latency depends on navigation, page rendering, browser, and network conditions.
Or skip the browser setup
For a one-call screenshot API, ScreenshotNeo accepts a URL and returns a screenshot or PDF. See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://starting-address.example/path -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://starting-address.example/path"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://starting-address.example/path' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Cookie banners, popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
- Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers report the page verdict and billing status.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The free plan includes 1,000 screenshots a month with no card. Paid plans start at $5 for 3,000 screenshots.
Create a free ScreenshotNeo account for 1,000 screenshots a month, with no card required.
Frequently asked questions
Does Playwright follow redirects automatically?
Playwright’s navigation resolves with the first non-redirect response. Inspect the final URL and response to confirm where it landed.
Can I screenshot a 404 page?
Yes, if navigation returns that HTTP response and the page renders. A 404 response is not, by itself, a thrown navigation exception.
Can I capture an element and the full page at the same time?
No. The Playwright MCP screenshot tool’s full-page mode cannot be combined with an element target.
What details are needed to diagnose a specific redirect failure?
Provide the MCP server and client, starting URL, final URL if available, response status or exact error text, and the screenshot request settings.


