From 6710a78641bc8550b37f88e594585d577e9362d9 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 25 Jul 2025 12:18:02 -0700 Subject: [PATCH] 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. --- README.md | 6 +++--- src/mcp/transport.ts | 8 ++++---- tests/http.spec.ts | 9 +++++++++ tests/sse.spec.ts | 9 --------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3ea79ee..de48c2d 100644 --- a/README.md +++ b/README.md @@ -317,19 +317,19 @@ npx @playwright/mcp@latest --config path/to/config.json ### Standalone MCP server 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 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 { "mcpServers": { "playwright": { - "url": "http://localhost:8931/sse" + "url": "http://localhost:8931/mcp" } } } diff --git a/src/mcp/transport.ts b/src/mcp/transport.ts index e85a66f..9d82b40 100644 --- a/src/mcp/transport.ts +++ b/src/mcp/transport.ts @@ -114,10 +114,10 @@ function startHttpTransport(httpServer: http.Server, serverBackendFactory: Serve const streamableSessions = new Map(); httpServer.on('request', async (req, res) => { const url = new URL(`http://localhost${req.url}`); - if (url.pathname.startsWith('/mcp')) - await handleStreamable(serverBackendFactory, req, res, streamableSessions); - else + if (url.pathname.startsWith('/sse')) await handleSSE(serverBackendFactory, req, res, url, sseSessions); + else + await handleStreamable(serverBackendFactory, req, res, streamableSessions); }); const url = httpAddressToString(httpServer.address()); const message = [ @@ -130,7 +130,7 @@ function startHttpTransport(httpServer: http.Server, serverBackendFactory: Serve } } }, 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'); // eslint-disable-next-line no-console console.error(message); diff --git a/tests/http.spec.ts b/tests/http.spec.ts index 51e07db..4ff9ac9 100644 --- a/tests/http.spec.ts +++ b/tests/http.spec.ts @@ -248,3 +248,12 @@ test('http transport browser lifecycle (persistent, multiclient)', async ({ serv await client1.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(); +}); diff --git a/tests/sse.spec.ts b/tests/sse.spec.ts index eab9248..60cc740 100644 --- a/tests/sse.spec.ts +++ b/tests/sse.spec.ts @@ -234,12 +234,3 @@ test('sse transport browser lifecycle (persistent, multiclient)', async ({ serve await client1.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(); -});