Skip to content

feat(mcp): default Patchright backend for Playwright MCP#1265

Open
atxtechbro wants to merge 1 commit intomainfrom
feat/patchright-playwright-default-1263
Open

feat(mcp): default Patchright backend for Playwright MCP#1265
atxtechbro wants to merge 1 commit intomainfrom
feat/patchright-playwright-default-1263

Conversation

@atxtechbro
Copy link
Owner

Summary
Default the Playwright MCP server to use an undetectable backend by shimming require('playwright') to Patchright, while continuing to run the community @playwright/mcp server.

What changed

  • Added shim: mcp/patchright-shim/node_modules/playwright/index.js resolves Playwright to Patchright.
  • Added wrapper: mcp/servers/patchright-playwright-mcp sets NODE_PATH to the shim (opt‑out with USE_PATCHRIGHT=0|false) and executes npx @playwright/mcp@latest.
  • Updated config: mcp/mcp.json now points the Playwright server to the wrapper command.
  • Added helper setup: mcp/setup-patchright-shim.sh installs the patchright package locally in the shim.

Usage

  • Default ON: Wrapper enables the shim automatically.
  • Toggle OFF: USE_PATCHRIGHT=0 (or false) before launching clients.

Notes

  • This keeps the community Playwright MCP server intact; no forks.
  • No consumer code changes required; resolution happens via NODE_PATH.

Follow‑ups (optional)

  • First‑time chromium download: npx patchright install chromium.
  • If any clients don’t inherit PATH, we can add a per‑client launcher pointing to mcp/servers/patchright-playwright-mcp.

Closes #1263

…m so require('playwright') resolves to Patchright\n- Add wrapper 'patchright-playwright-mcp' to set NODE_PATH and run @playwright/mcp\n- Point mcp/mcp.json Playwright server to the wrapper\n- Provide setup script to install Patchright locally\n\nCloses #1263
@amazon-q-developer
Copy link
Contributor

Code review in progress. Analyzing for code quality issues and best practices. Detailed findings will be posted upon completion.

Using Amazon Q Developer for GitHub

Amazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation.

Slash Commands

Command Description
/q <message> Chat with the agent to ask questions or request revisions
/q review Requests an Amazon Q powered code review
/q help Displays usage information

Features

Agentic Chat
Enables interactive conversation with Amazon Q to ask questions about the pull request or request specific revisions. Use /q <message> in comment threads or the review body to engage with the agent directly.

Code Review
Analyzes pull requests for code quality, potential issues, and security concerns. Provides feedback and suggested fixes. Automatically triggered on new or reopened PRs (can be disabled for AWS registered installations), or manually with /q review slash command in a comment.

Customization

You can create project-specific rules for Amazon Q Developer to follow:

  1. Create a .amazonq/rules folder in your project root.
  2. Add Markdown files in this folder to define rules (e.g., cdk-rules.md).
  3. Write detailed prompts in these files, such as coding standards or best practices.
  4. Amazon Q Developer will automatically use these rules when generating code or providing assistance.

Example rule:

All Amazon S3 buckets must have encryption enabled, enforce SSL, and block public access.
All Amazon DynamoDB Streams tables must have encryption enabled.
All Amazon SNS topics must have encryption enabled and enforce SSL.
All Amazon SNS queues must enforce SSL.

Feedback

To provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository.

For more detailed information, visit the Amazon Q for GitHub documentation.

Footnotes

  1. Amazon Q Developer uses generative AI. You may need to verify generated code before using it in your environment. See the AWS Responsible AI Policy.

Copy link
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the changes for defaulting the Playwright MCP to use Patchright backend. Here's the summary of findings:

Key Concerns:

  1. Security: The use of exec with unchecked arguments in the MCP wrapper script needs attention
  2. Error Handling: Several places would benefit from more robust error handling, particularly in the setup script and shim
  3. Configuration: The mcp.json could use versioning for better maintainability

The overall approach of using a shim for Playwright resolution is solid, but these improvements would make the implementation more robust and maintainable. Please address the security concern as a priority.


# Execute the community Playwright MCP server
exec npx @playwright/mcp@latest "$@"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 [Security Concern]: The script is using exec with "$@" which could potentially allow command injection if not properly sanitized1. Consider adding input validation for the arguments before passing them to exec.

Footnotes

  1. CWE-78: OS Command Injection - https://cwe.mitre.org/data/definitions/78.html

fi

echo "Installing patchright into $SHIM_DIR ..."
(cd "$SHIM_DIR" && npm install patchright --silent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the npm install command to provide more informative error messages if the installation fails.

@@ -1,13 +1,11 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a version field to the configuration to help with future compatibility checks and migrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default Patchright backend for Playwright MCP (keep @playwright/mcp)

1 participant