# Screenshot a Page — Puppeteer

> Captures a screenshot of a page using Puppeteer. See the documentation

- Key: `puppeteer-screenshot-page`
- Type: Action (Write)
- Version: 1.0.5
- App: Puppeteer (`puppeteer`) — https://pipedream.com/apps/puppeteer.md
- This page (HTML): https://pipedream.com/apps/puppeteer/actions/screenshot-page
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/puppeteer/actions/screenshot-page/screenshot-page.mjs

## Description

Captures a screenshot of a page using Puppeteer. [See the documentation](https://pptr.dev/api/puppeteer.page.screenshot)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `url` | `string` | Yes | The URL of the page to scrape. For example, https://example.com. |
| `downloadPath` | `string` | No | Download the screenshot to the /tmp directory with the specified filename |
| `captureBeyondViewport` | `boolean` | No | Capture the screenshot beyond the viewport. |
| `clipHeight` | `string` | No | Specifies the height of the region of the page to clip. |
| `clipScale` | `string` | No | Specifies the scale of the region of the page to clip. |
| `clipWidth` | `string` | No | Specifies the width of the region of the page to clip. |
| `clipX` | `string` | No | Specifies the X value of the region of the page to clip. |
| `clipY` | `string` | No | Specifies Y value of the region of the page to clip. |
| `encoding` | `string` | No | Encoding of the image. |
| `fromSurface` | `boolean` | No | Capture the screenshot from the surface, rather than the view. |
| `fullPage` | `boolean` | No | When true, takes a screenshot of the full page. |
| `omitBackground` | `boolean` | No | Hides default white background and allows capturing screenshots with transparency. |
| `optimizeForSpeed` | `boolean` | No | Optimize for speed. |
| `quality` | `integer` | No | Quality of the image, between 0-100. Not applicable to png images. |
| `type` | `string` | No | Type of the screenshot image. |
| `syncDir` | `dir` | Yes | SyncDir |
| `browserTimeout` | `integer` | No | Maximum time in seconds to wait for the browser to start. Default is 30 seconds. |
| `pageTimeout` | `integer` | No | Maximum time in seconds to wait for the page to load. Default is 30 seconds. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "puppeteer",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "puppeteer-screenshot-page",
  arguments: {
    url: "URL",
    downloadPath: "Download Path",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "puppeteer-screenshot-page",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    puppeteer: { authProvisionId: "apn_xxxxxxx" },
    url: "URL",
    downloadPath: "Download Path",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "puppeteer-screenshot-page",
    "configured_props": {
      "puppeteer": { "authProvisionId": "apn_xxxxxxx" },
      "url": "URL",
      "downloadPath": "Download Path"
    }
  }'
```

---

- App: https://pipedream.com/apps/puppeteer.md · All apps: https://pipedream.com/apps
