Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_file_upload

Destructive

Upload one or multiple files to a web page by providing absolute file paths. Cancel the file chooser by omitting the paths parameter.

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

  • The handler function for 'browser_file_upload'. It finds a file chooser modal state, sets the files via Playwright's setFiles, clears the modal state, and returns the action.
    const uploadFile: ToolFactory = captureSnapshot => defineTool({
      capability: 'files',
    
      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 (context, params) => {
        const modalState = context.modalStates().find(state => state.type === 'fileChooser');
        if (!modalState)
          throw new Error('No file chooser visible');
    
        const code = [
          `// <internal code to chose files ${params.paths.join(', ')}`,
        ];
    
        const action = async () => {
          await modalState.fileChooser.setFiles(params.paths);
          context.clearModalState(modalState);
        };
    
        return {
          code,
          action,
          captureSnapshot,
          waitForNetwork: true,
        };
      },
      clearsModalState: 'fileChooser',
    });
  • Input schema for 'browser_file_upload': requires 'paths' (array of absolute file path strings).
    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:35-66 (registration)
    Registration: 'browser_file_upload' is exported via files(true)/files(false) in snapshotTools and visionTools arrays.
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...wait(true),
    ];
    
    export const visionTools: Tool<any>[] = [
      ...common(false),
      ...console,
      ...dialogs(false),
      ...files(false),
      ...install,
      ...keyboard(false),
      ...navigate(false),
      ...network,
      ...pdf,
      ...tabs(false),
      ...testing,
      ...vision,
      ...wait(false),
    ];
  • Imports defineTool and ToolFactory from './tool.js' and zod for schema validation.
    import { z } from 'zod';
    import { defineTool, type ToolFactory } from './tool.js';
  • Helper: when a filechooser event fires on a page, it sets a FileUploadModalState on the context, which the handler then resolves.
      page.on('filechooser', chooser => {
        this.context.setModalState({
          type: 'fileChooser',
          description: 'File chooser',
          fileChooser: chooser,
        }, this);
      });
      page.on('dialog', dialog => this.context.dialogShown(this, dialog));
      page.on('download', download => {
        void this.context.downloadStarted(this, download);
      });
      page.setDefaultNavigationTimeout(60000);
      page.setDefaultTimeout(5000);
    }
Behavior2/5

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

The description only says 'Upload one or multiple files' and does not add behavioral details beyond what annotations provide (destructiveHint=true, openWorldHint=true). It misses explaining interactions like opening a file dialog or needing a file input.

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

Conciseness4/5

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

One sentence, no redundancy. While minimal, it is efficient and front-loaded. Slightly better than a tautology but still sparse.

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 simple tool with one parameter and annotations, the description is minimally acceptable. However, it lacks guidance on destructive behavior (destructiveHint=true) and prerequisites, leaving gaps.

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 coverage is 100%: the 'paths' parameter already has a clear description. The tool description adds no additional meaning beyond the schema, meeting baseline expectations.

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 it uploads files, aligning with the tool name. It is specific enough to distinguish from sibling browser tools, though it does not explicitly mention browser context.

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 on when to use this tool over alternatives or what prerequisites exist (e.g., needing a file input element). The description omits context for appropriate usage.

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

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