@simplysm/mcp-playwright 13.0.78 → 13.0.80
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/package.json +2 -1
- package/README.md +0 -139
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/mcp-playwright",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.80",
|
|
4
4
|
"description": "Simplysm MCP server — multi-session Playwright proxy",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
+
"docs",
|
|
17
18
|
"src"
|
|
18
19
|
],
|
|
19
20
|
"sideEffects": false,
|
package/README.md
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
# @simplysm/mcp-playwright
|
|
2
|
-
|
|
3
|
-
Simplysm MCP server — multi-session Playwright proxy.
|
|
4
|
-
|
|
5
|
-
Wraps [`@playwright/mcp`](https://github.com/microsoft/playwright-mcp) and adds **session isolation**: every Playwright tool call requires a `sessionId` argument that routes the request to a dedicated browser instance. Multiple sessions can exist concurrently without interfering with each other.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pnpm add -g @simplysm/mcp-playwright
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Or run directly with npx/pnpm dlx:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pnpm dlx @simplysm/mcp-playwright
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## MCP Configuration
|
|
20
|
-
|
|
21
|
-
Add the server to your MCP client configuration (e.g., Claude Desktop's `claude_desktop_config.json`):
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
{
|
|
25
|
-
"mcpServers": {
|
|
26
|
-
"playwright": {
|
|
27
|
-
"command": "pnpm",
|
|
28
|
-
"args": ["dlx", "@simplysm/mcp-playwright"]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
The server communicates over **stdio** using the Model Context Protocol.
|
|
35
|
-
|
|
36
|
-
## How It Works
|
|
37
|
-
|
|
38
|
-
- The server starts a single MCP process.
|
|
39
|
-
- Each call to a Playwright tool must include a `sessionId` string.
|
|
40
|
-
- On the first call with a given `sessionId`, the server launches a dedicated headless browser (isolated Playwright context).
|
|
41
|
-
- Subsequent calls with the same `sessionId` reuse that browser context.
|
|
42
|
-
- Sessions are automatically cleaned up after **5 minutes of inactivity**.
|
|
43
|
-
- Output files (screenshots, traces, etc.) are written to `.tmp/playwright/`.
|
|
44
|
-
|
|
45
|
-
## Session Management Tools
|
|
46
|
-
|
|
47
|
-
### `session_list`
|
|
48
|
-
|
|
49
|
-
Returns all currently active session IDs.
|
|
50
|
-
|
|
51
|
-
**Input:** _(none)_
|
|
52
|
-
|
|
53
|
-
**Output:** Pretty-printed JSON array of session ID strings.
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
["session-a", "session-b"]
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### `session_close`
|
|
60
|
-
|
|
61
|
-
Closes a specific browser session and releases its resources.
|
|
62
|
-
|
|
63
|
-
**Input:**
|
|
64
|
-
|
|
65
|
-
| Field | Type | Required | Description |
|
|
66
|
-
|-------|------|----------|-------------|
|
|
67
|
-
| `sessionId` | `string` | Yes | ID of the session to close |
|
|
68
|
-
|
|
69
|
-
**Output:** Confirmation text: `Session '<sessionId>' closed.`
|
|
70
|
-
|
|
71
|
-
## Playwright Proxy Tools
|
|
72
|
-
|
|
73
|
-
All tools from `@playwright/mcp` are forwarded by this server. Each forwarded tool has a `sessionId` field added to its original input schema.
|
|
74
|
-
|
|
75
|
-
**Every proxied tool requires:**
|
|
76
|
-
|
|
77
|
-
| Field | Type | Required | Description |
|
|
78
|
-
|-------|------|----------|-------------|
|
|
79
|
-
| `sessionId` | `string` | Yes | Session ID for browser isolation |
|
|
80
|
-
| _(original fields)_ | — | — | Same as the original `@playwright/mcp` tool |
|
|
81
|
-
|
|
82
|
-
If an error occurs during a proxied tool call, the server checks whether the underlying connection is still alive. If the connection is broken, the session is automatically destroyed to avoid leaving a browser in an unusable state. If the connection is still alive, the error is returned without destroying the session.
|
|
83
|
-
|
|
84
|
-
## Server Internals
|
|
85
|
-
|
|
86
|
-
### `SessionManager`
|
|
87
|
-
|
|
88
|
-
Internal class that manages the lifecycle of per-session Playwright MCP clients.
|
|
89
|
-
|
|
90
|
-
**Constructor**
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
new SessionManager(
|
|
94
|
-
config: NonNullable<Parameters<typeof createConnection>[0]>,
|
|
95
|
-
timeoutMs?: number,
|
|
96
|
-
version?: string,
|
|
97
|
-
)
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
| Parameter | Type | Default | Description |
|
|
101
|
-
|-----------|------|---------|-------------|
|
|
102
|
-
| `config` | `NonNullable<Parameters<typeof createConnection>[0]>` | — | Configuration passed to `@playwright/mcp`'s `createConnection` |
|
|
103
|
-
| `timeoutMs` | `number` | `300000` (5 min) | Inactivity timeout in milliseconds before a session is auto-cleaned |
|
|
104
|
-
| `version` | `string` | `"0.0.0"` | Version string reported by the internal MCP client |
|
|
105
|
-
|
|
106
|
-
**Methods**
|
|
107
|
-
|
|
108
|
-
| Method | Signature | Description |
|
|
109
|
-
|--------|-----------|-------------|
|
|
110
|
-
| `getOrCreate` | `(sessionId: string) => Promise<Client>` | Returns an existing MCP client for the session, or creates a new one. Updates the last-used timestamp on each call. Concurrent calls for the same `sessionId` are deduplicated. |
|
|
111
|
-
| `destroy` | `(sessionId: string) => Promise<void>` | Closes and removes a single session. No-op if the session does not exist. |
|
|
112
|
-
| `disposeAll` | `() => Promise<void>` | Closes all sessions and stops the cleanup interval. Called on `SIGINT`/`SIGTERM`. |
|
|
113
|
-
| `list` | `() => string[]` | Returns an array of all currently active session IDs. |
|
|
114
|
-
|
|
115
|
-
### `injectSessionId`
|
|
116
|
-
|
|
117
|
-
Internal utility that adds the `sessionId` field to a Playwright tool's input schema before the tool is registered on the proxy server.
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
function injectSessionId(tool: Tool): Tool
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
- Adds `sessionId` to `inputSchema.properties`.
|
|
124
|
-
- Ensures `sessionId` appears first in the `required` array.
|
|
125
|
-
- Deduplicates `sessionId` if it is already present in `required`.
|
|
126
|
-
- Returns a new tool object; the original is not mutated.
|
|
127
|
-
|
|
128
|
-
### `registerProxiedTools`
|
|
129
|
-
|
|
130
|
-
Internal function that wires up all Playwright tools and the two session management tools (`session_list`, `session_close`) to an MCP `Server` instance.
|
|
131
|
-
|
|
132
|
-
```ts
|
|
133
|
-
async function registerProxiedTools(
|
|
134
|
-
server: Server,
|
|
135
|
-
sessionManager: SessionManager,
|
|
136
|
-
): Promise<void>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
At startup it creates a temporary bootstrap session to discover the tool list from `@playwright/mcp`, then destroys it before serving real requests.
|