chore: refactor initialize (#812)

This commit is contained in:
Pavel Feldman
2025-08-01 13:06:36 -07:00
committed by GitHub
parent 7c07cc86eb
commit ffe0117456
3 changed files with 44 additions and 21 deletions

View File

@@ -43,9 +43,16 @@ export class BrowserServerBackend implements ServerBackend {
this._tools = filteredTools(config);
}
async initialize() {
async initialize(server: mcpServer.Server): Promise<void> {
this._sessionLog = this._config.saveSession ? await SessionLog.create(this._config) : undefined;
this._context = new Context(this._tools, this._config, this._browserContextFactory, this._sessionLog);
this._context = new Context({
tools: this._tools,
config: this._config,
browserContextFactory: this._browserContextFactory,
sessionLog: this._sessionLog,
clientVersion: server.getClientVersion(),
capabilities: server.getClientCapabilities() as mcpServer.ClientCapabilities,
});
}
tools(): mcpServer.ToolSchema<any>[] {
@@ -69,10 +76,6 @@ export class BrowserServerBackend implements ServerBackend {
return response.serialize();
}
serverInitialized(version: mcpServer.ClientVersion | undefined) {
this._context!.clientVersion = version;
}
serverClosed() {
void this._context!.dispose().catch(logUnhandledError);
}