export_page
Export a webpage and its resources for offline use or analysis. Specify a URL, headers, and optional best-attempt mode to capture content efficiently through browser automation.
Instructions
Export webpage with resources
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bestAttempt | No | ||
| headers | No | ||
| url | Yes |
Implementation Reference
- src/index.ts:416-435 (handler)MCP tool handler for 'export_page' that validates arguments, calls the client.exportPage method, and formats the response as MCP content.case 'export_page': { if (!args) throw new Error('Arguments are required'); const result = await this.client!.exportPage(args as any); if (result.success && result.data) { return { content: [ { type: 'text', text: `Page exported successfully with ${result.data.resources.length} resources.`, }, { type: 'text', text: result.data.html, }, ], }; } else { throw new Error(result.error || 'Failed to export page'); } }
- src/client.ts:169-180 (handler)Core client method that sends HTTP POST request to Browserless /export endpoint with ExportRequest and returns the ExportResponse.async exportPage(request: ExportRequest): Promise<BrowserlessResponse<ExportResponse>> { try { const response: AxiosResponse<ExportResponse> = await this.httpClient.post('/export', request); return { success: true, data: response.data, }; } catch (error) { return this.handleError(error); } }
- src/types.ts:185-197 (schema)Zod schema and TypeScript type definition for ExportRequest used in the exportPage tool.export const ExportRequestSchema = z.object({ url: z.string(), headers: z.record(z.string()).optional(), gotoOptions: z.object({ waitUntil: z.string().optional(), timeout: z.number().optional(), }).optional(), waitForSelector: WaitForSelectorSchema.optional(), waitForTimeout: z.number().optional(), bestAttempt: z.boolean().optional(), }); export type ExportRequest = z.infer<typeof ExportRequestSchema>;
- src/index.ts:160-171 (registration)Tool registration in ListTools response, including name, description, and simplified input schema.name: 'export_page', description: 'Export webpage with resources', inputSchema: { type: 'object', properties: { url: { type: 'string' }, headers: { type: 'object' }, bestAttempt: { type: 'boolean' }, }, required: ['url'], }, },
- src/types.ts:284-291 (schema)TypeScript interface for ExportResponse returned by the export_page tool.export interface ExportResponse { html: string; resources: Array<{ url: string; data: Buffer; type: string; }>; }