export_page
Export webpages with all embedded resources for offline use or archiving. This tool captures complete page content including images, stylesheets, and scripts from any URL.
Instructions
Export webpage with resources
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| headers | No | ||
| bestAttempt | No |
Implementation Reference
- src/client.ts:169-180 (handler)Core handler implementation for the 'export_page' tool. Makes a POST request to Browserless /export endpoint with ExportRequest and returns 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/index.ts:159-171 (registration)Tool registration in MCP ListTools response, defining name, description, and input schema for 'export_page'.{ name: 'export_page', description: 'Export webpage with resources', inputSchema: { type: 'object', properties: { url: { type: 'string' }, headers: { type: 'object' }, bestAttempt: { type: 'boolean' }, }, required: ['url'], }, },
- src/index.ts:416-435 (handler)MCP CallTool handler that invokes BrowserlessClient.exportPage and formats the response.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/types.ts:185-197 (schema)Detailed Zod schema validation for ExportRequest input type.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/types.ts:284-291 (schema)TypeScript interface for ExportResponse output type.export interface ExportResponse { html: string; resources: Array<{ url: string; data: Buffer; type: string; }>; }