Revert "chore: recommend sse by default" (#765)

Reverts microsoft/playwright-mcp#758

Sounds like the stock streamable implementation is to spec, so we can
keep it.
This commit is contained in:
Pavel Feldman 2025-07-25 12:18:02 -07:00 committed by GitHub
parent a9b9fb85da
commit 6710a78641
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 16 deletions

View File

@ -317,19 +317,19 @@ npx @playwright/mcp@latest --config path/to/config.json
### Standalone MCP server ### Standalone MCP server
When running headed browser on system w/o display or from worker processes of the IDEs, When running headed browser on system w/o display or from worker processes of the IDEs,
run the MCP server from environment with the DISPLAY and pass the `--port` flag to enable SSE transport. run the MCP server from environment with the DISPLAY and pass the `--port` flag to enable HTTP transport.
```bash ```bash
npx @playwright/mcp@latest --port 8931 npx @playwright/mcp@latest --port 8931
``` ```
And then in MCP client config, set the `url` to the SSE endpoint: And then in MCP client config, set the `url` to the HTTP endpoint:
```js ```js
{ {
"mcpServers": { "mcpServers": {
"playwright": { "playwright": {
"url": "http://localhost:8931/sse" "url": "http://localhost:8931/mcp"
} }
} }
} }

View File

@ -114,10 +114,10 @@ function startHttpTransport(httpServer: http.Server, serverBackendFactory: Serve
const streamableSessions = new Map(); const streamableSessions = new Map();
httpServer.on('request', async (req, res) => { httpServer.on('request', async (req, res) => {
const url = new URL(`http://localhost${req.url}`); const url = new URL(`http://localhost${req.url}`);
if (url.pathname.startsWith('/mcp')) if (url.pathname.startsWith('/sse'))
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
else
await handleSSE(serverBackendFactory, req, res, url, sseSessions); await handleSSE(serverBackendFactory, req, res, url, sseSessions);
else
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
}); });
const url = httpAddressToString(httpServer.address()); const url = httpAddressToString(httpServer.address());
const message = [ const message = [
@ -130,7 +130,7 @@ function startHttpTransport(httpServer: http.Server, serverBackendFactory: Serve
} }
} }
}, undefined, 2), }, undefined, 2),
'If your client supports streamable HTTP, you can use the /mcp endpoint instead.', 'For legacy SSE transport support, you can use the /sse endpoint instead.',
].join('\n'); ].join('\n');
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(message); console.error(message);

View File

@ -248,3 +248,12 @@ test('http transport browser lifecycle (persistent, multiclient)', async ({ serv
await client1.close(); await client1.close();
await client2.close(); await client2.close();
}); });
test('http transport (default)', async ({ serverEndpoint }) => {
const { url } = await serverEndpoint();
const transport = new StreamableHTTPClientTransport(url);
const client = new Client({ name: 'test', version: '1.0.0' });
await client.connect(transport);
await client.ping();
expect(transport.sessionId, 'has session support').toBeDefined();
});

View File

@ -234,12 +234,3 @@ test('sse transport browser lifecycle (persistent, multiclient)', async ({ serve
await client1.close(); await client1.close();
await client2.close(); await client2.close();
}); });
test('sse transport (default)', async ({ serverEndpoint }) => {
const { url } = await serverEndpoint();
const transport = new SSEClientTransport(url);
const client = new Client({ name: 'test', version: '1.0.0' });
await client.connect(transport);
await client.ping();
await client.close();
});