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-46 (handler)The handler function that executes the browser_file_upload tool. It validates the input parameters, retrieves the current tab, submits the file paths to the file chooser, and returns a code snippet indicating the internal file selection.
handle: async (context, params) => { const validatedParams = uploadFileSchema.parse(params); const tab = context.currentTab(); return await tab.runAndWait(async () => { await tab.submitFileChooser(validatedParams.paths); const code = [ `// <internal code to chose files ${validatedParams.paths.join(', ')}`, ]; return { code }; }, { captureSnapshot, noClearFileChooser: true, }); }, - src/tools/files.ts:22-32 (schema)Defines the Zod schema for input validation (paths array) and the tool schema object including the name 'browser_file_upload', description, and converted JSON schema.
const uploadFileSchema = z.object({ paths: z.array(z.string()).describe('The absolute paths to the files to upload. Can be a single file or multiple files.'), }); const uploadFile: ToolFactory = captureSnapshot => ({ capability: 'files', schema: { name: 'browser_file_upload', description: 'Upload one or multiple files', inputSchema: zodToJsonSchema(uploadFileSchema), }, - src/tools/files.ts:49-51 (registration)Registers the browser_file_upload tool by including the uploadFile factory in the exported array of tools.
export default (captureSnapshot: boolean) => [ uploadFile(captureSnapshot), ];