mirror of
				https://github.com/microsoft/playwright-mcp.git
				synced 2025-10-12 00:25:14 +03:00 
			
		
		
		
	docs: fix "programmatic usage with custom transports" code snippet (#235)
Fixes: #230
This commit is contained in:
		
							
								
								
									
										17
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								README.md
									
									
									
									
									
								
							| @@ -157,15 +157,22 @@ X Y coordinate space, based on the provided screenshot. | ||||
| ### Programmatic usage with custom transports | ||||
|  | ||||
| ```js | ||||
| import http from 'http'; | ||||
|  | ||||
| import { createServer } from '@playwright/mcp'; | ||||
| import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'; | ||||
|  | ||||
| // ... | ||||
| http.createServer(async (req, res) => { | ||||
|   // ... | ||||
|  | ||||
| const server = createServer({ | ||||
|   launchOptions: { headless: true } | ||||
|   // Creates a headless Playwright MCP server with SSE transport | ||||
|   const mcpServer = await createServer({ headless: true }); | ||||
|   const transport = new SSEServerTransport('/messages', res); | ||||
|   await mcpServer.connect(transport); | ||||
|  | ||||
|   // ... | ||||
| }); | ||||
| transport = new SSEServerTransport("/messages", res); | ||||
| server.connect(transport); | ||||
|  | ||||
| ``` | ||||
|  | ||||
| <!--- Generated by update-readme.js --> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Rui Figueira
					Rui Figueira