@simplysm/mcp-playwright 13.0.81 → 13.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -0
- package/package.json +1 -2
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# @simplysm/mcp-playwright
|
|
2
|
+
|
|
3
|
+
Multi-session Playwright MCP (Model Context Protocol) server. Wraps `@playwright/mcp` to support multiple isolated browser sessions, each identified by a `sessionId`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/mcp-playwright
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides a stdio-based MCP server that proxies all `@playwright/mcp` tools while adding multi-session support. Each tool call requires a `sessionId` parameter, ensuring that different consumers can operate independent browser instances without interference.
|
|
14
|
+
|
|
15
|
+
Key features:
|
|
16
|
+
|
|
17
|
+
- **Session isolation** -- each `sessionId` gets its own browser context via `@playwright/mcp`
|
|
18
|
+
- **Automatic cleanup** -- idle sessions are destroyed after a configurable timeout (default: 5 minutes)
|
|
19
|
+
- **Broken connection recovery** -- if an underlying Playwright connection breaks, the session is destroyed and the error is reported
|
|
20
|
+
- **All `@playwright/mcp` tools** are automatically discovered and proxied with the added `sessionId` parameter
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### As an MCP server (CLI)
|
|
25
|
+
|
|
26
|
+
The package publishes a `sd-mcp-playwright` binary:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx sd-mcp-playwright
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The server communicates over stdio using the MCP protocol. It is designed to be launched by an MCP client (e.g., Claude Code, an IDE extension, or any MCP-compatible host).
|
|
33
|
+
|
|
34
|
+
### MCP client configuration example
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"playwright": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["sd-mcp-playwright"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Tools
|
|
48
|
+
|
|
49
|
+
All tools from `@playwright/mcp` are automatically proxied with an additional required `sessionId` parameter. In addition, two session-management tools are provided:
|
|
50
|
+
|
|
51
|
+
### `session_close`
|
|
52
|
+
|
|
53
|
+
Close a browser session and release resources.
|
|
54
|
+
|
|
55
|
+
| Parameter | Type | Required | Description |
|
|
56
|
+
|-----------|------|----------|-------------|
|
|
57
|
+
| `sessionId` | `string` | Yes | Session ID to close |
|
|
58
|
+
|
|
59
|
+
### `session_list`
|
|
60
|
+
|
|
61
|
+
List all active browser session IDs. Returns a JSON array of session ID strings.
|
|
62
|
+
|
|
63
|
+
No parameters required.
|
|
64
|
+
|
|
65
|
+
### Proxied Playwright tools
|
|
66
|
+
|
|
67
|
+
Every tool exposed by `@playwright/mcp` (e.g., `browser_navigate`, `browser_click`, `browser_snapshot`, `browser_take_screenshot`, etc.) is available with an injected `sessionId` parameter. The `sessionId` is stripped before forwarding the call to the underlying Playwright MCP connection.
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
The server launches browsers with the following defaults:
|
|
72
|
+
|
|
73
|
+
| Option | Value |
|
|
74
|
+
|--------|-------|
|
|
75
|
+
| Headless mode | `true` |
|
|
76
|
+
| Browser isolation | `true` (each session gets its own context) |
|
|
77
|
+
| Output directory | `.tmp/playwright` (screenshots, PDFs, downloads) |
|
|
78
|
+
| Session idle timeout | 5 minutes |
|
|
79
|
+
| Cleanup interval | 30 seconds |
|
|
80
|
+
|
|
81
|
+
## API
|
|
82
|
+
|
|
83
|
+
### `SessionManager`
|
|
84
|
+
|
|
85
|
+
Manages the lifecycle of multiple isolated Playwright MCP sessions.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { SessionManager } from "@simplysm/mcp-playwright";
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### `constructor(config, timeoutMs?, version?)`
|
|
92
|
+
|
|
93
|
+
| Parameter | Type | Default | Description |
|
|
94
|
+
|-----------|------|---------|-------------|
|
|
95
|
+
| `config` | `CreateConnectionConfig` | -- | Configuration passed to `@playwright/mcp` `createConnection()` |
|
|
96
|
+
| `timeoutMs` | `number` | `300000` (5 min) | Idle timeout before a session is automatically destroyed |
|
|
97
|
+
| `version` | `string` | `"0.0.0"` | Version string for the internal MCP client |
|
|
98
|
+
|
|
99
|
+
#### `getOrCreate(sessionId: string): Promise<Client>`
|
|
100
|
+
|
|
101
|
+
Returns the MCP `Client` for the given session, creating a new one if it does not exist. Concurrent calls with the same `sessionId` are coalesced (only one session is created).
|
|
102
|
+
|
|
103
|
+
#### `destroy(sessionId: string): Promise<void>`
|
|
104
|
+
|
|
105
|
+
Closes and removes the session with the given ID. No-op if the session does not exist.
|
|
106
|
+
|
|
107
|
+
#### `disposeAll(): Promise<void>`
|
|
108
|
+
|
|
109
|
+
Destroys all active sessions and stops the background cleanup timer.
|
|
110
|
+
|
|
111
|
+
#### `list(): string[]`
|
|
112
|
+
|
|
113
|
+
Returns an array of all active session IDs.
|
|
114
|
+
|
|
115
|
+
### `registerProxiedTools(server, sessionManager): Promise<void>`
|
|
116
|
+
|
|
117
|
+
Discovers all tools from `@playwright/mcp`, injects the `sessionId` parameter, adds session-management tools (`session_close`, `session_list`), and registers request handlers on the given MCP `Server`.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { registerProxiedTools } from "@simplysm/mcp-playwright";
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### `injectSessionId(tool: Tool): Tool`
|
|
124
|
+
|
|
125
|
+
Utility that takes an MCP `Tool` definition and returns a copy with a required `sessionId` property added to its input schema.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { injectSessionId } from "@simplysm/mcp-playwright";
|
|
129
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/mcp-playwright",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.83",
|
|
4
4
|
"description": "Simplysm MCP server — multi-session Playwright proxy",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
"docs",
|
|
18
17
|
"src"
|
|
19
18
|
],
|
|
20
19
|
"sideEffects": false,
|