Skip to content
Back to search

playwright-mcp

Playwright MCP fork that works with Cloudflare Browser Rendering

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/cloudflare--playwright-mcp/badge.svg)](/listings/cloudflare--playwright-mcp)

HTML

<a href="/listings/cloudflare--playwright-mcp"><img src="/api/listings/cloudflare--playwright-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 508 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ## Cloudflare Playwright MCP
  2. [![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)
  3. ### Overview
  4. 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.
  5. ### Build and Deploy
  6. Follow these steps to set up and deploy the project:
  7. 1. Install dependencies:
  8. ```bash
  9. npm ci
  10. ```
  11. 2. Build:
  12. ```bash
  13. cd cloudflare
  14. npm run build
  15. ```
  16. 3. Deploy to Cloudflare Workers:
  17. ```bash
  18. cd cloudflare/example
  19. npm ci
  20. npx wrangler deploy
  21. ```
  22. ### Use with Cloudflare AI Playground
  23. ![alt text](docs/imgs/playground-ai-screenshot.png)
  24. [Cloudflare playground AI](https://playground.ai.cloudflare.com/) is a great way to test MCP servers using LLM models available in Workers AI.
  25. - Navigate to https://playground.ai.cloudflare.com/
  26. - Ensure model is set to `llama-3.3-70b-instruct-fp8-fast`
  27. - In **MCP Servers**, set **URL** to `https://[my-mcp-url].workers.dev/sse`
  28. - Click **Connect**
  29. - Status should update to **Connected** and it should list 14 available tools
  30. You can now start to interact with the model, and it will run necessary tools to accomplish what was requested.
  31. > [!TIP]
  32. > 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"
  33. Example of a conversation:
  34. | Role | Message |
  35. |------|---------|
  36. | **User** | Go to demo.playwright.dev/todomvc |
  37. | **Assistant** | *runs browser_navigate tool*<br> The page has been navigated to https://demo.playwright.dev/todomvc/. The page title is "React • TodoMVC". The page snapshot shows the content of the page, including a heading, a textbox, and several links. |
  38. | **User** | Create some todo entry |
  39. | **Assistant** | *runs browser_type tool*<br> A new todo entry "Buy groceries" has been created. The page snapshot shows the updated content of the page, including the new todo entry. |
  40. | **User** | Nice. Now create a todo in parrot style |
  41. | **Assistant** | *runs browser_type tool*<br> A new todo entry "Polly wants a cracker" has been created in parrot style. The page snapshot shows the updated content of the page, including the new todo entry. |
  42. | **User** | And create another todo in yoda style |
  43. | **Assistant** | *runs browser_type tool*<br> A new todo entry "A walk, I must take" has been created in Yoda style. The page snapshot shows the updated content of the page, including the new todo entry. |
  44. | **User** | Take a screenshot |
  45. | **Assistant** | *runs browser_take_screenshot tool*<br> ![alt text](docs/imgs/todomvc-screenshot-1.png) A screenshot of the current page has been taken. The screenshot is in PNG format and is 56KB in size. |
  46. | **User** | Now click the checkbox of the parrot todo entry |
  47. | **Assistant** | *runs browser_clickt tool*<br> The checkbox of the parrot todo entry "Polly wants a cracker" has been clicked. The page snapshot shows the updated content of the page, with the checkbox now checked. |
  48. | **User** | Take a screenshot |
  49. | **Assistant** | *runs browser_take_screenshot tool*<br> ![alt text](docs/imgs/todomvc-screenshot-2.png) A screenshot of the current page has been taken. The screenshot is in PNG format and is 58KB in size. |
  50. | **User** | Remove completed todo entries |
  51. | **Assistant** | *runs browser_clickt tool*<br> The "Clear completed" button has been clicked. The page snapshot shows the updated content of the page, with the completed todo entry "Polly wants a cracker" removed. |
  52. | **User** | Take a final screenshot |
  53. | **Assistant** | *runs browser_take_screenshot tool*<br> ![alt text](docs/imgs/todomvc-screenshot-3.png) A final screenshot of the current page has been taken. The screenshot is in PNG format and is 50KB in size. |
  54. ### Use with Claude Desktop
  55. As of now, [Claude Desktop](https://claude.ai/download) only supports local MCP servers. To use `playground-mcp` with Claude Desktop we make use of [mcp-remote](https://github.com/geelen/mcp-remote), a tool that proxies remote MCP servers and exposes them locally. Use the following configuration:
  56. 1. Open the configuration file for Claude Desktop.
  57. 2. Add the following JSON snippet under the `mcpServers` section:
  58. ```json
  59. {
  60. "mcpServers": {
  61. "cloudflare-playwright-mcp": {
  62. "command": "npx",
  63. "args": [
  64. "mcp-remote",
  65. "https://[my-mcp-url].workers.dev/sse"
  66. ]
  67. }
  68. }
  69. }
  70. ```
  71. 3. Save the configuration file and **restart** Claude Desktop to apply the changes.
  72. This setup ensures that Claude Desktop can communicate with the Cloudflare Playwright MCP server.
  73. Here's an example of a session opening the TODO demo app, adding "buy lemons" and doing a screenshot, taking advantage of playwright-mcp tools and Browser Rendering:
  74. ![alt text](docs/imgs/claudemcp.gif)
  75. ### Configure in VSCode
  76. You can install the Playwright MCP server using the [VS Code CLI](https://code.visualstudio.com/docs/configure/command-line):
  77. ```bash
  78. # For VS Code
  79. code --add-mcp '{"name":"cloudflare-playwright","type":"sse","url":"https://[my-mcp-url].workers.dev/sse"}'
  80. ```
  81. ```bash
  82. # For VS Code Insiders
  83. code-insiders --add-mcp '{"name":"cloudflare-playwright","type":"sse","url":"https://[my-mcp-url].workers.dev/sse"}'
  84. ```
  85. After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code.
  86. ### Use with Cursor
  87. By default, when `imageResponses` is set to `"auto"`, the server disables inline image responses for Cursor clients. To enable inline screenshots in Cursor, you need to override this behavior:
  88. If you're running your own Cloudflare Worker, pass `imageResponses: "allow"` when creating the MCP agent:
  89. ```typescript
  90. export const PlaywrightMCP = createMcpAgent(env.BROWSER, {
  91. imageResponses: 'allow',
  92. } as any);
  93. ```
  94. ### Tool Modes
  95. The tools are available in two modes:
  96. 1. **Snapshot Mode** (default): Uses accessibility snapshots for better performance and reliability
  97. 2. **Vision Mode**: Uses screenshots for visual-based interactions
  98. Vision Mode works best with the computer use models that are able to interact with elements using
  99. X Y coordinate space, based on the provided screenshot.
  100. <!--- Tools generated by update-readme.js -->
  101. <details>
  102. <summary><b>Interactions</b></summary>
  103. <!-- NOTE: This has been generated via update-readme.js -->
  104. - **browser_snapshot**
  105. - Title: Page snapshot
  106. - Description: Capture accessibility snapshot of the current page, this is better than screenshot
  107. - Parameters: None
  108. - Read-only: **true**
  109. <!-- NOTE: This has been generated via update-readme.js -->
  110. - **browser_click**
  111. - Title: Click
  112. - Description: Perform click on a web page
  113. - Parameters:
  114. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  115. - `ref` (string): Exact target element reference from the page snapshot
  116. - `doubleClick` (boolean, optional): Whether to perform a double click instead of a single click
  117. - Read-only: **false**
  118. <!-- NOTE: This has been generated via update-readme.js -->
  119. - **browser_drag**
  120. - Title: Drag mouse
  121. - Description: Perform drag and drop between two elements
  122. - Parameters:
  123. - `startElement` (string): Human-readable source element description used to obtain the permission to interact with the element
  124. - `startRef` (string): Exact source element reference from the page snapshot
  125. - `endElement` (string): Human-readable target element description used to obtain the permission to interact with the element
  126. - `endRef` (string): Exact target element reference from the page snapshot
  127. - Read-only: **false**
  128. <!-- NOTE: This has been generated via update-readme.js -->
  129. - **browser_hover**
  130. - Title: Hover mouse
  131. - Description: Hover over element on page
  132. - Parameters:
  133. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  134. - `ref` (string): Exact target element reference from the page snapshot
  135. - Read-only: **true**
  136. <!-- NOTE: This has been generated via update-readme.js -->
  137. - **browser_type**
  138. - Title: Type text
  139. - Description: Type text into editable element
  140. - Parameters:
  141. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  142. - `ref` (string): Exact target element reference from the page snapshot
  143. - `text` (string): Text to type into the element
  144. - `submit` (boolean, optional): Whether to submit entered text (press Enter after)
  145. - `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.
  146. - Read-only: **false**
  147. <!-- NOTE: This has been generated via update-readme.js -->
  148. - **browser_select_option**
  149. - Title: Select option
  150. - Description: Select an option in a dropdown
  151. - Parameters:
  152. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  153. - `ref` (string): Exact target element reference from the page snapshot
  154. - `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values.
  155. - Read-only: **false**
  156. <!-- NOTE: This has been generated via update-readme.js -->
  157. - **browser_press_key**
  158. - Title: Press a key
  159. - Description: Press a key on the keyboard
  160. - Parameters:
  161. - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
  162. - Read-only: **false**
  163. <!-- NOTE: This has been generated via update-readme.js -->
  164. - **browser_wait_for**
  165. - Title: Wait for
  166. - Description: Wait for text to appear or disappear or a specified time to pass
  167. - Parameters:
  168. - `time` (number, optional): The time to wait in seconds
  169. - `text` (string, optional): The text to wait for
  170. - `textGone` (string, optional): The text to wait for to disappear
  171. - Read-only: **true**
  172. <!-- NOTE: This has been generated via update-readme.js -->
  173. - **browser_file_upload**
  174. - Title: Upload files
  175. - Description: Upload one or multiple files
  176. - Parameters:
  177. - `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
  178. - Read-only: **false**
  179. <!-- NOTE: This has been generated via update-readme.js -->
  180. - **browser_handle_dialog**
  181. - Title: Handle a dialog
  182. - Description: Handle a dialog
  183. - Parameters:
  184. - `accept` (boolean): Whether to accept the dialog.
  185. - `promptText` (string, optional): The text of the prompt in case of a prompt dialog.
  186. - Read-only: **false**
  187. </details>
  188. <details>
  189. <summary><b>Navigation</b></summary>
  190. <!-- NOTE: This has been generated via update-readme.js -->
  191. - **browser_navigate**
  192. - Title: Navigate to a URL
  193. - Description: Navigate to a URL
  194. - Parameters:
  195. - `url` (string): The URL to navigate to
  196. - Read-only: **false**
  197. <!-- NOTE: This has been generated via update-readme.js -->
  198. - **browser_navigate_back**
  199. - Title: Go back
  200. - Description: Go back to the previous page
  201. - Parameters: None
  202. - Read-only: **true**
  203. <!-- NOTE: This has been generated via update-readme.js -->
  204. - **browser_navigate_forward**
  205. - Title: Go forward
  206. - Description: Go forward to the next page
  207. - Parameters: None
  208. - Read-only: **true**
  209. </details>
  210. <details>
  211. <summary><b>Resources</b></summary>
  212. <!-- NOTE: This has been generated via update-readme.js -->
  213. - **browser_take_screenshot**
  214. - Title: Take a screenshot
  215. - Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.
  216. - Parameters:
  217. - `raw` (boolean, optional): Whether to return without compression (in PNG format). Default is false, which returns a JPEG image.
  218. - `filename` (string, optional): File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.
  219. - `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.
  220. - `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.
  221. - Read-only: **true**
  222. <!-- NOTE: This has been generated via update-readme.js -->
  223. - **browser_pdf_save**
  224. - Title: Save as PDF
  225. - Description: Save page as PDF
  226. - Parameters:
  227. - `filename` (string, optional): File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.
  228. - Read-only: **true**
  229. <!-- NOTE: This has been generated via update-readme.js -->
  230. - **browser_network_requests**
  231. - Title: List network requests
  232. - Description: Returns all network requests since loading the page
  233. - Parameters: None
  234. - Read-only: **true**
  235. <!-- NOTE: This has been generated via update-readme.js -->
  236. - **browser_console_messages**
  237. - Title: Get console messages
  238. - Description: Returns all console messages
  239. - Parameters: None
  240. - Read-only: **true**
  241. </details>
  242. <details>
  243. <summary><b>Utilities</b></summary>
  244. <!-- NOTE: This has been generated via update-readme.js -->
  245. - **browser_install**
  246. - Title: Install the browser specified in the config
  247. - Description: Install the browser specified in the config. Call this if you get an error about the browser not being installed.
  248. - Parameters: None
  249. - Read-only: **false**
  250. <!-- NOTE: This has been generated via update-readme.js -->
  251. - **browser_close**
  252. - Title: Close browser
  253. - Description: Close the page
  254. - Parameters: None
  255. - Read-only: **true**
  256. <!-- NOTE: This has been generated via update-readme.js -->
  257. - **browser_resize**
  258. - Title: Resize browser window
  259. - Description: Resize the browser window
  260. - Parameters:
  261. - `width` (number): Width of the browser window
  262. - `height` (number): Height of the browser window
  263. - Read-only: **true**
  264. </details>
  265. <details>
  266. <summary><b>Tabs</b></summary>
  267. <!-- NOTE: This has been generated via update-readme.js -->
  268. - **browser_tab_list**
  269. - Title: List tabs
  270. - Description: List browser tabs
  271. - Parameters: None
  272. - Read-only: **true**
  273. <!-- NOTE: This has been generated via update-readme.js -->
  274. - **browser_tab_new**
  275. - Title: Open a new tab
  276. - Description: Open a new tab
  277. - Parameters:
  278. - `url` (string, optional): The URL to navigate to in the new tab. If not provided, the new tab will be blank.
  279. - Read-only: **true**
  280. <!-- NOTE: This has been generated via update-readme.js -->
  281. - **browser_tab_select**
  282. - Title: Select a tab
  283. - Description: Select a tab by index
  284. - Parameters:
  285. - `index` (number): The index of the tab to select
  286. - Read-only: **true**
  287. <!-- NOTE: This has been generated via update-readme.js -->
  288. - **browser_tab_close**
  289. - Title: Close a tab
  290. - Description: Close a tab
  291. - Parameters:
  292. - `index` (number, optional): The index of the tab to close. Closes current tab if not provided.
  293. - Read-only: **false**
  294. </details>
  295. <details>
  296. <summary><b>Testing</b></summary>
  297. <!-- NOTE: This has been generated via update-readme.js -->
  298. - **browser_generate_playwright_test**
  299. - Title: Generate a Playwright test
  300. - Description: Generate a Playwright test for given scenario
  301. - Parameters:
  302. - `name` (string): The name of the test
  303. - `description` (string): The description of the test
  304. - `steps` (array): The steps of the test
  305. - Read-only: **true**
  306. </details>
  307. <details>
  308. <summary><b>Vision mode</b></summary>
  309. <!-- NOTE: This has been generated via update-readme.js -->
  310. - **browser_screen_capture**
  311. - Title: Take a screenshot
  312. - Description: Take a screenshot of the current page
  313. - Parameters: None
  314. - Read-only: **true**
  315. <!-- NOTE: This has been generated via update-readme.js -->
  316. - **browser_screen_move_mouse**
  317. - Title: Move mouse
  318. - Description: Move mouse to a given position
  319. - Parameters:
  320. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  321. - `x` (number): X coordinate
  322. - `y` (number): Y coordinate
  323. - Read-only: **true**
  324. <!-- NOTE: This has been generated via update-readme.js -->
  325. - **browser_screen_click**
  326. - Title: Click
  327. - Description: Click left mouse button
  328. - Parameters:
  329. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  330. - `x` (number): X coordinate
  331. - `y` (number): Y coordinate
  332. - Read-only: **false**
  333. <!-- NOTE: This has been generated via update-readme.js -->
  334. - **browser_screen_drag**
  335. - Title: Drag mouse
  336. - Description: Drag left mouse button
  337. - Parameters:
  338. - `element` (string): Human-readable element description used to obtain permission to interact with the element
  339. - `startX` (number): Start X coordinate
  340. - `startY` (number): Start Y coordinate
  341. - `endX` (number): End X coordinate
  342. - `endY` (number): End Y coordinate
  343. - Read-only: **false**
  344. <!-- NOTE: This has been generated via update-readme.js -->
  345. - **browser_screen_type**
  346. - Title: Type text
  347. - Description: Type text
  348. - Parameters:
  349. - `text` (string): Text to type into the element
  350. - `submit` (boolean, optional): Whether to submit entered text (press Enter after)
  351. - Read-only: **false**
  352. <!-- NOTE: This has been generated via update-readme.js -->
  353. - **browser_press_key**
  354. - Title: Press a key
  355. - Description: Press a key on the keyboard
  356. - Parameters:
  357. - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
  358. - Read-only: **false**
  359. <!-- NOTE: This has been generated via update-readme.js -->
  360. - **browser_wait_for**
  361. - Title: Wait for
  362. - Description: Wait for text to appear or disappear or a specified time to pass
  363. - Parameters:
  364. - `time` (number, optional): The time to wait in seconds
  365. - `text` (string, optional): The text to wait for
  366. - `textGone` (string, optional): The text to wait for to disappear
  367. - Read-only: **true**
  368. <!-- NOTE: This has been generated via update-readme.js -->
  369. - **browser_file_upload**
  370. - Title: Upload files
  371. - Description: Upload one or multiple files
  372. - Parameters:
  373. - `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
  374. - Read-only: **false**
  375. <!-- NOTE: This has been generated via update-readme.js -->
  376. - **browser_handle_dialog**
  377. - Title: Handle a dialog
  378. - Description: Handle a dialog
  379. - Parameters:
  380. - `accept` (boolean): Whether to accept the dialog.
  381. - `promptText` (string, optional): The text of the prompt in case of a prompt dialog.
  382. - Read-only: **false**
  383. </details>
  384. <!--- End of tools generated section -->

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.