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);
        },
      };
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior3/5

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

Annotations already indicate this is a destructive, non-read-only operation with open-world behavior. The description adds no behavioral context beyond what annotations provide (e.g., no details on upload destinations, error handling, or file size limits), but it doesn't contradict annotations either.

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 at just four words, front-loading the core action and resource with zero wasted language. Every word earns its place by clearly communicating the essential function.

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?

For a destructive tool with no output schema, the description is minimally complete but lacks important context. It doesn't explain what happens after upload, potential side effects, or error conditions, leaving gaps despite good annotations covering basic safety profile.

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?

With 100% schema description coverage, the input schema fully documents the 'paths' parameter. The description mentions 'one or multiple files' which aligns with the schema but adds no additional semantic context beyond what's already in the structured data.

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 clearly states the action ('upload') and resource ('one or multiple files'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling upload tools (though none exist in the provided sibling list), which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives or prerequisites. It doesn't mention context like browser state requirements or when other browser tools might be more appropriate, leaving the agent with minimal usage direction.

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