From 3f6837baa934e53ad8c747493219ac7d9e380f8e Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 4 Aug 2025 20:52:55 -0700 Subject: [PATCH] fix: cursor does not respond to listRoots (#826) --- src/browserServerBackend.ts | 4 +++- tests/roots.spec.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/browserServerBackend.ts b/src/browserServerBackend.ts index 95b60e3..3a5ada4 100644 --- a/src/browserServerBackend.ts +++ b/src/browserServerBackend.ts @@ -55,7 +55,9 @@ export class BrowserServerBackend implements ServerBackend { async initialize(server: mcpServer.Server): Promise { const capabilities = server.getClientCapabilities() as mcpServer.ClientCapabilities; let rootPath: string | undefined; - if (capabilities.roots) { + if (capabilities.roots && ( + server.getClientVersion()?.name === 'Visual Studio Code' || + server.getClientVersion()?.name === 'Visual Studio Code - Insiders')) { const { roots } = await server.listRoots(); const firstRootUri = roots[0]?.uri; const url = firstRootUri ? new URL(firstRootUri) : undefined; diff --git a/tests/roots.spec.ts b/tests/roots.spec.ts index 9c8bb01..9b3ee20 100644 --- a/tests/roots.spec.ts +++ b/tests/roots.spec.ts @@ -25,6 +25,7 @@ const p = process.platform === 'win32' ? 'c:\\non\\existent\\folder' : '/non/exi test('should use separate user data by root path', async ({ startClient, server }, testInfo) => { const { client } = await startClient({ + clientName: 'Visual Studio Code', // Simulate VS Code client, roots only work with it roots: [ { name: 'test', @@ -48,6 +49,7 @@ test('check that trace is saved in workspace', async ({ startClient, server, mcp const rootPath = testInfo.outputPath('workspace'); const { client } = await startClient({ args: ['--save-trace'], + clientName: 'Visual Studio Code - Insiders', // Simulate VS Code client, roots only work with it roots: [ { name: 'workspace',