Spaces:
Paused
Paused
docs: fix "programmatic usage with custom transports" code snippet (#235)
Browse files
README.md
CHANGED
|
@@ -157,15 +157,22 @@ X Y coordinate space, based on the provided screenshot.
|
|
| 157 |
### Programmatic usage with custom transports
|
| 158 |
|
| 159 |
```js
|
|
|
|
|
|
|
| 160 |
import { createServer } from '@playwright/mcp';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
-
//
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
launchOptions: { headless: true }
|
| 166 |
});
|
| 167 |
-
|
| 168 |
-
server.connect(transport);
|
| 169 |
```
|
| 170 |
|
| 171 |
<!--- Generated by update-readme.js -->
|
|
|
|
| 157 |
### Programmatic usage with custom transports
|
| 158 |
|
| 159 |
```js
|
| 160 |
+
import http from 'http';
|
| 161 |
+
|
| 162 |
import { createServer } from '@playwright/mcp';
|
| 163 |
+
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
| 164 |
+
|
| 165 |
+
http.createServer(async (req, res) => {
|
| 166 |
+
// ...
|
| 167 |
|
| 168 |
+
// Creates a headless Playwright MCP server with SSE transport
|
| 169 |
+
const mcpServer = await createServer({ headless: true });
|
| 170 |
+
const transport = new SSEServerTransport('/messages', res);
|
| 171 |
+
await mcpServer.connect(transport);
|
| 172 |
|
| 173 |
+
// ...
|
|
|
|
| 174 |
});
|
| 175 |
+
|
|
|
|
| 176 |
```
|
| 177 |
|
| 178 |
<!--- Generated by update-readme.js -->
|