chore: handle list roots in the server, with timeout (#898)

This commit is contained in:
Yury Semikhatsky
2025-08-15 11:23:59 -07:00
committed by GitHub
parent 92554abfd1
commit 91d5d24cab
4 changed files with 78 additions and 84 deletions

View File

@@ -45,11 +45,9 @@ export class BrowserServerBackend implements ServerBackend {
this._tools = filteredTools(config);
}
async initialize(server: mcpServer.Server): Promise<void> {
const capabilities = server.getClientCapabilities();
async initialize(clientVersion: mcpServer.ClientVersion, roots: mcpServer.Root[]): Promise<void> {
let rootPath: string | undefined;
if (capabilities?.roots) {
const { roots } = await server.listRoots();
if (roots.length > 0) {
const firstRootUri = roots[0]?.uri;
const url = firstRootUri ? new URL(firstRootUri) : undefined;
rootPath = url ? fileURLToPath(url) : undefined;
@@ -60,7 +58,7 @@ export class BrowserServerBackend implements ServerBackend {
config: this._config,
browserContextFactory: this._browserContextFactory,
sessionLog: this._sessionLog,
clientInfo: { ...server.getClientVersion(), rootPath },
clientInfo: { ...clientVersion, rootPath },
});
}