-
Notifications
You must be signed in to change notification settings - Fork 10k
Playwright MCP #22668
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
Playwright MCP #22668
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
66d069a
Adds Playwright MCP documentation and changelog entry
celso cb43006
Merge branch 'production' of github.com:cloudflare/cloudflare-docs in…
celso f15494f
Update src/content/docs/browser-rendering/platform/playwright-mcp.mdx
celso aaf4a53
Update src/content/docs/browser-rendering/platform/playwright-mcp.mdx
celso 7431a2b
Update src/content/docs/browser-rendering/platform/playwright-mcp.mdx
celso 82fef59
Small improvements
celso fdfadcc
Update playwright-mcp.mdx
kathayl af05cdc
Small improvements
celso 3728238
Merge branch 'playwright-mcp' of github.com:cloudflare/cloudflare-doc…
celso dfd67b8
Update and rename 2025-05-26-playwright-mcp.mdx to 2025-05-28-playwri…
kathayl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
src/content/changelog/browser-rendering/2025-05-26-playwright-mcp.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| title: Playwright MCP server is now compatible with Browser Rendering | ||
| description: You can now deploy Playwright MCP and use any MCP client to get AI models to interact with Browser Rendering | ||
| products: | ||
| - browser-rendering | ||
| date: 2025-05-26T17:00:00Z | ||
| --- | ||
|
|
||
| We're excited to share that you can now use the [Playwright MCP](https://github.com/cloudflare/playwright-mcp) server with Browser Rendering. | ||
|
|
||
| Once you [deploy the server](/browser-rendering/platform/playwright-mcp/#deploying), you can use any MCP client with it to interact with Browser Rendering. This allows you to run AI models that can automate browser tasks, such as taking screenshots, filling out forms, or scraping data. | ||
|
|
||
|  | ||
|
|
||
| Playwright MCP is available as an npm package at [`@cloudflare/playwright-mcp`](https://www.npmjs.com/package/@cloudflare/playwright-mcp). To install it, type: | ||
|
|
||
| ```bash | ||
| npm install @cloudflare/playwright-mcp --save-dev | ||
| ``` | ||
|
|
||
| Deploying the server is then as easy as: | ||
|
|
||
| ```ts | ||
| import { env } from 'cloudflare:workers'; | ||
| import { createMcpAgent } from '@cloudflare/playwright-mcp'; | ||
|
|
||
| export const PlaywrightMCP = createMcpAgent(env.BROWSER); | ||
| export default PlaywrightMCP.mount('/sse'); | ||
| ``` | ||
|
|
||
| Check out the full code at [GitHub](https://github.com/cloudflare/playwright-mcp). | ||
|
|
||
| Learn more about Playwright MCP in our [documentation](/browser-rendering/platform/playwright-mcp/). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/content/docs/browser-rendering/platform/playwright-mcp.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| --- | ||
| pcx_content_type: concept | ||
| title: Playwright MCP | ||
| description: Deploy a Playwright MCP server that uses Browser Rendering to provide browser automation capabilities to your agents. | ||
| sidebar: | ||
| order: 6 | ||
| badge: Beta | ||
| --- | ||
|
|
||
| import { | ||
| Render, | ||
| WranglerConfig, | ||
| TabItem, | ||
| Tabs, | ||
| PackageManagers, | ||
| } from "~/components"; | ||
|
|
||
| [`@cloudflare/playwright-mcp`](https://github.com/cloudflare/playwright-mcp) is a [Playwright MCP](https://github.com/microsoft/playwright-mcp) server fork that provides browser automation capabilities using Playwright and Browser Rendering. | ||
|
|
||
| This server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models. Its key features are: | ||
|
|
||
| * Fast and lightweight. Uses Playwright's accessibility tree, not pixel-based input. | ||
| * LLM-friendly. No vision models needed, operates purely on structured data. | ||
| * Deterministic tool application. Avoids ambiguity common with screenshot-based approaches. | ||
|
|
||
| ## Deploying | ||
|
|
||
| Follow these steps to deploy `@cloudflare/playwright-mcp`: | ||
|
|
||
| 1. Install the Playwright MCP [npm package](https://www.npmjs.com/package/@cloudflare/playwright-mcp). | ||
|
|
||
| <PackageManagers pkg="@cloudflare/playwright-mcp" dev /> | ||
|
|
||
| 2. Make sure you have the [browser rendering](https://developers.cloudflare.com/browser-rendering/) and [durable object](https://developers.cloudflare.com/durable-objects/) bindings and [migrations](https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/) configured in your wrangler.toml file. | ||
celso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <WranglerConfig> | ||
|
|
||
| ```toml | ||
| name = "playwright-mcp-example" | ||
| main = "src/index.ts" | ||
| compatibility_date = "2025-03-10" | ||
| compatibility_flags = ["nodejs_compat"] | ||
|
|
||
| [browser] | ||
| binding = "BROWSER" | ||
|
|
||
| [[migrations]] | ||
| tag = "v1" | ||
| new_sqlite_classes = ["PlaywrightMCP"] | ||
|
|
||
| [[durable_objects.bindings]] | ||
| name = "MCP_OBJECT" | ||
| class_name = "PlaywrightMCP" | ||
| ``` | ||
|
|
||
| </WranglerConfig> | ||
|
|
||
| 3. Edit the code. | ||
|
|
||
| ```ts title="src/index.ts" | ||
| import { env } from 'cloudflare:workers'; | ||
| import { createMcpAgent } from '@cloudflare/playwright-mcp'; | ||
|
|
||
| export const PlaywrightMCP = createMcpAgent(env.BROWSER); | ||
| export default PlaywrightMCP.mount('/sse'); | ||
| ``` | ||
|
|
||
| 4. Deploy the server. | ||
|
|
||
| ```bash | ||
| npx wrangler deploy | ||
| ``` | ||
|
|
||
| The server is now available at `https://[my-mcp-url].workers.dev/sse` and you can use it with any MCP client. | ||
|
|
||
| Alternatively, use "[Deploy to Cloudflare](https://developers.cloudflare.com/workers/platform/deploy-buttons/)": | ||
|
|
||
| [](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/playwright-mcp/tree/main/cloudflare/example) | ||
|
|
||
| Check our [GitHub page](https://github.com/cloudflare/playwright-mcp) for more information on how to build and deploy Playwright MCP. | ||
|
|
||
| ## Using Playwright MCP | ||
|
|
||
|  | ||
|
|
||
| [Cloudflare playground AI](https://playground.ai.cloudflare.com/) is a great way to test MCP servers using LLM models available in Workers AI. | ||
|
|
||
| - Navigate to https://playground.ai.cloudflare.com/ | ||
| - Ensure model is set to `llama-3.3-70b-instruct-fp8-fast` | ||
| - In **MCP Servers**, set **URL** to `https://[my-mcp-url].workers.dev/sse` | ||
| - Click **Connect** | ||
| - Status should update to **Connected** and it should list 14 available tools | ||
|
|
||
| You can now start to interact with the model, and it will run necessary tools to accomplish what was requested. | ||
|
|
||
| :::note | ||
|
|
||
| For best results, give simple instructions consisting of one single action, e. g., "Create a new todo entry", "Go to cloudflare site", "Take a screenshot" | ||
celso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ::: | ||
|
|
||
| Try this sequence of instructions too see Playwright MCP in action: | ||
celso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * Go to demo.playwright.dev/todomvc | ||
| * Create some todo entry | ||
| * Nice. Now create a todo in parrot style | ||
| * And create another todo in yoda style | ||
| * Take a screenshot | ||
celso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You can also use other MCP clients like [Claude Desktop](https://github.com/cloudflare/playwright-mcp/blob/main/cloudflare/example/README.md#use-with-claude-desktop). | ||
|
|
||
| Check our [GitHub page](https://github.com/cloudflare/playwright-mcp) for more examples and MCP client configuration options. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.