Skip to main content
Glama

browser_file_upload

Upload single or multiple files using specified file paths for browser automation tasks with Playwright MCP, enabling efficient file handling in web interactions.

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 main handler function that implements the logic for the 'browser_file_upload' tool. It verifies the presence of a file chooser modal, prepares a code snippet, defines an action to set the files using the provided paths, clears the modal state, and configures execution options.
    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, }; },
  • Schema definition for the 'browser_file_upload' tool, specifying the name, title, description, Zod input schema expecting an 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', },
  • Exports a factory function that returns an array containing the 'browser_file_upload' tool, used for registration in higher-level tool collections.
    export default (captureSnapshot: boolean) => [ uploadFile(captureSnapshot), ];
  • src/tools.ts:35-50 (registration)
    Registers the tools from files.ts (including 'browser_file_upload') into the snapshotTools array via spread of files(true).
    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), ];
  • src/tools.ts:52-66 (registration)
    Registers the tools from files.ts (including 'browser_file_upload') into the visionTools array via spread of files(false).
    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), ];

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

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