import type { Page, Browser, BrowserContext, Protocol } from 'puppeteer';
/**
* Information about an open browser tab
*/
export interface TabInfo {
/** Unique tab identifier (e.g., "tab_a1b2c3") */
id: string;
/** Current URL of the tab */
url: string;
/** Current page title */
title: string;
/** Whether this is the active tab */
isActive: boolean;
}
/**
* Tab manager interface for multi-tab support
*/
export interface TabManager {
/** Create a new tab, optionally navigating to a URL */
createTab(url?: string): Promise<TabInfo>;
/** Close a tab by ID */
closeTab(tabId: string): Promise<void>;
/** Get a page by tab ID */
getTab(tabId: string): Page | undefined;
/** Get the currently active page */
getActiveTab(): Page | undefined;
/** Get the active tab ID */
getActiveTabId(): string | undefined;
/** List all open tabs */
listTabs(): Promise<TabInfo[]>;
/** Switch to a specific tab */
setActiveTab(tabId: string): Promise<void>;
/** Close all tabs and cleanup */
close(): Promise<void>;
}
/**
* Browser state management
*/
export interface BrowserState {
browser: Browser | null;
context: BrowserContext | null;
}
/**
* Configuration for the MCP server
*/
export interface ServerConfig {
/** Whether to run browser in headless mode */
headless: boolean;
/** Default timeout for operations in ms */
timeout: number;
/** HTTP server port (for HTTP transport) */
port: number;
}
/**
* Navigation result
*/
export interface NavigationResult {
url: string;
title: string;
status?: number;
}
/**
* Screenshot result
*/
export interface ScreenshotResult {
/** Base64-encoded image data */
data: string;
/** Image format */
format: 'png' | 'jpeg' | 'webp';
}
/**
* PDF result
*/
export interface PdfResult {
/** Base64-encoded PDF data */
data: string;
}
/**
* Evaluate result
*/
export interface EvaluateResult {
/** Result of JavaScript evaluation (serialized) */
result: unknown;
}
/**
* Element info from querySelector
*/
export interface ElementInfo {
/** Whether element exists */
exists: boolean;
/** Element tag name */
tagName?: string;
/** Element text content */
textContent?: string;
/** Element attributes */
attributes?: Record<string, string>;
/** Bounding box */
boundingBox?: {
x: number;
y: number;
width: number;
height: number;
};
}
/**
* Cookie type (re-export from Puppeteer)
*/
export type Cookie = Protocol.Network.Cookie;
/**
* Cookie to set
*/
export interface CookieParam {
name: string;
value: string;
domain?: string;
path?: string;
expires?: number;
httpOnly?: boolean;
secure?: boolean;
sameSite?: 'Strict' | 'Lax' | 'None';
}
/**
* Wait until options for navigation
*/
export type WaitUntilOption = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
/**
* Mouse button options
*/
export type MouseButton = 'left' | 'right' | 'middle';
/**
* Keyboard modifier keys
*/
export type KeyModifier = 'Alt' | 'Control' | 'Meta' | 'Shift';
/**
* Scroll direction
*/
export type ScrollDirection = 'up' | 'down' | 'left' | 'right';
/**
* Mouse action type
*/
export type MouseAction = 'move' | 'click' | 'down' | 'up';
/**
* Screenshot format
*/
export type ScreenshotFormat = 'png' | 'jpeg' | 'webp';
/**
* PDF format
*/
export type PdfFormat = 'Letter' | 'Legal' | 'Tabloid' | 'Ledger' | 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6';
/**
* Content type for get_content tool
*/
export type ContentType = 'html' | 'text';