Skip to content

Commit 8fe3fa2

Browse files
committed
Modify to support returning mcp browser contexts and popup analysis
feat: enhance Connection type with context and improve createConnection signature - Added context property to the Connection type for better state management. - Reformatted createConnection function signature for improved readability. chore: update package version to 0.0.29-1 fix: update import path for Context and adjust package name in package-lock.json - Changed import path for Context from "./lib/context.js" to "./src/context.ts". - Updated package name in package-lock.json to "@asteroid_ai/playwright-mcp". chore: set package as non-private - Updated package.json to set "private" to false, allowing for potential publishing. chore: update package name to remove scope - Changed package name from "@asteroid_ai/playwright-mcp" to "asteroid-playwright-mcp" in package.json. chore: update import path for Context and increment package version - Changed import path for Context from "./src/context.ts" to "./lib/context.js". - Incremented package version to 0.0.29-2 in package.json. chore: update import path for Context and increment package version - Changed import path for Context from "./lib/context.js" to "./lib/context.d.ts". - Incremented package version to 0.0.29-3 in package.json. chore: update import paths and increment package version - Changed import path for Context from "./lib/context.d.ts" to "./src/context.js". - Added import for Tab from "./src/tab.js". - Incremented package version to 0.0.29-4 in package.json. - Removed "declaration" option from tsconfig.json. feat: add context and tab type definitions - Introduced new type definitions for Context and Tab in context.d.ts and tab.d.ts respectively. - Updated import paths in index.d.ts to reflect the new file structure. - Enhanced type safety and modularity for better code organization. chore: update package version to 0.0.29-6 and include additional type definitions - Incremented package version to 0.0.29-6 in package.json. - Added context.d.ts and tab.d.ts to .npmignore exceptions for better type definition management. chore: increment package version to 0.0.29-7 and refactor context.ts for improved readability - Updated package version to 0.0.29-7 in package.json. - Refactored code in context.ts for better readability, including consistent formatting and improved handling of popups. chore: increment package version to 0.0.29-8 and enhance context.ts for async handling - Updated package version to 0.0.29-8 in package.json. - Improved async handling in context.ts by awaiting page creation and popup handling for better reliability. chore: increment package version to 0.0.29-9 and simplify page creation handling in context.ts - Updated package version to 0.0.29-9 in package.json. - Simplified the page creation logic in context.ts by removing unnecessary popup handling checks. Revert "chore: increment package version to 0.0.29-9 and simplify page creation handling in context.ts" This reverts commit fff3d31. Revert "chore: increment package version to 0.0.29-7 and refactor context.ts for improved readability" This reverts commit 33033cf. chore: increment package version to 0.0.29-10 in package.json fix: enhance popup handling in context.ts - Added a private flag _isHandlingPopup to manage popup state. - Updated _onPageCreated to handle popups asynchronously and convert them to tabs when detected. - Ensured proper handling of popup state during conversion to maintain tab integrity. chore: increment package version to 0.0.29-11 in package.json chore: increment package version to 0.0.29-12 in package.json and enhance popup handling in context.ts - Updated package version to 0.0.29-12 in package.json. - Removed the private flag _isHandlingPopup and implemented a new method _handlePopup to manage popup windows more effectively. - Improved the logic for detecting and converting popups to tabs, ensuring better handling of various popup scenarios. chore: increment package version to 0.0.29-13 in package.json chore: increment package version to 0.0.29-14 in package.json and remove redundant popup navigation wait in context.ts fix: improve download error handling in context.ts - Added error handling for download.saveAs to log any issues during the save process. - Ensured that entry.finished is set to true regardless of the success or failure of the download operation. feat: introduce everyTool export and update connection logic - Added everyTool export in tools.ts to combine snapshotTools and visionTools. - Updated createConnection function in connection.ts to use everyTool by default, with conditional logic for visionTools based on config.vision. chore: increment package version to 0.0.29-16 in package.json chore: increment package version to 0.0.29-17 in package.json fix: only include one version of each tool in `everyTool` feat: enhance popup event logging in context.ts - Added console logs to track popup events, including when a popup is received, if it is a valid popup window, and when it is closed. - Improved visibility into the popup handling process for better debugging and monitoring. chore: increment package version to 0.0.29-19 in package.json chore: increment package version to 0.0.29-20 in package.json and streamline popup handling in context.ts - Updated package version to 0.0.29-20 in package.json. - Simplified the popup handling logic by directly checking the created page for popups and logging relevant events. - Introduced a set of standard target names to improve the detection of popup windows. chore: increment package version to 0.0.29-21 in package.json and enhance popup detection logic in context.ts - Updated package version to 0.0.29-21 in package.json. - Improved the popup detection logic by adding additional indicators and checks for popup-like features, enhancing the accuracy of the `_isPopupWindow` method. chore: increment package version to 0.0.29-22 in package.json and refactor popup detection logic in context.ts - Updated package version to 0.0.29-22 in package.json. - Refactored the `_isPopupWindow` method to utilize a new `popupAnalysis` function for improved popup detection. - Enhanced the analysis process with additional checks and confidence scoring for better accuracy in identifying popup windows. fix: update type for reasons array and improve window resizability check in popup analysis - Changed the type of the `reasons` array to explicitly be an array of strings for better type safety. - Updated the check for window resizability to use a more explicit boolean expression. fix: add error logging for popup window detection in context.ts - Introduced console error logging to capture and report errors encountered during the popup window detection process, improving debugging capabilities. chore: increment package version to 0.0.29-23 in package.json chore: increment package version to 0.0.29-24 in package.json and refactor popup analysis to be asynchronous - Updated package version to 0.0.29-24 in package.json. - Refactored the `popupAnalysis` function to be asynchronous, allowing for better handling of page evaluations. - Updated the call to `popupAnalysis` in `context.ts` to await the result, improving the flow of popup detection. chore: increment package version to 0.0.29-25 in package.json and move THRESHOLD constant inside popupAnalysis function - Updated package version to 0.0.29-25 in package.json. - Moved the `THRESHOLD` constant inside the `popupAnalysis` function for better encapsulation and clarity. chore: increment package version to 0.0.29-26 in package.json chore: increment package version to 0.0.29-27 in package.json and add logging for popup URL in context.ts - Updated package version to 0.0.29-27 in package.json. - Added a console log to output the URL of the popup for better debugging and tracking of popup behavior. refactor: update popup handling to create a new page instead of a new tab in context.ts - Changed the logic to create a new page directly and navigate to the popup URL, improving the handling of popups. - Updated error handling to log navigation failures for better debugging. chore: increment package version to 0.0.29-29 in package.json and enhance error handling in context.ts - Updated package version to 0.0.29-29 in package.json. - Improved error handling for popup management in context.ts, including timeout handling for URL fetching and enhanced logging for better debugging. refactor: simplify popup URL fetching in context.ts - Removed timeout handling for fetching the popup URL, streamlining the process. - Enhanced logging to output the fetched popup URL for better debugging. chore: increment package version to 0.0.29-31 in package.json and ensure popup page loads before fetching URL in context.ts - Updated package version to 0.0.29-31 in package.json. - Added a wait for the "domcontentloaded" state before fetching the popup URL in context.ts to improve reliability. chore: increment package version to 0.0.29-32 in package.json and enhance popup URL retrieval logic in context.ts - Updated package version to 0.0.29-32 in package.json. - Improved the logic for fetching the popup URL in context.ts with retry attempts and error handling to ensure reliability. refactor: enhance popup handling logic in context.ts - Updated _handlePopup method to return a boolean indicating if a popup was handled. - Improved error handling and logging for popup URL retrieval and closing popups. - Streamlined the logic to avoid unnecessary tab additions when a popup is detected. refactor: improve popup URL retrieval with retry logic in context.ts - Enhanced the _handlePopup method to implement a retry mechanism for fetching the popup URL, allowing up to three attempts. - Improved error handling and logging during the URL retrieval process. - Adjusted return values to better reflect the success of popup handling. chore: increment package version to 0.0.29-35 in package.json and extend timeout for popup URL fetching in context.ts - Updated package version to 0.0.29-35 in package.json. - Increased the timeout duration for waiting on popup URL resolution from 1500ms to 2500ms in context.ts to improve reliability. chore: increment package version to 0.0.29-36 in package.json and adjust timeout for popup URL fetching in context.ts - Updated package version to 0.0.29-36 in package.json. - Increased the timeout duration for waiting on popup URL resolution from 2500ms to 3000ms in context.ts to enhance reliability. - Ensured that the current tab is always switched to the newly created tab in context.ts. chore: increment package version to 0.0.29-37 in package.json and extend timeout for popup URL fetching in context.ts - Updated package version to 0.0.29-37 in package.json. - Increased the timeout duration for waiting on popup URL resolution from 3000ms to 4000ms in context.ts to enhance reliability. chore: increment package version to 0.0.29-38 in package.json and improve context closure handling in context.ts - Updated package version to 0.0.29-38 in package.json. - Enhanced the logic in context.ts to log a message and handle errors when closing the context if no tabs are left, improving robustness. chore: increment package version to 0.0.29-39 in package.json and refine context closure handling in context.ts - Updated package version to 0.0.29-39 in package.json. - Simplified the context closure logic in context.ts to use a promise-based approach for error handling, improving code clarity and robustness. refactor: implement retry logic for dialog handling in dialogs.ts - Added a retry mechanism to the dialog handling process, allowing up to three attempts to accept or dismiss the dialog, improving robustness against transient errors. - Ensured that the dialog state is always cleared after handling, regardless of success or failure. chore: add .prettierignore and standardize import quotes in TypeScript files - Introduced a .prettierignore file to exclude all files from formatting. - Standardized import statements across TypeScript files to use single quotes for consistency. - Updated package name in package-lock.json and README.md to reflect the new naming convention. - Enhanced linting script in package.json to automatically fix issues during linting. refactor: comment out console error and log statements in context.ts and dialogs.ts - Commented out various console log and error statements in context.ts to reduce noise during execution. - Updated dialog handling in dialogs.ts by commenting out the error logging to streamline the process. chore(extension): support reconnect, implement relay-extension protocol (microsoft#602) chore(extension): convert to typescript (microsoft#603) chore(extension): wrap CDP protocol (microsoft#604) fix(docs): Fix typo of windsurf in readme (microsoft#620) devops(docker): enhance Docker image publishing with ORAS end-of-life tagging (microsoft#641) This tags the images we publish as EOL immediately in order to get excluded from the image scanning. Like we do upstream in microsoft/playwright. docs: adding installation steps for Gemini CLI (microsoft#625) I just tried it out with Gemini CLI and it works like a charm, thanks for creating this MCP server! docs: add instructions to install in Goose (microsoft#580) docs: Update README about imageResponses option. (microsoft#646) feat(dblclick): add double click (microsoft#654) Fixes microsoft#652 chore: update to 1.54.0 (microsoft#653) Closes microsoft#535 chore: roll Playwright to 1.54.1 (microsoft#665) chore: remove extension code (microsoft#667) chore: mark v0.0.30 (microsoft#666) chore: migrate to locator._resolveSelector (microsoft#670) chore: include page errors in console messages (microsoft#671) Fixes microsoft#669 chore: make tab indexes 0-based (microsoft#674) Fixes microsoft#570 chore: resolve dialog races (microsoft#673) Fixes microsoft#595 chore: remove generate_test tool for now - it adds no value (microsoft#675) chore: introduce browser_evaluate (microsoft#678) Fixes microsoft#424 chore: turn vision into capability (microsoft#679) Fixes microsoft#420 chore: remove server experiment (microsoft#681) chore: remove image reply special case in cursor (microsoft#680) chore: sort install sections (microsoft#682) chore: mirror cli options w/ env vars (microsoft#685) Fixes microsoft#639 chore: allow right click (microsoft#687) Fixes microsoft#467 chore: include recent console logs in results (microsoft#689) chore: mark v0.0.31 (microsoft#691) chore(docs): make VSCode match other README sections (microsoft#706) fix: no-sandbox flag logic to only disable sandbox when explicitly passed (microsoft#709) feat: add fullPage mode to browser_take_screenshot (microsoft#704) chore: add mcp chrome extension (microsoft#710) chore: add GitHub Copilot agent YAML specification (microsoft#715) chore: use streamable http by default (microsoft#716) Co-authored-by: Copilot <[email protected]> chore(extension): support running in http mode (microsoft#717) Add test for browser_evaluate error handling (microsoft#719) fix: browser_take_screenshot to not require snapshot unless element is specified (microsoft#725) chore: align lint w/ playwright (microsoft#729) chore(extension): find installed chrome (microsoft#728) chore: move state to tab, do not cache snapshot (microsoft#730) chore(extension): propagate errors to the client (microsoft#736) chore(extension): handle root session id in the relay (microsoft#737) chore: introduce response type (microsoft#738) chore: follow up on tab snapshot capture (microsoft#739) chore: save session log (microsoft#740) chore(extension): terminate all connections when tab closes (microsoft#741) docs: Add LM Studio installation instructions (microsoft#688) chore: add eval script (microsoft#743) chore: do not double close connection (microsoft#744) chore: unify loops (microsoft#745) chore: one tool experiment (microsoft#746) chore(extension): use free port (microsoft#735) chore(extension): page selector for MCP (microsoft#750) chore: extract pure mcp server helpers (microsoft#751) chore: wire one tool in-process (microsoft#753) chore(extension): exit gracefully when waiting for extension connection (microsoft#754) chore: extract loop tools into a separate folder (microsoft#755) chore: retain the source code from the underlying tools (microsoft#756) chore: recommend sse by default (microsoft#758) chore: ping client and disconnect on connection termination (microsoft#764) Revert "chore: recommend sse by default" (microsoft#765) Reverts microsoft#758 Sounds like the stock streamable implementation is to spec, so we can keep it. chore(extension): reject second http connection (microsoft#766) chore: do not snapshot on fill (microsoft#767) chore: mark v0.0.32 (microsoft#768) chore(extension): use react for connect dialog (microsoft#777) chore(extension): use separate package.json (microsoft#778) chore(extension): do not show chrome: tabs (microsoft#780) chore: parse response in tests (microsoft#796) chore: record user actions in the session log (microsoft#798) chore: make tab snapshot structured to mimic it in recorder (microsoft#799) chore: use pngs by default for screenshots (microsoft#797) 1. Use PNG by default. 1. Increase JPG quality from `50` -> `90`. chore: serialize session entries for tool calls and user actions (microsoft#803) chore(extension): bind relay lifetime to browser context (microsoft#804) chore: refactor initialize (microsoft#812) chore: slice profile dirs by root in vscode (microsoft#814) chore: allow to switch between browser connection methods (microsoft#815) chore(extension): terminate connection on debugger detach (microsoft#816) chore: follow up with win test fix (microsoft#818) chore(extension): build into dist directory (microsoft#825) fix: cursor does not respond to listRoots (microsoft#826) chore(extension): create relay per context (microsoft#828) chore(extension): terminate connection if nothing has been selected (microsoft#827) chore(extension): do not send if socket is already closed (microsoft#834) * Remove debugger listeners if closed() is called as `ws.onclosed` is dispatched asynchronously * Tabs can be closed while update badge command is in flight * Inflight CDP commands fail if the tab closes, do not try to send their response to a closed socket chore(extension): proper watchdog for inactive page selector (microsoft#835) chore(extension): show error when connection is rejected due to inact… (microsoft#836) …ivity chore(extension): add test (microsoft#842) * On Linux headed mode under xvfb-run fails to properly launch the process. It works fine without xvfb-run, we don't have environment for that on CI, so run on macOS instead. * Node v18.20.8 stalls on `const uuid = crypto.randomUUID();`, so use v20 for the extension tests. devops: switch to node 20 on CI (microsoft#844) Node 18 maintanence period ended in April 2025. Running on 18 already caused a problem in microsoft#842 chore(extension): explicitly detach from debugger when connection closes (microsoft#847) chore(extension): connect button for each page, style tweaks (microsoft#848) <img width="643" height="709" alt="image" src="https://github.com/user-attachments/assets/850f2455-b853-4c0f-8047-a7f2ced16b7b" /> fix(docs): Invalid MCP Install Link (microsoft#846) chore: do not return fullPage screenshots to the LLM (microsoft#849) chore: roll Playwright to recent (microsoft#850) chore: mark 0.0.33 (microsoft#851) chore(extension): status page (microsoft#856) fix: emit code for waitfor (microsoft#862) Fixes microsoft#859 chore: bump test workers to 2 on CI (microsoft#863) chore: mcp backend switcher (microsoft#854) chore: introduce check-deps (microsoft#864) fix(proxy): properly forward root requests and client metadata (microsoft#865) fix: backtick quote escaping (microsoft#871) chore: tool definition without zod (microsoft#873) chore: roll Playwright to latest (microsoft#875) chore: run test server per context (microsoft#874) Fixes microsoft#869 chore: extract utils folder (microsoft#876) chore: separate proxy client from external (microsoft#877) chore: steer towards mcp types a bit (microsoft#880) fix: wait for initialization to complete before listing tools (microsoft#886) chore: move tool schema to mcp as it is used by all servers (microsoft#887) chore: close all clients in fixture (microsoft#878) docs: add opencode installation instructions (microsoft#895) chore(extension): add readme file, recommend --extension option (microsoft#894) chore(extension): connection timeout when extension not installed (microsoft#896) chore: try macos15 runners (microsoft#892) devops: extension publishing job (microsoft#888) chore: handle list roots in the server, with timeout (microsoft#898) chore(extension): connected badge while loading (microsoft#899) devops: set-version.js script (microsoft#902) chore: fix copyright (microsoft#903) devops: update extension manifest version (microsoft#904) chore: mark 0.0.34 (microsoft#901) chore: do not wrap mcp in proxy by default, drive-by deps fix (microsoft#909) chore: check extension version on connect (microsoft#907) chore: check version in page, link to instructions (microsoft#918) chore(vscode): add vscode mcp factory (microsoft#868) docs: add instructions for installation in openai codex (microsoft#927) chore: show download link on the status mismatch page (microsoft#928) <img width="610" height="108" alt="image" src="https://github.com/user-attachments/assets/bc1f7534-f282-44f0-bb58-e385b2bf82af" /> chore(extension): do not show tab selector for browser_navigate (microsoft#923) chore: mdb stub (microsoft#912) chore: merge tabs tool into one (microsoft#933) chore: remove navigate_forward due to low usage counts (microsoft#934) chore: introduce form filling tool (microsoft#935) chore(extension): do not complain about old extension version (microsoft#937) chore: mark v0.0.35 (microsoft#938) chore: version extension-relay protocol (microsoft#939) chore(extension): support custom executablePath (microsoft#947) Fixes microsoft#941 chore: introduce verification tools (microsoft#951) chore: update README and extension background script - Removed deprecated arguments from README: `--extension` and `--save-session`. - Added new tab management functions to README: `browser_tab_close`, `browser_tab_list`, `browser_tab_new`, and `browser_tab_select`. - Updated background script to handle connection timeout more efficiently by using `void` with `chrome.tabs.sendMessage`. chore: update version and enhance README - Updated package and lock file versions to 0.0.35-0. - Added new arguments to README: `--extension` for connecting to a running browser instance and `--save-session` for saving the Playwright MCP session. - Revised screenshot parameters in README to clarify image format options. - Consolidated tab management functions in README under `browser_tabs`. feat: enhance connection handling in BrowserServerBackend - Added a new method `getContext` to retrieve the context from `BrowserServerBackend`, ensuring it is initialized. - Updated `createConnection` to return both the server and the context, improving the connection interface. chore: update version to 0.0.35-3 and refactor server creation - Incremented package version to 0.0.35-3 in package.json. - Refactored server creation in multiple files to use async/await for better handling of asynchronous operations, ensuring that server instances are fully initialized before use. chore: update version to 0.0.35-4 and improve tab selection error handling - Incremented package version to 0.0.35-4 in package.json. - Enhanced error handling in tab selection by checking for undefined index in tabs.ts. feat: enhance connection handling in BrowserServerBackend - Added `getContext` method to retrieve the context from `BrowserServerBackend`, ensuring it is initialized. - Updated `createConnection` to return both the server and the context, improving the connection interface. - Refactored server creation to use async/await for better handling of asynchronous operations. fix: improve error handling for tab selection in tabs.ts - Updated the tab selection logic to explicitly check for undefined index, ensuring that a valid tab index is provided before proceeding. This change enhances error reporting and prevents potential runtime issues.
1 parent 78298c3 commit 8fe3fa2

19 files changed

+695
-172
lines changed

.github/workflows/ci.yml

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -24,100 +24,100 @@ jobs:
2424
- name: Ensure no changes
2525
run: git diff --exit-code
2626

27-
test:
28-
strategy:
29-
fail-fast: false
30-
matrix:
31-
os: [ubuntu-latest, macos-15, windows-latest]
32-
runs-on: ${{ matrix.os }}
33-
steps:
34-
- uses: actions/checkout@v4
35-
- name: Use Node.js 20
36-
uses: actions/setup-node@v4
37-
with:
38-
node-version: '20'
39-
cache: 'npm'
40-
- name: Install dependencies
41-
run: npm ci
42-
- name: Playwright install
43-
run: npx playwright install --with-deps
44-
- name: Install MS Edge
45-
# MS Edge is not preinstalled on macOS runners.
46-
if: ${{ matrix.os == 'macos-latest' }}
47-
run: npx playwright install msedge
48-
- name: Build
49-
run: npm run build
50-
- name: Run tests
51-
run: npm test
27+
# test:
28+
# strategy:
29+
# fail-fast: false
30+
# matrix:
31+
# os: [ubuntu-latest, macos-15, windows-latest]
32+
# runs-on: ${{ matrix.os }}
33+
# steps:
34+
# - uses: actions/checkout@v4
35+
# - name: Use Node.js 20
36+
# uses: actions/setup-node@v4
37+
# with:
38+
# node-version: '20'
39+
# cache: 'npm'
40+
# - name: Install dependencies
41+
# run: npm ci
42+
# - name: Playwright install
43+
# run: npx playwright install --with-deps
44+
# - name: Install MS Edge
45+
# # MS Edge is not preinstalled on macOS runners.
46+
# if: ${{ matrix.os == 'macos-latest' }}
47+
# run: npx playwright install msedge
48+
# - name: Build
49+
# run: npm run build
50+
# - name: Run tests
51+
# run: npm test
5252

53-
test_docker:
54-
runs-on: ubuntu-latest
55-
steps:
56-
- uses: actions/checkout@v4
57-
- name: Use Node.js 20
58-
uses: actions/setup-node@v4
59-
with:
60-
node-version: '20'
61-
cache: 'npm'
62-
- name: Install dependencies
63-
run: npm ci
64-
- name: Playwright install
65-
run: npx playwright install --with-deps chromium
66-
- name: Build
67-
run: npm run build
68-
- name: Set up Docker Buildx
69-
uses: docker/setup-buildx-action@v3
70-
- name: Build and push
71-
uses: docker/build-push-action@v6
72-
with:
73-
tags: playwright-mcp-dev:latest
74-
cache-from: type=gha
75-
cache-to: type=gha,mode=max
76-
load: true
77-
- name: Run tests
78-
shell: bash
79-
run: |
80-
# Used for the Docker tests to share the test-results folder with the container.
81-
umask 0000
82-
npm run test -- --project=chromium-docker
83-
env:
84-
MCP_IN_DOCKER: 1
53+
# test_docker:
54+
# runs-on: ubuntu-latest
55+
# steps:
56+
# - uses: actions/checkout@v4
57+
# - name: Use Node.js 20
58+
# uses: actions/setup-node@v4
59+
# with:
60+
# node-version: '20'
61+
# cache: 'npm'
62+
# - name: Install dependencies
63+
# run: npm ci
64+
# - name: Playwright install
65+
# run: npx playwright install --with-deps chromium
66+
# - name: Build
67+
# run: npm run build
68+
# - name: Set up Docker Buildx
69+
# uses: docker/setup-buildx-action@v3
70+
# - name: Build and push
71+
# uses: docker/build-push-action@v6
72+
# with:
73+
# tags: playwright-mcp-dev:latest
74+
# cache-from: type=gha
75+
# cache-to: type=gha,mode=max
76+
# load: true
77+
# - name: Run tests
78+
# shell: bash
79+
# run: |
80+
# # Used for the Docker tests to share the test-results folder with the container.
81+
# umask 0000
82+
# npm run test -- --project=chromium-docker
83+
# env:
84+
# MCP_IN_DOCKER: 1
8585

86-
test_extension:
87-
strategy:
88-
fail-fast: false
89-
runs-on: macos-latest
90-
defaults:
91-
run:
92-
working-directory: ./extension
93-
steps:
94-
- uses: actions/checkout@v4
95-
- name: Use Node.js 20
96-
uses: actions/setup-node@v4
97-
with:
98-
node-version: '20' # crypto.randomUUID(); stalls in v18.20.8
99-
cache: 'npm'
100-
- name: Install dependencies
101-
run: npm ci
102-
- name: Build extension
103-
run: npm run build
104-
- name: Upload artifact
105-
uses: actions/upload-artifact@v4
106-
with:
107-
name: extension
108-
path: ./extension/dist
109-
retention-days: 7
110-
- name: Install and build MCP server
111-
run: |
112-
cd ..
113-
npm ci
114-
npm run build
115-
npx playwright install chromium
116-
- name: Run tests
117-
run: |
118-
if [[ "$(uname)" == "Linux" ]]; then
119-
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test
120-
else
121-
npm run test
122-
fi
123-
shell: bash
86+
# test_extension:
87+
# strategy:
88+
# fail-fast: false
89+
# runs-on: macos-latest
90+
# defaults:
91+
# run:
92+
# working-directory: ./extension
93+
# steps:
94+
# - uses: actions/checkout@v4
95+
# - name: Use Node.js 20
96+
# uses: actions/setup-node@v4
97+
# with:
98+
# node-version: '20' # crypto.randomUUID(); stalls in v18.20.8
99+
# cache: 'npm'
100+
# - name: Install dependencies
101+
# run: npm ci
102+
# - name: Build extension
103+
# run: npm run build
104+
# - name: Upload artifact
105+
# uses: actions/upload-artifact@v4
106+
# with:
107+
# name: extension
108+
# path: ./extension/dist
109+
# retention-days: 7
110+
# - name: Install and build MCP server
111+
# run: |
112+
# cd ..
113+
# npm ci
114+
# npm run build
115+
# npx playwright install chromium
116+
# - name: Run tests
117+
# run: |
118+
# if [[ "$(uname)" == "Linux" ]]; then
119+
# xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test
120+
# else
121+
# npm run test
122+
# fi
123+
# shell: bash

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ LICENSE
55
!cli.js
66
!index.*
77
!config.d.ts
8+
!context.d.ts
9+
!tab.d.ts

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Playwright MCP server supports following arguments. They can be provided in the
179179
<!--- Options generated by update-readme.js -->
180180

181181
```
182-
> npx @playwright/mcp@latest --help
182+
> npx asteroid-playwright-mcp@latest --help
183183
--allowed-origins <origins> semicolon-separated list of origins to allow the
184184
browser to request. Default is to allow all.
185185
--blocked-origins <origins> semicolon-separated list of origins to block the

context.d.ts

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import type * as playwright from 'playwright';
18+
import type {
19+
ImageContent,
20+
TextContent,
21+
} from '@modelcontextprotocol/sdk/types.js';
22+
import type { Tab } from './tab.js';
23+
24+
/**
25+
* Tool capability types
26+
*/
27+
export type ToolCapability =
28+
| 'core'
29+
| 'tabs'
30+
| 'pdf'
31+
| 'history'
32+
| 'wait'
33+
| 'files'
34+
| 'install'
35+
| 'testing';
36+
37+
/**
38+
* Configuration for the MCP server
39+
*/
40+
export type FullConfig = {
41+
browser: {
42+
browserAgent?: string;
43+
browserName: 'chromium' | 'firefox' | 'webkit';
44+
isolated?: boolean;
45+
userDataDir?: string;
46+
launchOptions?: playwright.LaunchOptions;
47+
contextOptions?: playwright.BrowserContextOptions;
48+
cdpEndpoint?: string;
49+
remoteEndpoint?: string;
50+
};
51+
server?: {
52+
port?: number;
53+
host?: string;
54+
};
55+
capabilities?: ToolCapability[];
56+
vision?: boolean;
57+
saveTrace?: boolean;
58+
outputDir?: string;
59+
network?: {
60+
allowedOrigins?: string[];
61+
blockedOrigins?: string[];
62+
};
63+
imageResponses?: 'allow' | 'omit' | 'auto';
64+
};
65+
66+
/**
67+
* Modal state types for handling dialogs and file choosers
68+
*/
69+
export type FileUploadModalState = {
70+
type: 'fileChooser';
71+
description: string;
72+
fileChooser: playwright.FileChooser;
73+
};
74+
75+
export type DialogModalState = {
76+
type: 'dialog';
77+
description: string;
78+
dialog: playwright.Dialog;
79+
};
80+
81+
export type ModalState = FileUploadModalState | DialogModalState;
82+
83+
/**
84+
* Tool action result type
85+
*/
86+
export type ToolActionResult =
87+
| { content?: (ImageContent | TextContent)[] }
88+
| undefined
89+
| void;
90+
91+
/**
92+
* Tool result type
93+
*/
94+
export type ToolResult = {
95+
code: string[];
96+
action?: () => Promise<ToolActionResult>;
97+
captureSnapshot: boolean;
98+
waitForNetwork: boolean;
99+
resultOverride?: ToolActionResult;
100+
};
101+
102+
/**
103+
* Tool schema type
104+
*/
105+
export type ToolSchema<Input = any> = {
106+
name: string;
107+
title: string;
108+
description: string;
109+
inputSchema: Input;
110+
type: 'readOnly' | 'destructive';
111+
};
112+
113+
/**
114+
* Tool type definition
115+
*/
116+
export type Tool<Input = any> = {
117+
capability: ToolCapability;
118+
schema: ToolSchema<Input>;
119+
clearsModalState?: ModalState['type'];
120+
handle: (context: Context, params: any) => Promise<ToolResult>;
121+
};
122+
123+
/**
124+
* Context class type definition
125+
*/
126+
export type Context = {
127+
readonly tools: Tool[];
128+
readonly config: FullConfig;
129+
clientVersion?: { name: string; version: string };
130+
131+
clientSupportsImages(): boolean;
132+
modalStates(): ModalState[];
133+
setModalState(modalState: ModalState, inTab: Tab): void;
134+
clearModalState(modalState: ModalState): void;
135+
modalStatesMarkdown(): string[];
136+
tabs(): Tab[];
137+
currentTabOrDie(): Tab;
138+
newTab(): Promise<Tab>;
139+
selectTab(index: number): Promise<void>;
140+
ensureTab(): Promise<Tab>;
141+
listTabsMarkdown(): Promise<string>;
142+
closeTab(index: number | undefined): Promise<string>;
143+
run(
144+
tool: Tool,
145+
params: Record<string, unknown> | undefined
146+
): Promise<{ content: (ImageContent | TextContent)[] }>;
147+
waitForTimeout(time: number): Promise<void>;
148+
close(): Promise<void>;
149+
};

index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { Context } from './context.js';
1819
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
1920
import type { Config } from './config.js';
2021
import type { BrowserContext } from 'playwright';
2122

22-
export declare function createConnection(config?: Config, contextGetter?: () => Promise<BrowserContext>): Promise<Server>;
23+
export interface Connection {
24+
server: Server;
25+
context: Context;
26+
}
27+
28+
export declare function createConnection(config?: Config, contextGetter?: () => Promise<BrowserContext>): Promise<Connection>;
2329
export {};

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)