Use stdio for the vscode playwright mcp (#262260)

* Use stdio for the vscode playwright mcp

makes for easier management... since it can be compiled when launched.

* add to readme
This commit is contained in:
Tyler James Leonhardt
2025-08-18 23:27:10 -07:00
committed by GitHub
parent f2c609caa9
commit c81631ed89
9 changed files with 1003 additions and 44 deletions
+15 -1
View File
@@ -13,7 +13,21 @@ The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is an open
- Handle file uploads and downloads
- Manage browser tabs and windows
## Quick Start
## Quick Start - Stdio
Firstly, make sure you install all dependencies (`npm i`) at the root of the repo.
Then, open the Command Palette and run:
```
MCP: List Servers → vscode-playwright-mcp → Start Server
```
or open [mcp.json](../../.vscode/mcp.json) and start it from there.
That's it! It should automatically compile everything needed.
Then you can use `/playwright` to ask specific questions.
## Quick Start - HTTP
Getting started with the MCP server is simple - just run the pre-configured Code - OSS task:
+2 -2
View File
@@ -9,11 +9,11 @@
"watch-automation": "cd ../automation && npm run watch",
"watch-mcp": "node ../../node_modules/typescript/bin/tsc --watch --preserveWatchOutput",
"watch": "npm-run-all -lp watch-automation watch-mcp",
"start": "node ./out/main.js"
"start-http": "npm run -s compile && node ./out/main.js",
"start-stdio": "npm run -s compile && node ./out/stdio.js"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.17.3",
"@playwright/mcp": "^0.0.33",
"cors": "^2.8.5",
"express": "^5.1.0",
"minimist": "^1.2.8",
+1
View File
@@ -138,6 +138,7 @@ export async function getServer() {
process.env.VSCODE_REPOSITORY = rootPath;
process.env.VSCODE_DEV = '1';
process.env.VSCODE_CLI = '1';
delete process.env.ELECTRON_RUN_AS_NODE; // Ensure we run as Node.js
const quality = Quality.Dev;
const userDataDir = path.join(testDataPath, 'd');
+16
View File
@@ -0,0 +1,16 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { getServer } from './playwright';
const transport: StdioServerTransport = new StdioServerTransport();
(async () => {
const server = await getServer();
await server.connect(transport);
})().catch(err => {
transport.close();
console.error('Error occurred while connecting to server:', err);
process.exit(1);
});