Skip to main content
Glama
nzjami

Playwright MCP

by nzjami

browser_file_upload

Destructive

Upload files to web pages during browser automation. Specify file paths to simulate user file selection in automated testing scenarios.

Instructions

Upload one or multiple files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsNoThe absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled.

Implementation Reference

  • Handler function that manages file upload in the browser's file chooser modal by setting the files and waiting for completion.
    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(`// Select files for upload`);
      response.addCode(`await fileChooser.setFiles(${JSON.stringify(params.paths)})`);
    
      tab.clearModalState(modalState);
      await tab.waitForCompletion(async () => {
        await modalState.fileChooser.setFiles(params.paths);
      });
    },
  • Schema definition for the browser_file_upload tool, specifying input as array of file paths and marking it as destructive.
    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',
    },
  • src/tools.ts:36-52 (registration)
    Central registration of all tools, including browser_file_upload via the spread of the 'files' import.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];
  • src/tools.ts:21-21 (registration)
    Import of the files tool module which contains the browser_file_upload tool.
    import files from './tools/files.js';
  • Tool definition using defineTabTool, which creates and exports the browser_file_upload tool instance.
    const uploadFile = defineTabTool({
      capability: 'core',
    
      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',
      },
    
      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(`// Select files for upload`);
        response.addCode(`await fileChooser.setFiles(${JSON.stringify(params.paths)})`);
    
        tab.clearModalState(modalState);
        await tab.waitForCompletion(async () => {
          await modalState.fileChooser.setFiles(params.paths);
        });
      },
      clearsModalState: 'fileChooser',
    });
Behavior3/5

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

Annotations provide readOnlyHint=false, destructiveHint=true, and openWorldHint=true, indicating a write operation with potential side effects. The description adds that it can upload 'one or multiple files' and implies a file chooser interaction if paths are omitted, but doesn't elaborate on authentication, rate limits, or specific destructive outcomes beyond annotations.

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 a single, efficient sentence with no wasted words. It's front-loaded with the core action ('upload files') and adds a useful detail about handling multiple files, making it highly concise and well-structured.

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 complexity (file upload with potential side effects), annotations cover safety aspects, but the description lacks details on error handling, supported file types, or interaction with browser state. With no output schema, it doesn't explain return values, leaving gaps for an agent to infer behavior.

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?

Schema description coverage is 100%, with the 'paths' parameter fully documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as file format constraints or upload behavior details, so it meets the baseline for high 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 clearly states the verb ('upload') and resource ('files'), specifying it can handle 'one or multiple files'. It distinguishes from sibling tools like browser_navigate or browser_type by focusing on file uploads, though it doesn't explicitly differentiate from all siblings.

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 doesn't mention prerequisites, context (e.g., browser state), or exclusions, leaving the agent to infer usage from the tool name alone.

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/nzjami/mcpPlaywright'

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