@@ -31,6 +31,7 @@ import { parseCommand } from './command';
3131import type * as mcp from '../../mcp/sdk/exports' ;
3232import type { BrowserContextFactory } from '../../mcp/browser/browserContextFactory' ;
3333import type { FullConfig } from '../../mcp/browser/config' ;
34+ import type { ServerInfo , SessionConfig } from '../client/registry' ;
3435
3536const daemonDebug = debug ( 'pw:daemon' ) ;
3637
@@ -45,11 +46,11 @@ async function socketExists(socketPath: string): Promise<boolean> {
4546}
4647
4748export async function startMcpDaemonServer (
48- config : FullConfig ,
49+ mcpConfig : FullConfig ,
50+ sessionConfig : SessionConfig ,
4951 contextFactory : BrowserContextFactory ,
5052) : Promise < string > {
51- const sessionConfig = config . sessionConfig ! ;
52- const { socketPath, version } = sessionConfig ;
53+ const { socketPath } = sessionConfig ;
5354 // Clean up existing socket file on Unix
5455 if ( os . platform ( ) !== 'win32' && await socketExists ( socketPath ) ) {
5556 daemonDebug ( `Socket already exists, removing: ${ socketPath } ` ) ;
@@ -81,7 +82,7 @@ export async function startMcpDaemonServer(
8182 const existingContextFactory = {
8283 createContext : ( ) => Promise . resolve ( { browserContext, close } ) ,
8384 } ;
84- const backend = new BrowserServerBackend ( config , existingContextFactory , { allTools : true } ) ;
85+ const backend = new BrowserServerBackend ( mcpConfig , existingContextFactory , { allTools : true } ) ;
8586 await backend . initialize ?.( clientInfo ) ;
8687
8788 await fs . mkdir ( path . dirname ( socketPath ) , { recursive : true } ) ;
@@ -94,7 +95,7 @@ export async function startMcpDaemonServer(
9495
9596 const server = net . createServer ( socket => {
9697 daemonDebug ( 'new client connection' ) ;
97- const connection = new SocketConnection ( socket , version ) ;
98+ const connection = new SocketConnection ( socket ) ;
9899 connection . onclose = ( ) => {
99100 daemonDebug ( 'client disconnected' ) ;
100101 } ;
@@ -114,6 +115,9 @@ export async function startMcpDaemonServer(
114115 toolParams . _meta = { cwd : params . cwd } ;
115116 const response = await backend . callTool ( toolName , toolParams ) ;
116117 await connection . send ( { id, result : formatResult ( response ) } ) ;
118+ } else if ( method === 'info' ) {
119+ const info : ServerInfo = { version : sessionConfig . version } ;
120+ await connection . send ( { id, result : info } ) ;
117121 } else {
118122 throw new Error ( `Unknown method: ${ method } ` ) ;
119123 }
0 commit comments