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-52 (handler)The handler function for the browser_file_upload tool. It finds the file chooser modal, sets the files using the provided paths, and returns an action to execute along with code and snapshot instructions.
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 expected 'paths' parameter as an array of 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/files.ts:57-59 (registration)The tool is registered by exporting a factory function that returns the uploadFile tool instance.
export default (captureSnapshot: boolean) => [ uploadFile(captureSnapshot), ];