Skip to content

Merge upstream and keep cloudflare bits under its own folder to avoid future conflicts #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 64 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
88fbf50
devops: use `--provenance` when publishing to NPM (#83)
mxschmitt Mar 29, 2025
a7392fc
chore: allow passing cdp endpoint (#86)
pavelfeldman Mar 30, 2025
aeb4cf6
Fixed typo in README.md (#88)
yyoshiki41 Mar 31, 2025
d316441
chore: sanitize file path when saving (#99)
pavelfeldman Mar 31, 2025
9042c03
chore: support channel and executable path params (#90)
pavelfeldman Mar 31, 2025
4f16786
chore: merge browser and channel settings (#100)
pavelfeldman Apr 1, 2025
0a5518b
chore: stitch together iframes into one tree (#71)
Skn0tt Apr 1, 2025
0de7c0d
chore: follow up with iframe stitch (#110)
pavelfeldman Apr 1, 2025
2366dbf
chore: mark v0.0.8 (#111)
pavelfeldman Apr 1, 2025
128e75b
devops: fix npm publishing due to proverance (#112)
mxschmitt Apr 1, 2025
23f392d
chore: mark v0.0.9 (#114)
pavelfeldman Apr 1, 2025
89627fd
chore: extract page snapshot, prep for multipage (#120)
pavelfeldman Apr 2, 2025
2291011
feat: add slowly option for typing one character at a time (#121)
yury-s Apr 2, 2025
38f038a
chore: typo in description (#127)
yury-s Apr 3, 2025
b358e47
chore: prep for multiple pages in context (#124)
pavelfeldman Apr 3, 2025
e36d4ea
chore: allow multiple tabs (#129)
pavelfeldman Apr 4, 2025
fc0cccf
chore: reuse the first tab when navigating (#131)
pavelfeldman Apr 4, 2025
707ebbf
chore: group tools, prepare for capabilities (#134)
pavelfeldman Apr 4, 2025
abd56f5
chore: introduce capabilities argument (#135)
pavelfeldman Apr 5, 2025
6b15c7e
chore: mark v0.0.10 (#138)
pavelfeldman Apr 6, 2025
4216787
chore: Update README.md (#140)
yyoshiki41 Apr 7, 2025
b8ff009
chore: add back stable vscode install button (#145)
paulirish Apr 7, 2025
31ac1ed
fix: exit watchdog should listen for SIGINT/SIGTERM (#144)
Skn0tt Apr 7, 2025
77080e8
Restore `package-lock.json` module hashes (#151)
cameronfyfe Apr 10, 2025
e729494
feat: browser_resize (#92)
Skn0tt Apr 14, 2025
606b898
chore: allow reusing tab over cdp (#170)
pavelfeldman Apr 14, 2025
0c5a104
chore: default to headless when DISPLAY is missing (#172)
pavelfeldman Apr 14, 2025
71e51ea
chore: mark v0.0.11 (#173)
pavelfeldman Apr 14, 2025
de08c24
fix: consider DISPLAY only on linux (#175)
yury-s Apr 15, 2025
0f7fd13
chore: mark 0.0.12 (#176)
yury-s Apr 15, 2025
6891a52
chore: add npx install step to the publish workflow (#178)
pavelfeldman Apr 15, 2025
4d59e06
test: fix flaky test (#180)
Skn0tt Apr 15, 2025
4a19e18
feat: respond with action and generated locator (#181)
Skn0tt Apr 15, 2025
795a9d5
chore: generalize status & action as code (#188)
pavelfeldman Apr 15, 2025
0d6bb2f
devops: add bots for other browsers/platforms (#174)
yury-s Apr 15, 2025
bc48600
chore: mark v0.0.13 (#190)
pavelfeldman Apr 15, 2025
e433131
chore: update exported types (#192)
pavelfeldman Apr 15, 2025
5c2e110
chore: convert console resource to tool (#193)
pavelfeldman Apr 16, 2025
e7c7709
chore: include "playwright" keyword, add examples (#196)
Skn0tt Apr 16, 2025
6d4adfe
feat: add element screenshot action for snapshots (#182)
AndrewBarzu Apr 16, 2025
6054290
chore: follow up to the element screenshot change (#199)
pavelfeldman Apr 16, 2025
cea347d
chore: introduce modal states (#204)
pavelfeldman Apr 16, 2025
7e4a964
chore: flatten tool calling, prep for timeout handling (#205)
pavelfeldman Apr 17, 2025
4b26128
chore: test list tabs (#208)
pavelfeldman Apr 17, 2025
6481100
feat(dialog): handle dialogs (#212)
pavelfeldman Apr 17, 2025
6a070a0
chore: restore page-side timeout (#213)
pavelfeldman Apr 17, 2025
7695717
docs: provide missing docs (#214)
pavelfeldman Apr 17, 2025
2448e8d
Revert changes since upstream version v0.0.7
ruifigueira Apr 21, 2025
0c3792d
chore: auto update tools in README (#219)
mxschmitt Apr 21, 2025
d4f8f87
docs: fix "programmatic usage with custom transports" code snippet (#…
ruifigueira Apr 21, 2025
dc955c7
Add Docker support (#220)
cmrigney Apr 22, 2025
cd5aa34
docs: push docker doc down the readme (#236)
pavelfeldman Apr 22, 2025
9578a5b
chore: mark v0.0.14 (#237)
pavelfeldman Apr 22, 2025
c80f7cf
chore: infer tool params (#241)
Skn0tt Apr 22, 2025
1bc3c76
feat(network): implement listing network requests (#247)
pavelfeldman Apr 22, 2025
f7e9bae
chore: roll playwright to 1745357020000 (#249)
pavelfeldman Apr 22, 2025
586492a
chore: mark v0.0.15 (#250)
pavelfeldman Apr 22, 2025
8754a2c
Merge commit '586492a3f061be75b3a773ee396cbdbda7c15785' into merge-up…
ruifigueira Apr 24, 2025
caac8f4
chore: build playwright-mcp for workers with vite
ruifigueira Apr 20, 2025
a56302d
patch(playwright-mcp): coerce boolean and number tool parameters
ruifigueira Apr 24, 2025
862a7d5
chore: add example for deploy to cloudflare button
ruifigueira Apr 24, 2025
dd2cc3a
patch(playwright-mcp): prevent errors in playground.ai
ruifigueira Apr 24, 2025
279ccc7
fix: include yaml and zod-to-json-schema dependencies
ruifigueira Apr 24, 2025
8158339
chore: bump @cloudflare/playwright to 0.0.10
ruifigueira Apr 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,30 @@ on:
branches: [ main ]

jobs:
build-and-test:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- run: npm run build
- name: Run ESLint
run: npm run lint
- run: npm run update-readme
- name: Ensure no changes
run: git diff --exit-code

test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
Expand All @@ -22,8 +44,12 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint
- name: Playwright install
run: npx playwright install --with-deps

- name: Install MS Edge
if: ${{ matrix.os == 'macos-latest' }} # MS Edge is not preinstalled on macOS runners.
run: npx playwright install msedge

- name: Build
run: npm run build
Expand All @@ -32,4 +58,4 @@ jobs:
run: npx playwright install --with-deps

- name: Run tests
run: npm test
run: npm test -- --forbid-only
8 changes: 6 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ on:
jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npx playwright install --with-deps
- run: npm run build
- run: npm run lint
- run: npm run test
- run: npm publish
- run: npm run ctest
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib/
node_modules/
test-results/
.vscode/mcp.json
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:22-bookworm-slim

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json at this stage to leverage the build cache
COPY package*.json ./

# Install dependencies
RUN npm ci

# Install chromium and its dependencies, but only for headless mode
RUN npx -y playwright install --with-deps --only-shell chromium

# Copy the rest of the app
COPY . .

# Build the app
RUN npm run build

# Run in headless and only with chromium (other browsers need more dependencies not included in this image)
ENTRYPOINT ["node", "cli.js", "--headless", "--browser", "chromium"]
246 changes: 245 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Cloudflare Playwright MCP

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/playwright-mcp/tree/main/cloudflare/example)

### Overview

This project leverages Playwright for automated browser testing and integrates with Cloudflare Workers, [Browser Rendering](https://developers.cloudflare.com/browser-rendering/) and [`@cloudflare/playwright`](https://github.com/cloudflare/playwright) for deployment.
Expand All @@ -13,9 +15,16 @@ Follow these steps to set up and deploy the project:
npm ci
```

2. Deploy to Cloudflare Workers:
2. Build:
```bash
cd cloudflare
npm run build
```

3. Deploy to Cloudflare Workers:

```bash
cd cloudflare/example
npx wrangler deploy
```

Expand Down Expand Up @@ -104,3 +113,238 @@ code-insiders --add-mcp '{"name":"cloudflare-playwright","type":"sse","url":"htt
```

After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code.

### Tool Modes

The tools are available in two modes:

1. **Snapshot Mode** (default): Uses accessibility snapshots for better performance and reliability
2. **Vision Mode**: Uses screenshots for visual-based interactions

Vision Mode works best with the computer use models that are able to interact with elements using
X Y coordinate space, based on the provided screenshot.

<!--- Generated by update-readme.js -->

### Snapshot-based Interactions

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_snapshot**
- Description: Capture accessibility snapshot of the current page, this is better than screenshot
- Parameters: None

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_click**
- Description: Perform click on a web page
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `ref` (string): Exact target element reference from the page snapshot

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_drag**
- Description: Perform drag and drop between two elements
- Parameters:
- `startElement` (string): Human-readable source element description used to obtain the permission to interact with the element
- `startRef` (string): Exact source element reference from the page snapshot
- `endElement` (string): Human-readable target element description used to obtain the permission to interact with the element
- `endRef` (string): Exact target element reference from the page snapshot

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_hover**
- Description: Hover over element on page
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `ref` (string): Exact target element reference from the page snapshot

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_type**
- Description: Type text into editable element
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `ref` (string): Exact target element reference from the page snapshot
- `text` (string): Text to type into the element
- `submit` (boolean, optional): Whether to submit entered text (press Enter after)
- `slowly` (boolean, optional): Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_select_option**
- Description: Select an option in a dropdown
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `ref` (string): Exact target element reference from the page snapshot
- `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values.

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_take_screenshot**
- Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.
- Parameters:
- `raw` (boolean, optional): Whether to return without compression (in PNG format). Default is false, which returns a JPEG image.
- `element` (string, optional): Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.
- `ref` (string, optional): Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.

### Vision-based Interactions

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_screen_capture**
- Description: Take a screenshot of the current page
- Parameters: None

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_screen_move_mouse**
- Description: Move mouse to a given position
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `x` (number): X coordinate
- `y` (number): Y coordinate

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_screen_click**
- Description: Click left mouse button
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `x` (number): X coordinate
- `y` (number): Y coordinate

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_screen_drag**
- Description: Drag left mouse button
- Parameters:
- `element` (string): Human-readable element description used to obtain permission to interact with the element
- `startX` (number): Start X coordinate
- `startY` (number): Start Y coordinate
- `endX` (number): End X coordinate
- `endY` (number): End Y coordinate

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_screen_type**
- Description: Type text
- Parameters:
- `text` (string): Text to type into the element
- `submit` (boolean, optional): Whether to submit entered text (press Enter after)

### Tab Management

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_tab_list**
- Description: List browser tabs
- Parameters: None

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_tab_new**
- Description: Open a new tab
- Parameters:
- `url` (string, optional): The URL to navigate to in the new tab. If not provided, the new tab will be blank.

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_tab_select**
- Description: Select a tab by index
- Parameters:
- `index` (number): The index of the tab to select

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_tab_close**
- Description: Close a tab
- Parameters:
- `index` (number, optional): The index of the tab to close. Closes current tab if not provided.

### Navigation

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_navigate**
- Description: Navigate to a URL
- Parameters:
- `url` (string): The URL to navigate to

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_navigate_back**
- Description: Go back to the previous page
- Parameters: None

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_navigate_forward**
- Description: Go forward to the next page
- Parameters: None

### Keyboard

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_press_key**
- Description: Press a key on the keyboard
- Parameters:
- `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`

### Console

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_console_messages**
- Description: Returns all console messages
- Parameters: None

### Files and Media

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_file_upload**
- Description: Upload one or multiple files
- Parameters:
- `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_pdf_save**
- Description: Save page as PDF
- Parameters: None

### Utilities

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_close**
- Description: Close the page
- Parameters: None

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_wait**
- Description: Wait for a specified time in seconds
- Parameters:
- `time` (number): The time to wait in seconds

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_resize**
- Description: Resize the browser window
- Parameters:
- `width` (number): Width of the browser window
- `height` (number): Height of the browser window

<!-- NOTE: This has been generated via update-readme.js -->

- **browser_handle_dialog**
- Description: Handle a dialog
- Parameters:
- `accept` (boolean): Whether to accept the dialog.
- `promptText` (string, optional): The text of the prompt in case of a prompt dialog.

<!--- End of generated section -->
Loading
Loading