diff --git a/tests/basic.spec.ts b/tests/basic.spec.ts index 765ebc4..09f5405 100644 --- a/tests/basic.spec.ts +++ b/tests/basic.spec.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import { spawn } from 'node:child_process'; +import path from 'node:path'; import { test, expect } from './fixtures'; test('test tool list', async ({ server, visionServer }) => { @@ -450,3 +452,26 @@ test('stitched aria frames', async ({ server }) => { }, })); }); + +test('sse transport', async () => { + const cp = spawn('node', [path.join(__dirname, '../cli.js'), '--port', '0'], { stdio: 'pipe' }); + try { + let stdout = ''; + const url = await new Promise(resolve => cp.stdout?.on('data', data => { + stdout += data.toString(); + const match = stdout.match(/Listening on (http:\/\/.*)/); + if (match) + resolve(match[1]); + })); + + // need dynamic import b/c of some ESM nonsense + const { SSEClientTransport } = await import('@modelcontextprotocol/sdk/client/sse.js'); + const { Client } = await import('@modelcontextprotocol/sdk/client/index.js'); + const transport = new SSEClientTransport(new URL(url)); + const client = new Client({ name: 'test', version: '1.0.0' }); + await client.connect(transport); + await client.ping(); + } finally { + cp.kill(); + } +});