browser_file_upload
Upload files to web forms during browser automation. Specify file paths to simulate user file selection in automated web interactions.
Instructions
Upload one or multiple files
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | No | The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled. |
Implementation Reference
- src/tools/files.ts:33-53 (handler)The handler function that executes the browser_file_upload tool. It finds the file chooser modal state, creates an action to set the files from the provided paths, and returns code, action, and other execution details.
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, }; }, - src/tools/files.ts:23-31 (schema)Input schema and metadata for the browser_file_upload tool, defining the name, title, description, input parameters (paths array), 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', }, - src/tools.ts:35-50 (registration)Registration of the browser_file_upload tool by including the files tools factory (...files(true)) in the snapshotTools array, which is later used to provide tools to the MCP server.
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)Registration of the browser_file_upload tool by including the files tools factory (...files(false)) in the visionTools array for vision mode.
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), ];