@dorothywebb/any-browser-mcp
Version:
Any Browser MCP - Launch Chrome with your actual data in debug mode for comprehensive browser automation
95 lines • 2.79 kB
TypeScript
/**
* Browser Connection Utility - STRICT EXISTING BROWSER ONLY
* This utility NEVER launches browsers, only connects to existing ones
*/
import { PageInfo, ConnectionState } from '../types/index.js';
import { ChromeInstance } from './ChromeLauncher.js';
export declare class BrowserConnection {
private ws;
private state;
private config;
private messageId;
private pendingMessages;
private chromeLauncher;
private mcpChromeInstance;
private discoveredPort;
constructor();
/**
* Discover active Chrome debug ports by scanning common port ranges
*/
discoverChromeDebugPort(): Promise<{
port: number;
pages: PageInfo[];
} | null>;
/**
* Get available pages from a specific port with custom timeout
*/
private getAvailablePagesOnPort;
/**
* Check if a browser is running with debugging enabled
* This method ONLY checks - it NEVER launches anything
* Now includes dynamic port discovery
*/
checkBrowserAvailability(): Promise<{
available: boolean;
reason?: string;
discoveredPort?: number;
}>;
/**
* Get available pages from existing browser
* NEVER launches - only queries existing browser
* Uses discovered port if available
*/
getAvailablePages(): Promise<PageInfo[]>;
/**
* Connect to browser page - either existing or launch separate MCP instance
*/
connectToPage(pageId?: string): Promise<void>;
/**
* Establish WebSocket connection to browser
*/
private establishWebSocketConnection;
/**
* Send command to browser via CDP
*/
sendCommand(method: string, params?: any): Promise<any>;
/**
* Check if connected to browser
*/
isConnected(): boolean;
/**
* Get current connection state
*/
getState(): ConnectionState;
/**
* Get the currently active debug port (discovered or configured)
*/
getActiveDebugPort(): number;
/**
* Get information about port discovery
*/
getPortInfo(): {
configuredPort: number;
discoveredPort: number | null;
activePort: number;
};
/**
* Disconnect from browser
*/
disconnect(): Promise<void>;
/**
* Disconnect and optionally close MCP Chrome instance
*/
disconnectAndClose(closeMCPInstance?: boolean): Promise<void>;
/**
* Get MCP Chrome instance information
*/
getMCPInstance(): ChromeInstance | null;
/**
* SAFETY CHECK: Prevent any accidental browser launching
* This method always throws an error if called
*/
private launchBrowser;
}
export declare function createBrowserConnection(): BrowserConnection;
//# sourceMappingURL=BrowserConnection.d.ts.map