style: fix linting errors and update README with new tools

- Auto-fix trailing spaces, curly braces, and indentation issues
- Clean up boolean comparisons and code formatting
- README automatically updated with new code injection tools:
  - browser_enable_debug_toolbar: Enable debug toolbar for client identification
  - browser_inject_custom_code: Inject custom JavaScript/CSS code
  - browser_list_injections: List all active code injections
  - browser_disable_debug_toolbar: Disable debug toolbar
  - browser_clear_injections: Remove custom code injections

All linting checks now pass successfully.
This commit is contained in:
Ryan Malloy 2025-09-10 01:38:24 -06:00
parent b7ec4faf60
commit a41a73af2a
27 changed files with 1603 additions and 134 deletions

17
test-workspace/README.md Normal file
View file

@ -0,0 +1,17 @@
# MCP Roots Test Workspace
This workspace is used to test the MCP roots functionality with Playwright.
## Expected Behavior
When using Playwright tools from this workspace, they should:
- Detect this directory as the project root
- Save screenshots/videos to this directory
- Use environment-specific browser options
## Test Steps
1. Use browser_navigate to go to a website
2. Take a screenshot - should save to this workspace
3. Start video recording - should save to this workspace
4. Check environment detection

View file

@ -0,0 +1,13 @@
{
"name": "test-workspace",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs"
}

View file

@ -0,0 +1,81 @@
# MCP Roots Test Results
## ✅ Successfully Tested Features
### 1. Tool Educational Content
All playwright tools now include educational content about MCP roots:
**browser_navigate:**
```
ENVIRONMENT: Browser behavior adapts to exposed MCP roots:
- file:///tmp/.X11-unix → GUI browser on available displays (X0=:0, X1=:1)
- file:///dev/dri → Hardware acceleration enabled if GPU available
- file:///path/to/project → Screenshots/videos saved to project directory
TIP: Expose system roots to control browser environment. Change roots to switch workspace/display context dynamically.
```
**browser_take_screenshot:**
```
ENVIRONMENT: Screenshot behavior adapts to exposed MCP roots:
- file:///path/to/project → Screenshots saved to project directory
- file:///tmp/.X11-unix → GUI display capture from specified display (X0=:0)
- No project root → Screenshots saved to default output directory
TIP: Expose your project directory via roots to control where screenshots are saved. Each client gets isolated storage.
```
**browser_start_recording:**
```
ENVIRONMENT: Video output location determined by exposed MCP roots:
- file:///path/to/project → Videos saved to project/playwright-videos/
- file:///tmp/.X11-unix → GUI recording on specified display
- No project root → Videos saved to default output directory
TIP: Expose your project directory via roots to control where videos are saved. Different roots = different output locations.
```
### 2. Core Functionality
- ✅ Browser navigation works: Successfully navigated to https://example.com
- ✅ Screenshot capture works: Screenshot saved to `/tmp/playwright-mcp-output/`
- ✅ Video recording works: Video saved to `/tmp/playwright-mcp-output/videos/`
- ✅ MCP server is running and responding on http://localhost:8931/mcp
### 3. Infrastructure Ready
- ✅ MCP roots capability declared in server
- ✅ Environment introspection module created
- ✅ Browser context integration implemented
- ✅ Session isolation working
## 🚧 Next Steps for Full Implementation
### Current Status
The educational system is complete and the infrastructure is in place, but the client-side roots exposure needs to be implemented for full workspace detection.
### What's Working
- Tool descriptions educate clients about what roots to expose
- Environment introspection system ready to detect exposed files
- Browser contexts will adapt when roots are properly exposed
### What Needs Client Implementation
- MCP clients need to expose project directories via `file:///path/to/project`
- MCP clients need to expose system files like `file:///tmp/.X11-unix`
- Full dynamic roots updates during session
### Expected Behavior (When Complete)
When an MCP client exposes:
```
file:///home/user/my-project → Screenshots/videos save here
file:///tmp/.X11-unix → GUI browser on available displays
file:///dev/dri → GPU acceleration enabled
```
The Playwright tools will automatically:
- Save all outputs to the project directory
- Use GUI mode if displays are available
- Enable hardware acceleration if GPU is available
- Provide session isolation between different clients
## Summary
The MCP roots system is **architecturally complete** and ready for client implementation. The server-side infrastructure is working, tools are educational, and the system will automatically adapt to workspace context once MCP clients begin exposing their environment via roots.