fix: cursor does not respond to listRoots (#826)

This commit is contained in:
Yury Semikhatsky
2025-08-04 20:52:55 -07:00
committed by GitHub
parent 6d62c173c8
commit 3f6837baa9
2 changed files with 5 additions and 1 deletions

View File

@@ -55,7 +55,9 @@ export class BrowserServerBackend implements ServerBackend {
async initialize(server: mcpServer.Server): Promise<void> {
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;

View File

@@ -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',