Screenshots for AI agents over MCP

Let an AI agent take clean screenshots with the capture_screenshot MCP tool: its inputs, why it returns a download URL and not bytes, and how to get new links.

Updated

An agent connected to the Wayfern MCP server can take screenshots with the capture_screenshot tool. This guide shows the tool’s inputs, what it returns, and how the agent or your app gets the image.

Call the tool

Connect your client to https://api.wayfern.com/mcp, for example with an API token that has the mcp scope. The MCP docs explain how. An agent calls the tool with arguments like these:

{
  "url": "https://example.com/pricing",
  "full_page": true,
  "format": "jpeg",
  "hide_selectors": ["#chat-launcher"],
  "fail_if_contains": ["Access denied"]
}

The same call as a raw request, in the current stateless protocol:

curl -X POST https://api.wayfern.com/mcp \
  -H "Authorization: Bearer $WAYFERN_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: 2026-07-28" \
  -H "Mcp-Method: tools/call" \
  -H "Mcp-Name: capture_screenshot" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "capture_screenshot",
      "arguments": { "url": "https://example.com/pricing", "format": "jpeg" },
      "_meta": {
        "io.modelcontextprotocol/protocolVersion": "2026-07-28",
        "io.modelcontextprotocol/clientCapabilities": {},
        "io.modelcontextprotocol/clientInfo": { "name": "my-agent", "version": "1.0.0" }
      }
    }
  }'

One call costs 5 credits, the same as the REST endpoint. Slices cost nothing extra. A call that fails is not charged.

The inputs

InputDefaultWhat it does
urlrequiredThe page to capture.
full_pagetrueCapture the whole page, not only the viewport.
format"png"png or jpeg.
width, height1440, 900Viewport size in CSS pixels, 320 to 3840.
dark_modefalseAsk the page for its dark color scheme.
block_adstrueBlock ad and tracker requests and hide ad slots.
block_cookie_bannerstrueDismiss and hide cookie banners.
selector-Capture only one element.
hide_selectors-Up to 50 CSS selectors to hide.
click-A CSS selector to click first.
wait_for_selector-Wait for this element after load.
wait_for_ms0Wait after load, up to 30,000 ms.
full_page_slicesfalseAlso return the page cut into images.
slice_heightviewport height400 to 10,000 px per slice.
fail_if_contains-Up to 20 terms that fail the call.
proxy"auto"auto, datacenter or residential.

Ad and cookie banner blocking are on by default in the tool and off by default for blockAds on the REST API. An agent wants the content of the page, not its ads.

What the agent gets back

The result is JSON, not image bytes:

{
  "screenshot": {
    "url": "https://...",
    "urlExpiresAt": "2026-10-29T10:15:00.000Z",
    "key": "screenshots/USER_ID/9c1f4d02-7ab8-4e51-9d3f-2c60ba17e8c4.jpg",
    "contentType": "image/jpeg",
    "bytes": 418223,
    "expiresAt": "2026-11-05T10:00:00.000Z"
  },
  "metadata": { "title": "Pricing", "statusCode": 200, "sourceUrl": "https://example.com/pricing" },
  "credits_charged": 5
}

With full_page_slices: true, the result also has slices, a list of images in the same shape, from the top of the page to the bottom.

A URL keeps the tool result small. A full-page image can be megabytes, and a model context has no use for raw bytes. The agent can:

  • Give the link to the user.
  • Download the image with a fetch tool and pass it to a vision model.
  • Read a long page one slice at a time.

The link stops working at urlExpiresAt. The image is kept for 7 days.

The MCP server has no tool for new links. Your app can get one from the REST API with a token that has the web scope:

curl -X POST https://api.wayfern.com/api/v1/artifacts/link \
  -H "Authorization: Bearer $WAYFERN_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "key": "screenshots/USER_ID/9c1f4d02-7ab8-4e51-9d3f-2c60ba17e8c4.jpg" }'

The call is free and returns key, url and urlExpiresAt. It works only for keys of your own account.

When a call fails

A failed call is a tool error, not an exception. The text starts with Wayfern capture_screenshot failed: and gives the reason, for example that the page contains a fail_if_contains term or that full_page_slices needs full_page. The agent can read it and try something else.

What the tool leaves out

The tool is smaller than the REST API. It takes no custom CSS, no custom JavaScript, no extra headers and no PDF options. A tool argument is written by a model that may be reading the very page it captures. A page could hide instructions for the model, and those instructions must not become JavaScript that runs with the page’s privileges. Call the Screenshot API for styles, scripts and headers.

The input limits are in the MCP tool reference.