Skip to main content
Glama

browser_file_upload

Destructive

Upload files to web pages during browser automation. Specify file paths to simulate file selection in forms for testing or data entry workflows.

Instructions

Upload one or multiple files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYesThe absolute paths to the files to upload. Can be a single file or multiple files.

Implementation Reference

  • The core handler function implementing the browser_file_upload tool logic. It handles file upload by interacting with the file chooser modal state in the current tab, setting the files via Playwright API.
    handle: async (tab, params, response) => {
      response.setIncludeSnapshot();
    
      const modalState = tab.modalStates().find(state => state.type === 'fileChooser');
      if (!modalState)
        throw new Error('No file chooser visible');
    
      response.addCode(`await fileChooser.setFiles(${JSON.stringify(params.paths)})`);
    
      tab.clearModalState(modalState);
      await tab.waitForCompletion(async () => {
        await modalState.fileChooser.setFiles(params.paths);
      });
    },
  • Zod-based schema definition for the tool, specifying name, title, description, input parameters (array of file paths), and destructive type.
    schema: {
      name: 'browser_file_upload',
      title: 'Upload files',
      description: 'Upload one or multiple files',
      inputSchema: z.object({
        paths: z.array(z.string()).describe('The absolute paths to the files to upload. Can be a single file or multiple files.'),
      }),
      type: 'destructive',
    },
  • Export of the defined tool (uploadFile) as default array for inclusion in higher-level tool lists.
    export default [
      uploadFile,
    ];
  • src/tools.ts:36-52 (registration)
    Top-level registration where tools from files.ts (including browser_file_upload) are spread into the allTools array, imported at line 21.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];
  • Helper function defineTabTool used to wrap tab-specific tools, adding modal state validation before calling the custom handler.
    export function defineTabTool<Input extends z.Schema>(tool: TabTool<Input>): Tool<Input> {
      return {
        ...tool,
        handle: async (context, params, response) => {
          const tab = context.currentTabOrDie();
          const modalStates = tab.modalStates().map(state => state.type);
          if (tool.clearsModalState && !modalStates.includes(tool.clearsModalState))
            response.addError(`Error: The tool "${tool.schema.name}" can only be used when there is related modal state present.\n` + tab.modalStatesMarkdown().join('\n'));
          else if (!tool.clearsModalState && modalStates.length)
            response.addError(`Error: Tool "${tool.schema.name}" does not handle the modal state.\n` + tab.modalStatesMarkdown().join('\n'));
          else
            return tool.handle(tab, params, response);
        },
      };
    }
Behavior3/5

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

Annotations provide readOnlyHint=false, openWorldHint=true, and destructiveHint=true, indicating it's a mutable, open-ended, and potentially destructive operation. The description adds minimal behavioral context beyond this, such as not specifying what 'upload' entails (e.g., to a server, local storage) or any rate limits. It doesn't contradict annotations, but offers little extra insight.

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

Conciseness5/5

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

The description is extremely concise with a single sentence 'Upload one or multiple files', which is front-loaded and wastes no words. Every part of the sentence directly contributes to understanding the tool's purpose without redundancy.

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

Completeness3/5

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

Given the tool's moderate complexity (file upload with destructive potential), annotations cover safety aspects, but the description lacks details on output (no schema provided), error handling, or environmental needs (e.g., browser context). It's minimally adequate but leaves gaps for an agent to infer usage.

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

Parameters3/5

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

The input schema has 100% description coverage, with the 'paths' parameter fully documented in the schema. The description adds no additional semantic meaning beyond implying file uploads, which is already clear from the tool name and schema. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description 'Upload one or multiple files' clearly states the action (upload) and resource (files), with specificity about quantity (one or multiple). It distinguishes from sibling tools like browser_navigate or browser_click by focusing on file uploads, though it doesn't explicitly differentiate from all siblings (e.g., browser_drag could involve files).

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

Usage Guidelines2/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. The description lacks context about prerequisites (e.g., needing an open browser session), exclusions (e.g., not for network requests), or comparisons to other file-related tools (none in siblings, but general alternatives aren't mentioned).

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/maywzh/playwright-mcp'

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