Skip to main content
Glama

download_files

Handle file downloads from web pages using browser automation. This tool processes download requests to save files locally during web scraping or automation tasks.

Instructions

Handle file downloads

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
contextNo

Implementation Reference

  • Core handler implementation that sends a POST request to the Browserless '/download' endpoint with the provided request and handles the response containing downloaded files.
    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);
      }
    }
  • MCP tool handler for 'download_files' that calls the client.downloadFiles method, processes the result, and returns MCP-formatted content with binary file data.
    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'],
      },
    },
  • Zod schema and TypeScript type definition for the DownloadRequest input.
    export const DownloadRequestSchema = z.object({
      code: z.string(),
      context: z.record(z.any()).optional(),
    });
    
    export type DownloadRequest = z.infer<typeof DownloadRequestSchema>;
  • TypeScript interface for the DownloadResponse output containing array of downloaded files.
    export interface DownloadResponse {
      files: Array<{
        name: string;
        data: Buffer;
        type: string;
      }>;
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Handle file downloads' is extremely vague—it doesn't specify if this is a read-only operation, requires authentication, has rate limits, affects system state, or what the output entails. This leaves critical behavioral traits unknown.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with a single phrase, but it's under-specified rather than efficiently informative. While it avoids unnecessary words, it lacks the structure needed to convey meaningful information, making it more of a placeholder than a helpful description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity implied by 2 parameters (including a nested object), no annotations, no output schema, and 0% schema coverage, the description is completely inadequate. It doesn't address what the tool does, how to use it, what parameters mean, or what to expect, leaving the agent with insufficient context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter details. The description adds no information about the parameters 'code' (a required string) or 'context' (an object), failing to explain their purpose, format, or how they relate to file downloads. This is inadequate for a tool with 2 parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Handle file downloads' is tautological with the tool name 'download_files', essentially restating the name without adding specificity. It doesn't clarify what types of files, from what source, or with what constraints, making it vague about the actual purpose beyond the obvious.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. With sibling tools like 'export_page', 'generate_pdf', and 'take_screenshot' that might involve file outputs, there's no indication of how 'download_files' differs or when it's the appropriate choice, leaving the agent without usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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