chore: extract pure mcp server helpers (#751)

This commit is contained in:
Pavel Feldman
2025-07-24 12:57:01 -07:00
committed by GitHub
parent bd34e9d7e9
commit c63b7823e1
12 changed files with 300 additions and 469 deletions

View File

@@ -14,10 +14,11 @@
* limitations under the License.
*/
import { createMCPServer } from './connection.js';
import { BrowserServerBackend } from './browserServerBackend.js';
import { resolveConfig } from './config.js';
import { contextFactory } from './browserContextFactory.js';
import { filteredTools } from './tools.js';
import * as mcpServer from './mcp/server.js';
import type { Config } from '../config.js';
import type { BrowserContext } from 'playwright';
import type { BrowserContextFactory } from './browserContextFactory.js';
@@ -26,7 +27,7 @@ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
export async function createConnection(userConfig: Config = {}, contextGetter?: () => Promise<BrowserContext>): Promise<Server> {
const config = await resolveConfig(userConfig);
const factory = contextGetter ? new SimpleBrowserContextFactory(contextGetter) : contextFactory(config.browser);
return createMCPServer(config, filteredTools(config), factory);
return mcpServer.createServer(new BrowserServerBackend(config, factory));
}
class SimpleBrowserContextFactory implements BrowserContextFactory {