Skip to main content
Glama

download_files

Download files from web pages using browser automation. Ideal for extracting content, generating PDFs, or saving media files directly through the Browserless MCP Server.

Instructions

Handle file downloads

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
contextNo

Implementation Reference

  • MCP tool handler for 'download_files': validates args, calls client.downloadFiles, constructs MCP response with text summary and binary file contents.
    case 'download_files': { if (!args) throw new Error('Arguments are required'); const result = await this.client!.downloadFiles(args as any); if (result.success && result.data) { const content = [ { type: 'text', text: `Downloaded ${result.data.files.length} files successfully.`, }, ]; for (const file of result.data.files) { content.push({ type: 'binary', mimeType: file.type, data: file.data.toString('base64'), } as any); } return { content }; } else { throw new Error(result.error || 'Failed to download files'); } }
  • src/index.ts:147-158 (registration)
    Registration of the 'download_files' tool in the ListTools response, including name, description, and input schema.
    { name: 'download_files', description: 'Handle file downloads', inputSchema: { type: 'object', properties: { code: { type: 'string' }, context: { type: 'object' }, }, required: ['code'], }, },
  • BrowserlessClient.downloadFiles method: HTTP POST to '/download' endpoint, handles response and errors.
    async downloadFiles(request: DownloadRequest): Promise<BrowserlessResponse<DownloadResponse>> { try { const response: AxiosResponse<DownloadResponse> = await this.httpClient.post('/download', request, { headers: { 'Content-Type': 'application/javascript', }, }); return { success: true, data: response.data, }; } catch (error) { return this.handleError(error); } }
  • Zod schema and TypeScript type definition for DownloadRequest (input validation for download_files).
    export const DownloadRequestSchema = z.object({ code: z.string(), context: z.record(z.any()).optional(), }); export type DownloadRequest = z.infer<typeof DownloadRequestSchema>;
  • TypeScript interface for DownloadResponse (output structure from download_files).
    export interface DownloadResponse { files: Array<{ name: string; data: Buffer; type: string; }>; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Lizzard-Solutions/browserless-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server