initialize_browserless
Establish a connection to a Browserless instance for browser automation, enabling tasks like PDF generation, screenshots, content extraction, and performance audits.
Instructions
Initialize connection to Browserless instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| concurrent | No | ||
| host | No | localhost | |
| port | No | ||
| protocol | No | http | |
| timeout | No | ||
| token | Yes |
Implementation Reference
- src/index.ts:288-300 (handler)The main handler function for the 'initialize_browserless' tool. It parses the input arguments using BrowserlessConfigSchema, creates a new BrowserlessClient instance with the config, fetches the health status, and returns a success message with the health info.case 'initialize_browserless': { const config = BrowserlessConfigSchema.parse(args); this.client = new BrowserlessClient(config); const health = await this.client.getHealth(); return { content: [ { type: 'text', text: `Browserless client initialized successfully. Health status: ${health.data?.status || 'unknown'}`, }, ], }; }
- src/index.ts:36-50 (registration)Registration of the 'initialize_browserless' tool in the list of available tools, including its description and input schema.name: 'initialize_browserless', description: 'Initialize connection to Browserless instance', inputSchema: { type: 'object', properties: { host: { type: 'string', default: 'localhost' }, port: { type: 'number', default: 3000 }, token: { type: 'string' }, protocol: { type: 'string', enum: ['http', 'https', 'ws', 'wss'], default: 'http' }, timeout: { type: 'number', default: 30000 }, concurrent: { type: 'number', default: 5 }, }, required: ['token'], }, },
- src/types.ts:4-11 (schema)Zod schema definition for BrowserlessConfig, used to validate the tool's input arguments in the handler.export const BrowserlessConfigSchema = z.object({ host: z.string().default('localhost'), port: z.number().default(3000), token: z.string(), protocol: z.enum(['http', 'https', 'ws', 'wss']).default('http'), timeout: z.number().default(30000), concurrent: z.number().default(5), });
- src/index.ts:282-283 (helper)Helper guard clause that ensures the browserless client is initialized by calling this tool before other browserless tools.if (!this.client && name !== 'initialize_browserless') { throw new Error('Browserless client not initialized. Call initialize_browserless first.');